What can we help you with today?

Log in and chat with an Applications Engineer now! Check out our chat button in the bottom right corner!

What can we help you with today?

Log in and chat with an Applications Engineer now! Check out our chat button in the bottom right corner!

Place Attribute Text Template

Comments

4 comments

  • bob larranaga
    bob larranaga

    I'm not sure if this is what you're looking for. I'm assuming that you're placing on formboard sheet?

    The script below searches for a connector X1. It finds the Default Template as an attribute. It creates a formboard device and places a symbol using the Default Template. It then assigns the symbol to the formboard device.

    Option Explicit
    Dim e3  : Set e3 = CreateObject("CT.Application")
    Dim job : Set job = e3.CreateJobObject()
    Dim dev : Set dev = job.CreateDeviceObject()
    Dim sym : Set sym = job.CreateSymbolObject()

    e3.ClearOutputWindow

    Dim devId : devId = dev.Search("X1", "", "")

    If devId <> 0 Then
        Call Test()
    Else
        e3.PutError 0, "Device not found", 0
    End If

    Set job = Nothing
    Set e3 = Nothing

    Sub Test()
        Dim symTemplate : symTemplate = dev.GetAttributeValue(".DEFAULT_TEMPLATE")

        If symTemplate <> "" Then
            ' must be "clicked" inside formboard sheet
            Dim fbShtId : fbShtId = job.GetActiveSheetId()
            Dim fbDevId : fbDevId = dev.CreateFormboard(devId, fbShtId)

            sym.Load symTemplate, ""
            Dim symId   : symId = sym.Place(fbShtId, 5, 5, "0")
            Dim ret     : ret   = sym.AssignTo(fbDevId)

            e3.PutMessage "Attribute Text Template: " & symTemplate
            e3.PutMessage "Formboard Id: " & fbDevId
            e3.PutMessage "Assigned: " & ret
        Else
            e3.PutError 0, "Device does not have a .DEFAULT_TEMPLATE", 0
        End If
    End Sub

    Was this Helpful?

    0
  • Christian Dupuis
    Christian Dupuis

    Hey Bob,

    Thanks for the input! I get the idea of your suggested code.

    I inserted my section of code that matches up the connector and the attribute text template and was wondering if you think your sub test() function would run incorporated in here since I already match the correct attribute template

    Was this Helpful?

    0
  • bob larranaga
    bob larranaga

    i guess it depends. i

    i'm not sure the context of the foreach loop. it looks like its searching for Attribute Text Template symbols that are already placed.

    if the attribute text templates are not placed, then the loop would not find the device on the sheet?

    if they are placed as views, in order to retrieve the DEFAULT_TEMPLATE attribute, i believe you can only retrieve attribute values from the original device (unless Zuken E3 COM has been updated which is possible). 

    Was this Helpful?

    0
  • Christian Dupuis
    Christian Dupuis

    Yeah right now the program searches for the attribute template already on the formboard and then adds the labels but I am trying to make it so I can add the template and the labels at the same time. Probably have to try taking out the foreach that looks for the template already on the formboard.

    Was this Helpful?

    0

Please sign in to leave a comment.