4 Replies Latest reply on May 6, 2015 6:38 AM by peter_festesen

    Extracting Parts From a Schematic

    oallaire

      Hi, I would like to write a script to extract all parts of schematic (RefDes, Part Name, etc.) and also the Nets connected to this part? Any pointers on how to do this?

       

      I have read the threads in this space and it is very difficult to find tutorials and help. Links that are hosted by mentor graphics seem to be depricated (page not found and such). The examples in the help of DxDatabook are not helping me with what I'm looking to achieve.

       

      Finally, I downloaded AATK sources, but couldn't find what I need in there. Maybe I missed something because I am looking at the scripts with Notepad++ because I failed to find a way to edit scripts using DxDesigner. Open only seems to let you run an efm, not edit it.

       

      Thanks in advance for helping me!

        • 1. Re: Extracting Parts From a Schematic
          john_dube

          Looks like you want a netlist, look at the File -> Export menu and see if one of the included netlist formats is acceptable.

           

          If none of these is a close match, take a look at How to visit each schematic sheet in DxDesigner 2007.x for the basics on how to visit each sheet, then for every component with a refdes, walk the collection of connections, and get the net name. 

           

          To edit a script form, click the Stop button to go into Edit mode, then click the Script button to toggle between dialog editing and script editing modes.

           

          John

          • 2. Re: Extracting Parts From a Schematic
            Patrick.Cashman

            I have some examples of doing the things you ask.  Note - I do all of this using external executables created in vb.net using the SharpDevelop IDE.  You can also use the Visual Studio express IDE if you want - it's all 100% compatible. Both are free.  I use this method because of the greatly increased functionality available with vb.net.  It has many features not available in the vbscript world or even in the forms-based EFM stuff, like how the AATK is done.

             

            If you use the vb.net system, you will need to add ViewDraw as a reference in your project.

             

             

            Then, you need to declare some Public variables to access the ViewDraw application and some of it's features:

             

                 Public app as ViewDraw.Application

                 Public dxd_running As Boolean

                 Public prj As ViewDraw.IProjectData

                 public view as ViewDraw.View

                 Public scomp As ViewDraw.Component

                 Public scomps

                 Public schms As ViewDraw.IStringList

                 Public sheets As ViewDraw.IStringList

                 Public design_name as String

             

             

            Second, you need to connect to DxDesigner.  That can be done with a subroutine like this one:

             

                 Public Sub DX_Connect()

                     dim errmsg as String

                    

                     dxd_running = false

                     app = Nothing

                     on error goto dxd_error

                     app = GetObject(,"ViewDraw.Application")

                     doc = app.ActiveDocument

                     dxd_running = True

                     prj = app.GetProjectData

                    

                     Exit Sub

                    

                     dxd_error:

                     msgbox("Error: No active DxDesigner Application found.")

                    

                 End Sub

             

             

            You can call this sub from anywhere, such as with the action code of a button press, or in the form's load subroutine.  Once this has been accomplished successfully, the app, view, and prj variables can be used anywhere else with all of the included functionality they provide.

             

             

            Now, in some other subroutine, you need to get a reference to all the components in the design.  To do that, you need something like this:

             

                  scomps = Nothing

                     'load all components into scomps.  scomps will get a reference to every component in the design

                     design_name = app.GetProjectData.GetiCDBDesignRootBlock(app.GetActiveDesign())

                     scomps = app.DesignComponents("", design_name, "-1", , False)    'gets all the components in the design

             

            You'll notice in the declaration for scomps, there is no datatype.  This is on purpose.  It is just a generic collection object.  Pretty much all you can do with it is iterate through it with a loop like this:

             

                      For Each scomp In scomps

             

                     Next

             

            And then do something with each scomp in the loop. For example, if you wanted the value of any attribute (property) of the component, you would do this:

             

            Dim attr As ViewDraw.Attribute

            Dim pn as string

            attr = scomp.findattribute("Part Number")

            pn = attr.value

             

             

            If you wanted to get the pin connections of the part, you would do this, and get pin number and net name.

             

                      Dim con As ViewDraw.Connection

                     Dim cons

                     Dim comp_pin As ViewDraw.ComponentPin

                      Dim pin_no as string

                      Dim net_name as string

             

                     cons = scomp.GetConnections

                      For Each con In cons

                           comp_pin = con.CompPin

                           pin_no = comp_pin.Number

             

                           net_name =  con.Net.LogicalNetName

                      Next

             

             

            There is a lot more information available for some of these objects, and many more things you can do with them.  This is just a start. 

             

            Hope this helps.

            1 of 1 people found this helpful
            • 3. Re: Extracting Parts From a Schematic
              oallaire

              Thanks a lot! I am sure this will help me greatly! As soon as get something working, I will give some feedback! I am trying to write some code to partially automate a derating analysis. Since it's not a priority, progress is slow. But I will post back on this for sure!

              • 4. Re: Extracting Parts From a Schematic
                peter_festesen

                Hello

                 

                I decided to give it a test run, because the lack of debugging facilities in the xDxDesigner form editor. I also wanted to see how easy it was to write this in Visual Studio 2010 Express (that's what I had installed).

                 

                So, based on the excellent input from Pat, I have put together a basic template project fro VB Studio 2010 Express. I always get a little annoued with the multitude of files that are generated, but for now i simply zipped the entire VBS2010E package.

                 

                Enjoy !!

                 

                /Peter