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!

How to Access Placed Device Views by using Script ??

Comments

11 comments

  • bob larranaga
    bob larranaga

    use the Device method GetViewIds(). example below in pseudo-vbscript. won't run but shows the basics

    Set dev = CreateObject("CT.Device")
    dev.SetId (id of the device you have selected)

    Dim intViewCount, viewIds
    intViewCount = dev.GetViewIds(viewIds) '<<< access device views
    For j = 1 to intViewCount
    dev.SetId viewIds(j)
    Dim msg
    msg = "Dev: " & dev.GetName() & " #" & dev.GetViewNumber()
    e3.PutMessage msg
    Next

    Was this Helpful?

    1
  • rana
    rana

    thank you so much.

    Can i Set  attributes  to respective View.???

    Was this Helpful?

    0
  • bob larranaga
    bob larranaga

    i am not sure that it is possible to set a view with an attribute. try it for yourself. 

    i've had issues where if i need to read an attribute off of a device and the device happens to be a view, the attribute will not be returned. this is why i don't think its possible to set the view with an attribute.

    if it is necessary to store an attribute related to a view, i would store it as an attribute of the view symbol.

    FWIW... in order to access the attribute of a device, script needs to check if the device object has a parent using GetOriginald(). If parent exists then need to set the ID to the OriginaId.

    Dim intOrginalId
    intOriginalId = dev.GetOriginalId()

    If intOrginalId <> 0 Then
       dev.SetId intOrginalId
    End If

     

     

    Was this Helpful?

    1
  • rana
    rana

    Here am trying to assign attribute (UNIT OF MEASURE) in Existing View P1#2.

    i tried but am not able to assign attribute to device.

    but i can assign attribute to OriginalId() and  not to the View(P1#2)

    Was this Helpful?

    0
  • bob larranaga
    bob larranaga

    i am not sure i understand your need to set Unit of Measure on a device view. this doesn't sound right.

    if a component like a connector has an Unit of Measure set to "EACH", then the unit of measure for all devices of the connector should be "EACH".

    if you had multiple views of the same device AND each device had the Unit of Measure BUT different values, then this would introduce conflicts within the data model.

    therefore it should not be possible for a representation of a parent device to have attribute values different than its parent. 

    i recommend accessing Unit of Measure using the Component interface but you'd likely need to update your library so Unit of Measure is defined in the component.

    if you have to apply Unit of Measure to a device, you'll need to set it at the parent device, not the view.

    Was this Helpful?

    0
  • rana
    rana

    Thank you bob.

    In case of BoM Position attribute , i want to show BoM Position Value only in Particular View.

    Was this Helpful?

    0
  • bob larranaga
    bob larranaga

    If the connector symbol has the following:

    • A TextType to show BoM Position
    • BoM Position TextType is initially set to "Invisible" (check marked is set)
    • BoM Position TextType is mapped to an attribute of BoM Position

    Then either the user or a script could set the text type to be visible so that the value of BoM position appears in a particular view.

    Was this Helpful?

    0
  • rana
    rana

    through the script can i set the text type attribute(BoM Position) for DeviceView??

    Was this Helpful?

    0
  • bob larranaga
    bob larranaga

    the TextType belongs to the symbol.

    i haven't tried this but presumably you would need to get a list of symbol Ids that belong to the device view. initialize the symbol object to the first ID found, then get a list of TextTypeIds and find the one that matches TextType. then set the text type visibility.

    Was this Helpful?

    0
  • rana
    rana

    (User Manual Process)

    when ever we assign a BOM Postion in Device Properties (parent device ),

    is it visible in all device Views???

    Was this Helpful?

    0
  • bob larranaga
    bob larranaga

    should be visible if your symbols have the BOM Position text type.

    Was this Helpful?

    0

Please sign in to leave a comment.