5 Replies Latest reply on Oct 25, 2016 10:56 PM by Rhea Kelly

    Automate export of PDF for different configurations

    Rhea Kelly

      Hi guys,

       

      I'm fairly new to VBA/Macros but basically what I am looking for is the following -

       

      1. Scale views of assembly on drawing sheet 1
      2. 'Save as PDF' and named file as assembly configuration name
      3. Open/activate assembly
      4. Rebuild assembly
      5. Cycle to next assembly configuration
      6. Open/activate drawing
      7. Repeat steps 1 - 5 until end.

       

      Anyone can give me some instructions it would be greatly appreciated.

       

      Cheers,

      Rhea

        • Re: Automate export of PDF for different configurations
          Deepak Gupta

          When you say scale do you mean a fixed scale or based on sheet size?

          • Re: Automate export of PDF for different configurations
            Peter Brinkhuis

            Will you be providing the drawing first? Or does that have to be created as well?

             

            Do you need to open the assembly or could you change the configuration of all of the drawing views as well? Is it because the assembly configuration might be out of date? Then you might want to start by opening up all configs first.

            • Re: Automate export of PDF for different configurations
              Nilesh Patel

              Hi Rhea,

              If you have drawing document open with the drawing view of an assembly (only one view on the drawing sheet), then

               

              1. Get the first drawing view using IDrawingDoc.GetFirstView. First view will be "SHEET1" view. Use IView.GetNextView to get the actual assembly drawing view.

              2. Get the referenced model in the drawing view using IView.ReferencedDocument.

              3. Get configuration names of the assembly using IModelDoc2.GetConfigurationNames which return an array.

              4. Run a for loop for the array of configuration names.

                   4A. Change the configuration of the assembly in the drawing view using IView.ReferencedConfiguration.

                   4B. Rebuild the drawing document using IModelDoc2.EditReuild3. (This will only rebuilt the drawing document not assembly document)

                   4C. Save the PDF file using IModelDoc2.Extension.SaveAs (Need to specify the full path of the PDF file using configuration name including extension ".PDF" as string).

                          If you want to save the PDF file in the same location as drawing document then use IModelDoc2.GetPathName to get the full path of the drawing document and remove drawing document name to get the folder location.

              5. Save the drawing document using IModelDoc2.Save3.

               

              You need to make sure that all configurations in the assembly document are not out of date.

              Hope this helps.