AnsweredAssumed Answered

Update Border Properties with Automation

Question asked by andrew_french on Jul 26, 2011
Latest reply on Jul 27, 2011 by andrew_french

I've got a script that runs when a DxDesigner project is opened and it is supposed to update certain properties associated with the sheet border(s).


The script works only once I've manually changed a property in Dx from the default value built into the library symbol.  If I leave the value unedited the script runs fine and throws no errors but the value is never updated.  Feel like its a bug in the automation implementation but figured I'd post up in here just to have my code checked/verified first.


EE7.9.1 update 1

Code is in  (Haven't figured out how to traverse sheets in C# yet...)



Private Sub writeData()


Dim schmObj As ViewDraw.IStringList

Dim sheetObj As ViewDraw.IStringList

Dim compObj As ViewDraw.IVdObjs

Dim comp As ViewDraw.Component

Dim fail As Boolean = True

Dim origin As ViewDraw.IVdPoint

VdApp.Visible = False

VdApp.AppendOutput("Output", "Updating Border Properties...")


'Get the collection of schematic in the project

schmObj = VdApp.SchematicSheetDocuments.GetAvailableSchematics


'Iterate throught the collection of schematics

For x = 1 To schmObj.GetCount


     'Get the collection of sheets in the current schematic

     sheetObj = VdApp.SchematicSheetDocuments.GetAvailableSheets(schmObj.GetItem(x))


     'Iterate through the collection of sheets

     For y = 1 To sheetObj.GetCount


          'Open the sheet

          VdApp.SchematicSheetDocuments.Open(schmObj.GetItem(x), sheetObj.GetItem(y))


          'Get the collection of components on the sheet

          compObj = VdApp.Query(ViewDraw.VdObjectTypeMask.VDM_COMP, ViewDraw.VdAllOrSelected.VD_ALL)


          'Iterate through the collection of components

          For z = 1 To compObj.Count

               comp = compObj.Item(z)


               'Get the location of the current component

               'Only care about the border here and it will always have a location of (0,0)

               origin = comp.GetLocation


               If origin.X = 0 Then

                    If origin.Y = 0 Then

                         fail = setAttribute(comp, "cad_ident", VdApp.Version, x, y)

                         z = compObj.Count

                    End If

               End If









If fail = False Then

     VdApp.AppendOutput("Output", "BorderFill Script completed with errors, Please view the BorderFill log: File -> File Viewer")


     VdApp.AppendOutput("Output", "BorderFill Script completed successfully!")

     writer.WriteLine("BorderFill Script completed successfully!")


End If

VdApp.Visible = True


End Sub


Private Function setAttribute(ByVal c As ViewDraw.Component, ByVal attrName As String, ByVal attrValue As String, ByVal x As Integer, ByVal y As Integer) As Boolean


Dim attr As ViewDraw.Attribute

setAttribute = True



     attr = c.FindAttribute(attrName)

     attr.Value = attrValue

Catch ex As Exception

     writer.WriteLine("Property '" & attrName & "' FAILED to update on schematic " & x & " sheet " & y)

     setAttribute = False


End Try


End Function