3 Replies Latest reply on Aug 29, 2017 8:43 AM by Patrick.Cashman

    Dxdatabook automation

    shainaor

      Hi,

       

      is it possible to place a component from DxDatabook using automation?

       

      Shai

        • 1. Re: Dxdatabook automation
          Patrick.Cashman

          Not in the way you are thinking about it, but yes.

           

          There is no automation function that does the same thing as DxDatabook, ie places a component symbol on the schematic sheet and 'instantiates' it in the same way that it happens when you drag the part from the DxDatabook symbol window into the schematic sheet. DxDatabook does have some scripting ability but it's fairly limited and has nothing like this level of functionality.

           

          What you can do is place the desired component symbol from the library, using the part number and symbol name information, plus a location you supply.  Then, you can add all the same properties to the component that you'd normally get by using DxDatabook in the normal way. Your automation code would add attributes to the symbol once it's already on the schematic sheet.

           

          There are a few things to think carefully about when doing this:

           

          - You need to be able to access your DxDatabook data source with your automation tools. This means that, completely independent of any connection to DxDatabook, you need to know where the database is, what kind of database it is, and have the appropriate connection string and connection object in your script or application. The good news is that there is tons of information on the internet about how to do this.  For example if you are using vbscript and a MS Access database, you can do a search for "read MS access database with vbscript" and you will find many examples of the code and methods used to do this. 

          - Once you have the connection to your database in place, you need to use SQL statements to query the database.  Again, there is a lot of information about how to construct SQL all over the web, so it's not hard to find.

          - Finally, you need to be aware of the rules in place in your DxDatabook Configuration (.dbc) file.  You can't just read all the properties from the database table and add them to the component.  The dbc file specifies what properties are applied to the components, whether they are annotated to the PCB, some information about the datatype of the properties, and so on.  You will need to follow the same set of rules for adding the properties as are used in the dbc, or your resulting components will have the properties applied differently than parts added using DxDatabook in the normal way.

           

          Once you are set with all that, there are two key functions you will use to put the parts on the sheet and add properties to them:

           

          Block.AddPartInstance

          Component.AddAttribute

          • 2. Re: Dxdatabook automation
            shainaor

            Hi Patrick,

             

            Many thanks for your answer !

             

            Before dealing with the ODBC I want to see if I can write a C# program that places a component.

            Then I want to see which fields I need to import from the ODBC.

            In the below jpg, the lef side is the component from the DxDatabook.

            Could it be that the only field I need to import is the Description?

             

            Shai

            • 3. Re: Dxdatabook automation
              Patrick.Cashman

              You're most welcome.

               

              You need to carefully check out your DxDatabook configuration to see what properties you need to import. I strongly suspect there are more properties you will need to add.

               

              I've attached a routine I've used to replace parts on the schematic.  It may be helpful to you when doing your code.  There are some things in it that are created externally so you'll have to skip over that, but hopefully it will give you some ideas.