13 Replies Latest reply on Nov 11, 2013 8:08 AM by afaulstich

    Using VB script to export IDF and DXF formats

    victor.ting

      Hello,

       

      I am trying to automate the generation of certain files and would like to know how to export DXF and IDF files from a script.

       

      In the PADS Layout Automation Server Reference, there is the description of Document.ExportASCII which is great for exporting ASCII files but I cannot find a similar method for exporting in other formats.

       

      Could someone point me to the correct Object and Method for exporting DXF and IDF files?

       

      Every time I try to get support from Mentor, my questions always get routed to the reseller and they have NO idea about the products they sell.

       

      Thanks,

      Vic.

        • 1. Re: Using VB script to export IDF and DXF formats
          yu.yanfeng

          Try to record a macro file for the operation for file-Export DXF, then use  Application.RunMacro (dxfout.mcr).

          Yanfeng

          • 2. Re: Using VB script to export IDF and DXF formats
            victor.ting

            Hi, thanks for your suggestion.

             

            My problem with macros is that I cannot specify the target directory for the output files.  I have a macro already that calls Appllication.ExportDocument("file.asc") but I have not found a way to dynamically change "file.asc" so I end up having one macro for each project.

             

            I have already contacted support but they said it was not possible to use variables in macros.

             

            Do you think this can be done in another way?

             

            Vic.

            • 3. Re: Using VB script to export IDF and DXF formats
              yu.yanfeng

              It's easy to implement your requirement of specifying a path for output file during script's executing.

               

               

              Yanfeng

              • 4. Re: Using VB script to export IDF and DXF formats
                victor.ting

                Using a _script_, I agree it's possible but it's NOT possible using a macro.  That is why I need to find the correct command to export the IDF format via a SCRIPT.

                 

                Do you know what is the correct SCRIPT command?

                 

                Vic.

                • 5. Re: Using VB script to export IDF and DXF formats
                  yu.yanfeng

                  Hi Victor,

                   

                  In your automation script, you can use  Application.RunMacro (%macrofileforIDForDXF%) method to output IDF or DXF file.

                  Because you hope to this script supports to specify where(path) the output file should be during executing, so you have to let

                  your script to first create the macro file on the fly after get user's input,then call  Application.RunMacro method.

                   

                  BTW, who is your reseller?

                   

                  Yanfeng

                  • 6. Re: Using VB script to export IDF and DXF formats
                    victor.ting

                    Wow, that's a pretty round-about way of doing something that seems really quite simple, but if it's the only way, I'll give it a try.

                     

                    My reseller is CADInformatique and I've contacted them on several occasions for support on different topics and they don't seem to know (or care) about the product but they're the only supplier here in France I think.

                     

                    Vic.

                    • 7. Re: Using VB script to export IDF and DXF formats
                      a.sassano

                      Hello,

                       

                      use dynamic Macros, you need no file on the disk. You can modify everything you need.

                       

                      Build a command String with your Folder Data and then run the Macro using Runmacro.

                      The First Parameter must be defined by an empty string "".

                      The second Parameter contains the Data String for the commands.

                       

                      -Sample1-------------------

                      sCommand = "Msgbox ""Test"""

                      Application.Runmacro "",sCommand

                       

                      -Sample2-------------------

                      sCommand  = "Application.ExportDocument(""C:\PADS Projects\Samples\preview.dxf"")"

                      Application.Runmacro "",sCommand

                       

                      sCommand = "DXFExportDlg.Ok.Click()"

                      Application.Runmacro "",sCommand

                       

                      -Sample3-------------------

                      sCommand = "Application.ExportDocument(""C:\PADS Projects\Samples\preview.dxf"")" & vbLfcr

                      sCommand = sCommand + "DXFExportDlg.Ok.Click()"

                       

                      Application.Runmacro "",sCommand

                      --------------------

                       

                      Maybe it can help.

                      Best Regards

                      Angelo

                      • 8. Re: Using VB script to export IDF and DXF formats
                        victor.ting

                        Thanks for the tip.

                         

                        I did test Yanfeng's method by writing a temporary macro file to disk and it's functional.  I'll try the dynamic macro method you describe as I think it should be a simple modification.

                         

                        Still, I'm pretty amazed that there is no 'direct' method of doing an export in a specific format.

                         

                        Thanks again to both of you for all your help.  You're much more knowledgeable than my stupid reseller.

                         

                        Vic.

                        • 9. Re: Using VB script to export IDF and DXF formats
                          ponkarthikeyan

                          Victor It will will great help for me if you give me the .bas file for exporting IDF from pads. Currently I am not having that export option in my Pads.

                           

                          Thanks in Advance

                          Karthikeyan

                          • 10. Re: Using VB script to export IDF and DXF formats
                            victor.ting

                            Sorry, I didn't write the IDF export script and don't have the source.  I only wrote a script that creates a macro that calls the 'Export' command.

                             

                            What version of PADS are you running?  Are you sure IDF isn't supported?

                             

                            If you select from the menu:

                             

                                 File->Export

                             

                            then in the 'Save as type:' pulldown, is IDF there or not?

                             

                            Vic.

                            • 11. Re: Using VB script to export IDF and DXF formats
                              afaulstich

                              a.sassano wrote:

                               

                              Hello,

                               

                              use dynamic Macros, you need no file on the disk. You can modify everything you need.

                               

                              Build a command String with your Folder Data and then run the Macro using Runmacro.

                              The First Parameter must be defined by an empty string "".

                              The second Parameter contains the Data String for the commands.

                               

                              -Sample1-------------------

                              sCommand = "Msgbox ""Test"""

                              Application.Runmacro "",sCommand

                               

                              -Sample2-------------------

                              sCommand  = "Application.ExportDocument(""C:\PADS Projects\Samples\preview.dxf"")"

                              Application.Runmacro "",sCommand

                               

                              sCommand = "DXFExportDlg.Ok.Click()"

                              Application.Runmacro "",sCommand

                               

                              -Sample3-------------------

                              sCommand = "Application.ExportDocument(""C:\PADS Projects\Samples\preview.dxf"")" & vbLfcr

                              sCommand = sCommand + "DXFExportDlg.Ok.Click()"

                               

                              Application.Runmacro "",sCommand

                              --------------------

                               

                              Maybe it can help.

                              Best Regards

                              Angelo

                              Hi Angelo,

                               

                              I have been trying to use this approach, but PADS is acting like it is not possible. Your Sample 2 and Sample 3 code does not work on my system (PADS 9.5). Once the ExportDocument dialog box appears, all script execution halts. It does not continue until the dialog box is closed manually. As an example, if I run this code:

                               

                              sCommand  = "Application.ExportDocument(""C:\PADS Projects\Samples\preview.dxf"")"

                              Application.Runmacro "",sCommand

                              MsgBox "The script is running"

                              sCommand = "DXFExportDlg.Ok.Click()"

                              Application.Runmacro "",sCommand

                               

                              ...the message box never appears until after I have personally closed the export dialog.

                               

                              Am I missing something? Do your examples require other code before or after them in order to work? Thanks.

                              • 12. Re: Using VB script to export IDF and DXF formats
                                a.sassano

                                >>Am I missing something? Do your examples require other code before or after them in order to work? Thanks.

                                No.

                                 

                                I tested it again. But it works. If I call this SAX Basic script I get the output.

                                 

                                -Sample3----------------------

                                    sCommand = ""

                                    sCommand = sCommand & "Application.ExportDocument(""C:\Users\Angelo\Desktop\preview.dxf"")" & vbCrLf

                                    sCommand = sCommand & "DXFExportDlg.Ok.Click()" & vbCrLf

                                 

                                    Application.RunMacro "",sCommand

                                 

                                    MsgBox "Finished"

                                -----------------------

                                 

                                !! The script will stop if the path does not exists. (C:\Users\Angelo\Desktop\preview.dxf)

                                 

                                Sample 2 will not work because the Dialog will stay modal.

                                 

                                I hope this helps.

                                • 13. Re: Using VB script to export IDF and DXF formats
                                  afaulstich

                                  Thank you. Your updated Sample3 code works for me.