Quantcast
Channel: Mentor Graphics Communities: Message List
Viewing all articles
Browse latest Browse all 4541

Re: Extracting Parts From a Schematic

$
0
0

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 AsBoolean

     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 asString

 

 

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

 

     PublicSub DX_Connect()

         dim errmsg asString

        

         dxd_running = false

         app = Nothing

         onerrorgoto dxd_error

         app = GetObject(,"ViewDraw.Application")

         doc = app.ActiveDocument

         dxd_running = True

         prj = app.GetProjectData

        

         ExitSub

        

         dxd_error:

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

        

     EndSub

 

 

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:

 

          ForEach 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

          ForEach 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.


Viewing all articles
Browse latest Browse all 4541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>