AnsweredAssumed Answered

DxDesigner automation in vb.net

Question asked by french on Jul 28, 2010
Latest reply on Aug 3, 2010 by french

In this example the call comp.SymbolBlock.ChangeComponent changes every instance of the old component on the current sheet once the first component is found that meets the stated criteria.  The way this is written one would expect that this call should only change the current component.  This really wouldnt be an issue if I didn't need to move the onsheet components after the swap so that the net and pin connect correctly.  How do I change a component from type "A" to type "B" but do them one at a time?

 

DxDesigner version EE7.9

 

    Private Sub FindOffPage()
        Dim schmObj As ViewDraw.IStringList
        Dim sheetObj As ViewDraw.IStringList
        Dim compObj As ViewDraw.IVdObjs
        Dim comp As ViewDraw.Component
        Dim loc As ViewDraw.IVdPoint
        Dim compName As String

 

        'Get the list of schematics in project
        schmObj = appDX.SchematicSheetDocuments.GetAvailableSchematics

 

        'Iterate through each schematic
        For x = 1 To schmObj.GetCount

 

            'Get list of sheets in current schematic
            sheetObj = appDX.SchematicSheetDocuments.GetAvailableSheets(schmObj.Item(x))

 

            'Iterate through each sheet in current schematic
            For y = 1 To sheetObj.GetCount

 

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

 

                'Get collection of all components on current sheet
                compObj = appDX.ActiveView.Query(ViewDraw.VdObjectTypeMask.VDM_COMP, ViewDraw.VdAllOrSelected.VD_ALL)

 

                'Iterate through each component in current sheet
                For z = 1 To compObj.Count

 

                    comp = compObj.Item(z)
                    compName = comp.SymbolBlock.GetName(ViewDraw.VdNameType.FULL_PATH_FROM_BLOCK)

 

                    'Test if current component is type offpage
                    Select Case compName

 

                        Case "offpage_out"
                            Try
                                comp.SymbolBlock.ChangeComponent(compName, "offsheet")
                            Catch
                            End Try

 

                        Case "offpage_in"
                            Try
                                comp.SymbolBlock.ChangeComponent(compName, "onsheet")
                                'loc = comp.GetLocation()
                                'comp.SetLocation(loc.X - 1, loc.Y)
                            Catch
                            End Try

 

                    End Select
                   
                Next

 

                appDX.SchematicSheetDocuments.Close()

 

            Next

 

        Next

 

    End Sub

Outcomes