10 Replies Latest reply on Apr 7, 2014 12:04 AM by Artem Taturevych

    Link/Export Cut List Property to Custom Property

    Jeffrey Tongco

      Hi Guys,

       

      I need help regarding properties of parts.

      I created a weldment in a part document with contains cut list properties right?

      I insert this part to an assembly with the other related parts.

      Then I input the custom properties of each parts

      What I need is the cut list property of the weldment part.

       

      The idea is to export the cut list property (description and length) to be shown in the custom properties of parts.

       

      Hope to hear your ideas.

       

       

      Cheers

        • Re: Link/Export Cut List Property to Custom Property
          Seth Ruhan

          Hi Jeffrey,

           

          What you want to do, ie Cut-list properties -> Custom Properties is not technically difficult to do. (And happy to share the code with you)

           

          The issue come is to play with implementation, The difficult method to do is updating the propertiesz. You could do it 3 ways,

          On macro run.

          An Addin with a rebuild event

          or a Macro Feature.

           

          A Macro feature would be the only method that would work for all users (internal/External).

          This is where I failed implementing the .Net Macro feature

           

          Hope this helps

            • Re: Link/Export Cut List Property to Custom Property
              Jeffrey Tongco

              Hey Seth

               

              I think a macro will do the thing but I dont know how to do one.

              If you have I appreaciate it.

               

              Cheers

                • Re: Link/Export Cut List Property to Custom Property
                  Seth Ruhan

                  Jeffrey,

                   

                  As I mentioned above. The code is incomplete. It fails to implement a Macro feature to keep the properties upto date.

                  However the macro can be run by the user manully as an update.

                   

                  If any one know why my macro featue is failing, please let me know.

                   

                  .Dll is attached  (macro) , as is source code.

                    • Re: Link/Export Cut List Property to Custom Property
                      Artem Taturevych

                      Hi Seth,

                       

                      Thanks for sharing the dlls and the source. I think such a macro can be very beneficial for a lot of users. I have noted two things which causing your macro feature to fail:

                       

                      1) The module macro feature approach where you specify the callback functions as the 'MacroMethods' parameters of InsertMacroFeature3 is only applicable for VBA based macro features. If you are using .NET or c++ you have to use COM-Based macro feature. You need to implement the ISwComFeature interface which is going to be the definition of your macro feature (the logic inside the implementation is the same as in module based approach).

                       

                      2) I'm not sure you can insert the macro feature from VSTA macro. I would recommend to download free Visual Studio Express Edition and create an add-in for this.

                       

                      Please let me know if you have any questions. I'm happy to provide some examples for you if needed.

                      ______________________________________________

                      Regards, Artem Taturevych | Snr. Developer | IC3D ANZ

                       

                      IC3DSteel – New Steel Solution for SolidWorks

                      translationXpert – SolidWorks files language translator

                      LinkedIn - SolidWorks API Group

                        • Re: Link/Export Cut List Property to Custom Property
                          Seth Ruhan

                          Hey Artem,

                           

                          Thats for the suggestions, I knew I was implementing wrong, But unsure how.

                          I have implemented IswComFeature. However I am still calling some thing wrong.

                           

                          I do have an addin for it. However for testing purposes VSTA is alot easier for test methods.

                           

                          Attached is the revised code, If you have a chance, Please let me know what I'm still doing wrong.

                            • Re: Link/Export Cut List Property to Custom Property
                              Artem Taturevych

                              Hi Seth,

                               

                              1) I would add the following COM attributes to your feature class to ensure it is COM visible and to matches the progId:

                               

                              <ComVisible(True)> _

                              <ProgId("CutListPropExport.MacroFeature")> _

                              Public Class MacroFeature

                                  Implements ISwComFeature

                              ...

                              2) Then you need to register your dll for COM:

                               

                              "C:\Windows\Microsoft.NET\Framework64\v2.0.50727\RegAsm.exe" <Path>\MacroFeature.dll" /codebase /tlb

                               

                              3) After you can insert your macro feature.

                               

                              I have changed main functions to shared methods:

                               

                                  Public Shared Sub CreateNewMacroFeature(ByRef swApp As SldWorks)

                              ...

                                  Public Shared Function LinkFeatureExists(ByRef swApp As SldWorks) As Boolean

                              ...

                              to be able to create a macro feature outside of definition without the need to create an instance of the class:

                               

                              ...

                                  MacroFeature.CreateNewMacroFeature(swApp)

                              ...

                              I managed to insert it from VSTA but it doesn't return to callbacks. I still think you can only do this within an add-in.

                              ______________________________________________

                              Regards, Artem Taturevych | Snr. Developer | IC3D ANZ

                               

                              IC3DSteel – New Steel Solution for SolidWorks

                              translationXpert – SolidWorks files language translator

                              LinkedIn - SolidWorks API Group

                                • Re: Link/Export Cut List Property to Custom Property
                                  Seth Ruhan

                                  Thanks a lot Artem for your help, Its now working as intended.

                                   

                                  I've now noticed an error in the logic. The macro only works on feature rebuilds, Ie change a dimension, not on a rebuild or Forced Rebuild. Which can cause properties to be come out of sync if the user changes the property is only updates when you change some thing on the model.

                                   

                                  I was hoping a rebuild happened on document open so I could create rebuild event.

                                   

                                  Any other idea's other than a limitation?

                                   

                                  Thanks again!

                                  • Re: Link/Export Cut List Property to Custom Property
                                    Seth Ruhan

                                    I've just been testing on another computer, On the rebuild it errors cause it could not find a file.

                                    Have I miss understood the use of a macro feature? I thought that the reason you ebeded it into the feature tree etc was so that the Model could be given to other people and still work? ie the features rebuilt.

                                      • Re: Link/Export Cut List Property to Custom Property
                                        Artem Taturevych

                                        The biggest difference between the VBA based macro feature and the COM based is that COM based requires the COM server to be registered on every target machine while the VBA code can be embedded directly to the model. So in your case you have to register your DLL with RegAsm on every target machine which will be using your macro feature.

                                         

                                        Answering your previous questions. You may add the parent-child relations between your macro feature and any other features so it is rebuilding when the child feature is rebuilt. Another workaround is to subscribe to Rebuild event and do the work from the handler. You can subscribe to this event within the swmSecurity handler which is invoked quite frequently.

                                        ______________________________________________

                                        Regards, Artem Taturevych | Snr. Developer | IC3D ANZ

                                         

                                        IC3DSteel – New Steel Solution for SolidWorks

                                        translationXpert – SolidWorks files language translator

                                        LinkedIn - SolidWorks API Group

                                • Re: Link/Export Cut List Property to Custom Property
                                  Jeffrey Tongco

                                  Hi Seth

                                   

                                  Sorry I am not familiar with this.

                                  Can you please instruct how to use this program?

                                   

                                  Thanks

                                   

                                  Cheers