7 Replies Latest reply on Jul 27, 2018 8:18 PM by Nilesh Patel

    API - Changing reference configurations in a drawing

    Trevor Burch

      Hi,

       

      I am currently using a part with 200 configurations each possessing a flat. I need to create a drawing for each configuration, with the flat pattern and 2 other views (that aren't the flat pattern) that reference the same configuration as the flat pattern. I attached a picture to help explain.

      Flat Example.png

       

       

      I tried to use the first macro, "CreateDrawingsForAllConfs", I found in the forums, but it makes all three views only flats or only the part. The other macro "CreateDrawingsForAllFlatPatterns" also only creates flat drawings. While they both appear to be well made, I do not know enough about coding in this language to adapt them to my problem. Any assistance with this situation will be greatly appreciated.

        • Re: API - Changing reference configurations in a drawing
          Nilesh Patel

          Hi Trevor,

           

          Have a look at the following macro. I have been using this macro for over a year and works fine. You will need to create first drawing and save the drawing as reference configuration name of the model referenced in the drawing view. Macro will create drawings for remaining configuration. It works for both part and assembly document. If you have a BOM table (top level) in the drawing, it updates the BOM and re-references the configuration. If the drawing for any configuration already exist, macro will skip that drawing. It saves all new drawings into the same location as original drawing.

           

          It does not change the view scale. You will have to change it manually.

           

          Hope this helps.

           

          Regards,

          Nilesh

            • Re: API - Changing reference configurations in a drawing
              Trevor Burch

              Nilesh,

               

              Thank you for sharing the macro. Unfortunately it does not change the reference to the three drawing views I have in my drawing correctly. All three views come from the same model, with two of the views from the same config, while the other view is a flat pattern of that config. I think it is due to the change in character lengths, but I have not figured out how to adjust the code to fix that possible issue.

              108-10.png

               

              Appreciate any input,

              Trevor

                • Re: API - Changing reference configurations in a drawing
                  Nilesh Patel

                  Could you attached your part and drawing using pack and go?

                    • Re: API - Changing reference configurations in a drawing
                      Trevor Burch

                      This is not the original part or drawing because they were made at my work place. These files still possess the same concept/problem I've ran into when attempting to use the macro.

                        • Re: API - Changing reference configurations in a drawing
                          Nilesh Patel

                          Hi Trevor,

                           

                          I tested the macro on your drawing and worked fine.

                           

                          You will need to save the first drawing as one of the configuration name and all drawing views must have referenced configuration to match this configuration name. I saved your drawing as "Default" and change all configuration to match this configuration e.g. flat pattern view as 'DefaultSM-FLAT-PATTERN' and other two views as 'Default'. Then I ran the macro and it created 3 drawings called '32-6 With Guard', '32-6 With Guard' and '180-10 With Guard' and all tree views' referenced configuration are also changed accordingly.

                           

                          This is how the macro works:

                           

                          1. Create a first drawing and save as one of the configuration name. All drawing view must refer to this configuration.

                          2. Macro will save the drawing for each remaining configuration and change all views' configuration to match the configuration.

                          3. If the drawing for any configuration already exist, it will skip that configuration.

                           

                          Hope this is clear now.

                           

                          Regards,

                          Nilesh

                            • Re: API - Changing reference configurations in a drawing
                              Trevor Burch

                              Nilesh,

                               

                              It worked perfectly! I followed your instructions, and instead of starting with '108-10 With Guard' I created another configuration named 'Default' (that I plan to delete), and used that as the template.

                               

                              For future readers, I think the macro was having a difficult time with using the numbers or dashes as a template. If this program isn't working for you try to create an additional configuration in your part file named something like, 'Default' or 'Simple', and hopefully that will fix the problem you run into.

                               

                              Thanks again Nilesh!

                              -Trevor

                                • Re: API - Changing reference configurations in a drawing
                                  Nilesh Patel

                                  You don't need to create extra configuration. You can user one of the existing configurations. You just need to make sure that the drawing is saved with the name of this configuration and all views in the drawing refer to this configuration.

                                   

                                  In your case, you can create first drawing as '108-10 With Guard' and change reference configuration of all views to refer '108-10 With Guard' configuration in part. Then run the macro and it will create another two drawings '180-2 With Guard' and '32-6 With Guard'.

                                   

                                  As I mentioned earlier, macro also works for assemblies in the same manner.