14 Replies Latest reply on Aug 20, 2010 6:03 AM by StuartB_EricssonTV

    API for editing DxDesigner symbols.

    avjohn

      It seems that the API we used in ePD2005 for modifying symbols is not available in EE2007.  I have two scripts, one cleans up symbols that we have created using SymXpert, the other creates a POP (part on part) symbol from a regular symbol.  A POP symbol looks like a regular symbol, the pin information is replaced with graphics and text.  These scripts no longer work in EE2007.  The new symbol editor is Tcl based but I haven't seen a way to have the editor call a Tcl script from within the tool to modify a symbol.

       

      What does Mentor propose that we use to modify DxDesigner symbols programmatically?

       

      Tony

        • 1. Re: API for editing DxDesigner symbols.
          olivier_arnaud

          Hi Tony,

           

          The new symbol editor introduced with EE2007 (a.k.a NSE) definitely provides a Tcl API and you can source any Tcl script from within the console window. The format of the symbols has not changed since ePD2005. The API functions are very likely to be different though so I suspect your script should indeed be adapted to the new editor. By the way we will publish very soon the latest version of the NSE API corresponding to the latest version of the tool.

          Meanwhile, you could probably send us the script you were using so that we can take a look and advise you how to modify it.

           

          Have a terrific day!

          Olivier

          • 2. Re: API for editing DxDesigner symbols.
            avjohn

            Oliver,

             

            That's good news.  However, in looking at the Tcl commands, I don't see a way to retrieve information about the symbol, (i.e. pin names, pin numbers, location, etc).  Is there a way to do this?

             

            I've also provided the code for the script.  This scripts creates what we call a POP (part on part) symbol from an existing symbol.  It has a part number and a REFDES but doesn't contain any pin information.  It first reads all of the pin information (pin name, pin number, inverted status, location) and then deletes the pins and replaces them with graphics and text.

             

            Regards,

             

            Tony

             

            Dim ObjSymBlk, ObjPin, AttrPinName, PinLabel, strPinName, AttrPinNumber, strPinNumber
            Dim PinBoundaryLocation, PinInteriorLocation, PinNameLocation, PinNumberLocation, PinLabelLocation
            Dim ObjText, PinNameSize, PinNumberSize, PinNameColor, PinNumberColor, PinColor
            Dim PinNameOrigin, PinNumberOrigin, ObjLine, AttrPin, Attr, PinInverted, PinSide, ObjCircle
            Dim midx, midy, centerx, centery

            'Const VDPIN_INTERIOR = 0
            'Const VDPIN_BOUNDARY = 1
            'Const VD_ALL = 0
            'Const VDM_PIN = 512
            'Const VDINVERTED = 1
            'Const VDNOTINVERTED = 0
            'Const VDTOP = 0
            'Const VDRIGHT = 3
            'Const VDLEFT = 2
            'Const VDBOTTOM = 1
            'Const VDINVISIBLE = 0
            Dim mydx
            'Set mydx = CreateObject("ViewDraw.Application")
            Set mydx = GetObject(, "ViewDraw.Application")

            Set ObjSymBlk = mydx.ActiveView.ActiveBlock
            '
            ' change the grid to .01
            '
            mydx.ExecuteCommand "gspace 1"
            '
            ' Add the CLASS=HRD attribute
            '
            Set Attr = ObjSymBlk.AddAttribute("CLASS=HRD", 0, 0, VDINVISIBLE)
            '
            ' Delete the DEVICE attribute
            '
            'Set Attr = ObjSymBlk.FindAttribute("DEVICE")
            'If Not Attr Is Nothing Then
            ' Attr.Delete
            'End If
            '
            ' Change each pin into a dummy pin
            ' We need to get the pin Name or Label, pin number
            '
            For Each ObjPin In mydx.ActiveView.Query(VDM_PIN, VD_ALL)
            PinInverted = False
            ' Pin Label
            NoPinLabel = False
            Set AttrPinName = ObjPin.FindAttribute("PIN NAME")
            If Not AttrPinName Is Nothing Then
              strPinName = AttrPinName.Value
              Set PinNameLocation = AttrPinName.GetLocation
              PinNameSize = AttrPinName.Size
              PinNameColor = AttrPinName.Color
              PinNameOrigin = AttrPinName.Origin
            Else
              NoPinLabel = true
            '  Set PinLabel = ObjPin.Label
            '  strPinName = PinLabel.TextString
            '  Set PinNameLocation = PinLabel.GetLocation
            '  PinNameSize = PinLabel.Size
            '  PinNameColor = PinLabel.Color
            '  PinNameOrigin = PinLabel.Origin
            End If
            ' Pin Number
            Set AttrPinNumber = ObjPin.FindAttribute("#")
            If Not AttrPinNumber Is Nothing Then
              strPinNumber = AttrPinNumber.Value
              Set PinNumberLocation = AttrPinNumber.GetLocation
              PinNumberSize = AttrPinNumber.Size
              PinNumberColor = AttrPinNumber.Color
              PinNumberOrigin = AttrPinNumber.Origin
            End If
            ' Pin line graphics
            If ObjPin.Sense = VDINVERTED Then
              PinInverted= True
              PinSide = ObjPin.Side 
            End if
            Set PinBoundaryLocation = ObjPin.GetLocation(VDPIN_BOUNDARY)
            Set PinInteriorLocation = ObjPin.GetLocation(VDPIN_INTERIOR)
            PinColor = ObjPin.Color
            '
            ' Delete the Pin
            '
            ObjSymBlk.DeSelectAll
            ObjPin.Selected = True
            ObjSymBlk.DeleteSelected(True)
            '
            ' Add the dummy Pin
            '
            ' Pin Line graphics
            If PinInverted = True Then
              If PinSide = VDLEFT Then
               midx = (PinBoundaryLocation.X + PinInteriorLocation.X - 10)/2
               midy = (PinBoundaryLocation.Y + PinInteriorLocation.Y)/2
               centerx = PinInteriorLocation.X - 5
               centery = PinInteriorLocation.Y
               Set ObjLine = ObjSymBlk.AddArc(PinBoundaryLocation.X, PinBoundaryLocation.Y, midx, midy, PinInteriorLocation.X - 10, PinInteriorLocation.Y)
               ObjLine.Color = PinColor
              ElseIf PinSide = VDRIGHT Then
               midx = (PinBoundaryLocation.X + PinInteriorLocation.X - 10)/2
               midy = (PinBoundaryLocation.Y + PinInteriorLocation.Y)/2
               centerx = PinInteriorLocation.X + 5
               centery = PinInteriorLocation.Y
               Set ObjLine = ObjSymBlk.AddArc(PinBoundaryLocation.X, PinBoundaryLocation.Y, midx, midy, PinInteriorLocation.X + 10, PinInteriorLocation.Y)
               ObjLine.Color = PinColor
              ElseIf PinSide = VDTOP Then
               midx = (PinBoundaryLocation.X + PinInteriorLocation.X)/2
               midy = (PinBoundaryLocation.Y + PinInteriorLocation.Y + 10)/2
               centerx = PinInteriorLocation.X
               centery = PinInteriorLocation.Y + 5
               Set ObjLine = ObjSymBlk.AddArc(PinBoundaryLocation.X, PinBoundaryLocation.Y, midx, midy, PinInteriorLocation.X, PinInteriorLocation.Y + 10)
               ObjLine.Color = PinColor
              ElseIf PinSide = VDBOTTOM Then
               midx = (PinBoundaryLocation.X + PinInteriorLocation.X)/2
               midy = (PinBoundaryLocation.Y + PinInteriorLocation.Y - 10)/2
               centerx = PinInteriorLocation.X
               centery = PinInteriorLocation.Y - 5
               Set ObjLine = ObjSymBlk.AddArc(PinBoundaryLocation.X, PinBoundaryLocation.Y, midx, midy, PinInteriorLocation.X, PinInteriorLocation.Y - 10)
               ObjLine.Color = PinColor
              End if   
              Set ObjCircle = ObjSymBlk.AddCircle(centerx, centery, 5)
              ObjCircle.Color = PinColor
            Else
              midx = (PinBoundaryLocation.X + PinInteriorLocation.X)/2
              midy = (PinBoundaryLocation.Y + PinInteriorLocation.Y)/2
              Set ObjLine = ObjSymBlk.AddArc(PinBoundaryLocation.X, PinBoundaryLocation.Y, midx, midy, PinInteriorLocation.X, PinInteriorLocation.Y)
              ObjLine.Color = PinColor
            End If
            ' Pin Label
            If NoPinLabel = False then
              Set ObjText = ObjSymBlk.AddText(strPinName, PinNameLocation.X, PinNameLocation.Y)
              ObjText.Size = PinNameSize
              ObjText.Color = PinNameColor
              ObjText.Origin = PinNameOrigin
            End If
            ' Pin Number
            Set ObjText = ObjSymBlk.AddText(strPinNumber, PinNumberLocation.X, PinNumberLocation.Y)
            ObjText.Size = PinNumberSize
            ObjText.Color = PinNumberColor
            ObjText.Origin = PinNumberOrigin
            ' Remove the Pin Order Attribute
            Set AttrPin = ObjSymBlk.FindAttribute("PINORDER")
            If Not AttrPin Is Nothing Then
              ObjSymBlk.DeSelectAll
              AttrPin.Selected = True
              ObjSymBlk.DeleteSelected(True)
            End If
            ' Remove the Pin Swap Attribute
            Set AttrPin = ObjSymBlk.FindAttribute("PINSWAP")
            If Not AttrPin Is Nothing Then
              ObjSymBlk.DeSelectAll
              AttrPin.Selected = True
              ObjSymBlk.DeleteSelected(True)
            End If
            Next
            '
            ' change the grid to .12
            '
            mydx.ExecuteCommand "gspace 12"
            MsgBox "Symbol converted to " & Chr(34) & "POP" & Chr(34) & "symbol."

            • 3. Re: API for editing DxDesigner symbols.
              olivier_arnaud

              Hi Tony,

               

              Thanks for providing me with the script. It is very useful as I originally thought that your script was in Tcl when it is in VBScript as I was expecting it from 2005.

              Obviously the Tcl source command in the console window will not help you much!

              I need to better understand what is your method to deal with these symbols to see how we could support a similar approach in the New Symbol Editor (NSE). So my understanding is that you expect to be able to import a symbol generated by SymXpert into NSE from where you could execute a script to reformat it to be compliant with the POP preferences. Am I right?

              What would help to assess if the latest version of the NSE API provides what is needed, would be to get a few examples of symbols generated by SymXpert as well as the "corrected" symbols. Do you think it would be possible?

              I'm looking forward to hearing from you again.

               

              Have a great day!

              Olivier

              • 4. Re: API for editing DxDesigner symbols.
                avjohn

                Oliver,

                 

                The script I put into this conversation to create the POP part is totally separate from the script that updates our symbols created from SymXpert.  The POP script gets the pin label, pin number, Invert status, color, and location of the each pin on the symbol.  It then deletes the pin and recreates it with text and graphics.  I think in the new Symbol Editor it would be possible to recreate the pin graphics and text, the problem I see is how do I get the pin information in the first place?  I didn't see any commands/methods to get the information or even go through each pin.  The data is on the symbol, there's just no way using the new Symbol editor to get at the data.

                 

                We never used the NSE in ePD2005.  We're on ePD2005.1 and it wasn't available for that release and since we use Zuken for our PCB layout tool, there was no need to go to ePD2005.3.

                 

                The script that updates the SymXpert symbols is a Visual Basic program.  From what I remember, the program opens up the symbol in DxDesigner, fixes the symbol boundary to meet our requirements, adds any needed attributes (HETERO is one) and saves the symbol.  The script may be easier to migrate to Tcl as all it does is add stuff to the symbol.  It's not looking for any information.

                 

                I also think if you can get the POP script working in EE2007 somehow, it shouldn't be that hard to migrate the SymXpert script.

                 

                Tony

                • 5. Re: API for editing DxDesigner symbols.
                  olivier_arnaud

                  Hi Tony,

                   

                  Understood. I just looked at the latest version of the NSE API which has been reworked for the next release of EE2007 and I believe you'll find in there everything you need. The command set has been extended and sorted by Namespace. You can find a few examples which you'll probably need below:

                  # symbol::getports

                  # port::getlabel
                  # port::getlength
                  # port::getname
                  # port::getposition
                  # port::getproperties
                  # port::getside
                  # port::gettype
                  # port::isinverted

                  A brand new documentation will be available in the next release. It should not be diffcult to adapt your script to Tcl and therefore to retrieve the same functionality as before.

                   

                  I hope it helps.

                  Cheers

                  Olivier

                  • 6. Re: API for editing DxDesigner symbols.
                    avjohn

                    Oliver,

                     

                    That's good news.  We'll wait for the next release of the NSE

                     

                    One more question, will we be able to call a tcl script from within the tool?  I can think of times where we will want to run multiple scripts on a symbol.

                     

                    Thanks,

                     

                    Tony

                    • 7. Re: API for editing DxDesigner symbols.
                      olivier_arnaud

                      Hi Tony,

                       

                      You'll be able to use a new feature called External tools which allows you adding software applications and/or external scripts, programs, or Tcl commands from a dedicated dialog box. These applications/scripts/commands become available from the NSE Tools menu dropdown and can be launched from there.

                       

                      It seems that you will find in this new version everything you need!

                       

                      Have a great day!

                      OLivier

                      • 8. Re: API for editing DxDesigner symbols.
                        avjohn

                        Oliver,

                         

                        Again, great news!!

                         

                        Thanks for all your help!!

                         

                        Tony

                        • 9. Re: API for editing DxDesigner symbols.
                          rinnert_hawkins

                          Hello Tony -

                          I am currently updating the Dx Symbol Editor documentation for the next EE2007 release to include information that Olivier noted in his previous post.

                          To find this document in the next EE release, go to InfoHub and look for the Dx Symbol Editor document.

                           

                          Best regards -

                          Rinnert Hawkins

                          Technical Writer

                          Mentor Graphics Corporation

                          Huntsville, Alabama, USA

                          • 10. Re: API for editing DxDesigner symbols.
                            avjohn

                            Rinnert,

                             

                            Thanks for the info.  Since I have to wait for the next version of the Symbol editor to access the new functionality, I'll wait until then to look at the documentation.  Besides, I'm not sure I'd be able to find it anyway because I don't have access to EE2007.9.

                             

                            Thanks,

                             

                            Tony

                            • 11. Re: API for editing DxDesigner symbols.
                              rinnert_hawkins

                              Hi Tony -

                              Understood.

                              Just wanted you to know (in advance) exactly where to find this information in the documentation when 2007.9 is released (in fact, I'm working the documentation update for this issue right now).

                               

                              Thanks -

                              Rinnert

                              • 12. Re: API for editing DxDesigner symbols.
                                artsiom.shchatsko

                                Again there is no 100% consistency at Mentor. They say Automation is a way to go - great, but it should be available for all tools (including NSE). I realize that different part for the tool-chain could be written by different teams but they all must be consistent.

                                • 13. Re: API for editing DxDesigner symbols.
                                  rinnert_hawkins

                                  Hi Tony -

                                  Dx Symbol Editor delivered in EE 7.9 now features automation scripting. The DxDesigner Symbol Editor documentation has been updated to include Appendix C, "TCL Commands in Dx Symbol Editor" and provides a full listing of Tcl/Tk scripts grouped by category. Please take a look and see if this is helpful. Any ideas for improvement are welcome.

                                   

                                  Best regards -

                                  Rinnert Hawkins

                                  Technical Writer, Mentor Graphics Corporation

                                  • 14. Re: API for editing DxDesigner symbols.
                                    StuartB_EricssonTV

                                    I'd go along with this - to get best use of automation it needs to be consistent.

                                     

                                    I've been writing some scripts to extract part information.

                                    This is mostly from the Part Editor so I've used VBScript/COM automation.

                                    ... but there are a couple of pin properties that I need from the symbol editor. For these I'd need to use TCL.

                                     

                                    I've raised an Idea

                                    (COM automation of symbol editor : https://mentorideas.brightidea.com/ct/ct_a_view_idea.bix?c=FDA2FA5D-237C-48D7-A66F-5DA754706D6C&idea_id=D6D264F9-0567-4F45-874D-B4B8A030FF70)

                                     

                                    Do you know if there is a way of launching Symbol Editor and sending TCL commands from within a VBScript?

                                    Can Mentor provide COM-like wrapper functions for all the TCL commands so the TCL Automation can be used transparently from VBScripts?