5 Replies Latest reply on Jun 8, 2011 10:35 PM by kendall_hiles

    PutTrace from within Excel


      I get Automation Error messages when executing lines such as the following:


      set oTrace = pcbDoc.putTrace(LYR, ETC)


      Does anyone have an example of how to place traces in Expedition from within Excel VBA?  Does it have anything to do with Scripting.AddTypeLibrary?  That line doesn't play nice with Excel from what I have seen.





        • 1. Re: PutTrace from within Excel



          You don't need Scripting.AddTypeLibrary, that is only for Mentor applications to load the enumerated types for other COM servers.


          VBA has a Tools -> References menu that loads the type library information.


          Use TransactionStart with the appropriate DRC mode before calling PutTrace, then call TransactionEnd afterwards.


          Let us know what error messages you are getting, that will determine what else needs to be done.



          • 2. Re: PutTrace from within Excel

            Hi John,


            The error message displayed from Excel said "Automation Error" with a number that I did not record.


            I went down the path of thinking that this operation could only be executed from within the PCB itself.  Once I ported the code from my spreadsheet into the .vbs file, the error messages were more descriptive.  There were two errors:


            1. Invalid pointsArray

            2. DRC errors due to (I presume) extending a trace beyond the route border.  Adding an offset from the origin fixed this for now.


            I was unable to get working code with the transactionStart/End methods.  However, I am using pcbApp.lockserver...  It seems to exit the subroutine prior to committing the change for individual changes.  Do you recommend one vs. the other?  Maybe both?


            I drew heavily on the SPIRAL code published by ???.  I don't know what the legalities are of re-publishing the code in the forum without giving proper credit.  Did you create that script?


            If it's not an issue I can send you my spreadsheet.





            • 3. Re: PutTrace from within Excel



              You will find better performance running a script within Expedition instead of through Excel (a separate process), but debugging might be a little easier in VBA.


              I recommend that you use TransactionStart/TransactionEnd. 


              I didn't write spiral.vbs, I think that was done by an apps engineer.  I would say that unless someone has put some restrictive copyright notice in the code, you are free to publish a derived work, especially here on the forum where sharing is encouraged.  Now if you tried to sell it, that's another story...



              • 4. Re: PutTrace from within Excel

                Hi John,


                I like using VBA because it has the object browser.  I've not found a better IDE to expose the data model for the referenced COMs.  Also - when I pass these around the excel interface is familiar to the non-developer useres...  In this case It also does a better job at creating the spiral with the transformation.  I created the code in .vbs after my original script was failing and it took a noticeably longer amount of time to generate the pointsArray.  The Excel also has charting which gives you a warm fuzzy that the copper you are about to put has the characteristics that you intended.


                I attached it if you are interested.  Don't laugh at the hackiness of it! It's not smart enough to figure out an offset that prevents a DRC error.  If you try to route over the router border then you will get a memory violation error from within excel... The XOFFSET field creates oval spirals.  I wanted to post process the data to create paralell horizontal lines but settled for this for now.


                Thanks to whoever wrote the original SPIRAL.vbs demo code.  I drew heavily from that source.




                • 5. Re: PutTrace from within Excel

                  That's pretty cool, I wrote something like this for a 3-Axis CNC machine.  Too bad Expedition doesn't support bezier curves! I made multiple passes with the cutter head and drop the head (Z-Axis) a little as you go:^)  I was looking into the 4th axis to control the angle of the head but it is way easier to breakdown and buy some good software to keep from hitting the work when you angled the cutter head.


                  Do you want to add this to AATK?






                  Kendall Hiles CID
                  Sr. Global Applications Engineer Consultant

                  Mentor Graphics Corporation

                  North Carolina  USA

                  Cell +1-919-345-9807

                      Challenging myself through innovation, integrity and resolve to bring success to MGC customers.

                      Ask other users questions here:  Communities

                      Vote on Enhancements here:  Bright Ideas