3 Replies Latest reply on Aug 26, 2017 8:44 PM by Nilesh Patel

    Macro code for already existing assemblies

    Naga Ranjith Kumar Addagalla

      Hi all,

       

      My question is very very very simple.

       

      Is there any way to get(retrieve) the macro code without recording the parts and assembly creation?  I mean that I didn't recorded any single part to create macro till date but after completion of entire top level assembly, I thought if I have macro code I can able to modify parts or sub-assemblies easily.

       

      I don't know how to do.  Please share your ideas, if possible.

       

      Thanks and Regards

      Naga Ranjithkumar A

        • Re: Macro code for already existing assemblies
          Nilesh Patel

          Hi,

          1. Yes, you will have to start writing the macro from scratch.

          2. What do you mean by modify parts and sub-assemblies easily? What is your end goal?

            • Re: Macro code for already existing assemblies
              Naga Ranjith Kumar Addagalla

              Hi Nilesh,

               

              I am working a company, we have several parts, sub-assemblies and top levels that have been created already.  But now, I have a work in which 03 parts have different attributes(those are customized).  And now I have to change those parts in the top level and create a new top level.  In this way, I have to create 50 sub-assemblies.

               

              As they are top level, to change those parts taking long time.  So, I thought to change them easily by using the code if it is available.  And also if the similar cases prevails in future if we have access to coding either in c#/VB it might be helpful to complete the work faster.  So, if there is any possibility please provide some solution.

               

              Thanks

              Naga Ranjithkumar A

                • Re: Macro code for already existing assemblies
                  Nilesh Patel

                  Hi,

                   

                  If I have understood you correctly, you are planning to replace 3 off old components in the final assembly with 3 off new components and save the new final assembly as different name. If it is the case, have a look at the following example from API help: 2017 SOLIDWORKS API Help - Replace Component Example (VBA) .

                   

                  You will have to modify the code to suit your needs. You will still have to open each assembly and select the components you need replace and run a loop to replace them. Another difficult approach would be to create an Add-in or a stand alone application using Document Manager Licence Key, in this case you can specify path of all final assemblies, parts that need to be replaced and new parts.

                   

                  You may not find readily available codes. If you know about VBA, VB.Net or C#, start your codes and if you stuck somewhere just ask the question and someone will guide you to right path.

                   

                  Let us know how you go.

                   

                  Regards,