15 Replies Latest reply on May 12, 2016 4:37 PM by Alin Vargatu

    API call of Solidworks command

    Vlad Shevchenko

      Hi everyone!

       

      I want to write addin which will call SolidWorks DeFeature command and save it result in new file. Are there some methods which will allow me to work with DeFeature command via API? I able to run this command using ISldWorks.RunCommand but I also need to pass parameters in it and get some response. How I can do that?

       

      Have a nice day.

        • Re: API call of Solidworks command
          Alin Vargatu

          Just adding to what Vlad wrote, the important thing is to ensure that:

           

          1. Defeature does not eliminate any bit of geometry. All faces, all bodies should stay untouched.

          2. Each component should be set-up as a group, so its mates will be preserved.

           

          Vlad, if you need geometry to be simplified (like removing cavities, or replacing Parasolid geometry with tessellation data), a different tool needs to be used.

          • Re: API call of Solidworks command
            Deepak Gupta

            This won't be an easy exercise  to write this program. So are you looking to get a paid program made.

             

            However you still have to do some of the task manually so I would rather use the available functionalities rather than developing a new program for it.

              • Re: API call of Solidworks command
                Vlad Shevchenko

                I need to automate this existing process, make it in batch mode for whole assembly which was loaded in SolidWorks. That is why I'm looking for some possibility which will give me access to run SolidWorks DeFeature API programmatically. But as I understand there are no ways to do it.

                  • Re: API call of Solidworks command
                    Oleg Bezyaev

                    Defeature API does not exist. The best way - it does not pay as advised here , and take advantage of all the power of API SW. Result after defeature exactly the same as when saving in STEP. What should be done:

                    - Read the coordinates of all the parts in the assembly and subassemblies

                    -Save all parts as STEP

                    - Create an assembly and insert to the STEP model coordinates obtained previously.

                    That's all. It's easy, just be a lot of code.

                      • Re: API call of Solidworks command
                        Alin Vargatu

                        Oleg Bezyaev wrote:

                         

                        Defeature API does not exist. The best way - it does not pay as advised here , and take advantage of all the power of API SW. Result after defeature exactly the same as when saving in STEP. What should be done:

                        - Read the coordinates of all the parts in the assembly and subassemblies

                        -Save all parts as STEP

                        - Create an assembly and insert to the STEP model coordinates obtained previously.

                        That's all. It's easy, just be a lot of code.

                        But that would eliminate all the mates.

                         

                        If the mates would not be a problem, but the bodies need to be preserved I would:

                         

                        1. Save the assembly as a part using these settings (so I preserve the face IDs):

                         

                         

                        2. Save the bodies of the new part and use the Create assembly option.

                         

                        Result: an identical assembly, same positions, all components fixed.

                        • Re: API call of Solidworks command
                          Vlad Shevchenko

                          Good idea. IAssemblyDoc.AddMate4 has 14 parameters. Some of them I able to copy from Mate2 instance. But what about such parameters as DistanceAbsUpperLimit, DistanceAbsUpperLimit, GearRatioNumerator, Angle, AngleAbsUpperLimit, ForPositioningOnly...? Where I can find value of those properties?

                        • Re: API call of Solidworks command
                          Oleg Bezyaev

                          And again....after 2 minutes FAQ search))) SaveDeFeaturedFile

                          Theese examples are many. The main thing -  is search. This forum is full of such free macros or code examples.

                            • Re: API call of Solidworks command
                              Vlad Shevchenko

                              Oleg Bezyaev wrote:

                               

                              And again....after 2 minutes FAQ search))) SaveDeFeaturedFile

                              Theese examples are many. The main thing - is search. This forum is full of such free macros or code examples.

                               

                              Thank you for your time. I saw this method but it saves all assembly parts into one file, bodies which were mates exports like one big surface-body and this file won't keep information about mates.  I would like to keep those data.

                                • Re: API call of Solidworks command
                                  Alin Vargatu

                                  Vlad Shevchenko wrote:

                                   

                                  Oleg Bezyaev wrote:

                                   

                                  And again....after 2 minutes FAQ search))) SaveDeFeaturedFile

                                  Theese examples are many. The main thing - is search. This forum is full of such free macros or code examples.

                                   

                                  Thank you for your time. I saw this method but it saves all assembly parts into one file, bodies which were mates exports like one big surface-body and this file won't keep information about mates. I would like to keep those data.

                                  The main challenge with programing the Defeature tool is to ensure that each component is placed in a separate group, for preserving the mates.

                                   

                                  One thing Defeature run from the top level assembly will not preserve is the assembly/subassembly structure.

                                   

                                  Maybe we should also submit an ER to SW to ensure that a whole assembly can be saved as another assembly with just the dumb bodies and the mates.

                                   

                                  Is pretty much the functionality you get in lightweight mode. You just need to take away the option to resolve the components.

                          • Re: API call of Solidworks command
                            Christian Chu

                            Writing an add-in is not a simple job and much more complicated than a macro

                            if you don't have enough knowledge of programming , I think you need to pay someone to do this for you - Here is the one

                            • Re: API call of Solidworks command
                              Vlad Shevchenko

                              I found one more solution for simplifying assembly. I can export SW assembly to Parasolid format (*.x_t), then load it into SW and save as SW assembly again. As a result, information about assembly hierarchy will be preserved and all bodies will be converted like in Defeature tool. All bodies will be fixed in their original position, but, unfortunately, information about mates will be lost.

                              I'm still looking for way how I can copy this data to new assembly.

                              • Re: API call of Solidworks command
                                Alin Vargatu

                                Vlad Shevchenko wrote:

                                 

                                Hi everyone!

                                 

                                I want to write addin which will call SolidWorks DeFeature command and save it result in new file. Are there some methods which will allow me to work with DeFeature command via API? I able to run this command using ISldWorks.RunCommand but I also need to pass parameters in it and get some response. How I can do that?

                                 

                                Have a nice day.

                                 

                                At this time, Defeature is the only tool that would preserve mates.

                                 

                                This is the ER that I just submitted to SW:

                                 

                                 

                                Ability to use Defeature to create a new assembly with the same assembly structure, component geometry and mates, but no features

                                 

                                Protecting intellectual property is important. My customers would like to prevent their customers from opening assemblies fully resolved, but only in lightweight.

                                All the geometry, masses, materials and mates should be preserved. Only the features should be scrubbed from the feature tree.

                                Defeature can do most of this right now. We need this added functionality for Defeature:

                                1. Run Defeature in an assembly
                                2. Have an option to protect all faces, so none will disappear
                                3. Have an option to place each components in its own group (for mate preservation)
                                4. Have an option for preserving the assembly structure
                                5. Have an option for preserving material
                                6. Have an option for preserving custom properties.

                                 

                                Alternatively, this can be another SAVE AS option from inside the assembly. Like:

                                Save Assembly LightWeight, which will replace all features with one "stock" feature per part.

                                 

                                Once I receive an SPR, I will post it here, so you can vote on it. Such an enhancement will be revolutionary!!!

                                 

                                If any SW employee reads this, the ER is 1-10993066081