3 Replies Latest reply on Dec 29, 2015 1:40 PM by Jordan Wigley

    Telling if a part is in an assembly

    Jordan Wigley

      I have created a c# add in that adds properties to the custom and configuration specific properties for parts and assemblies. The point of this is to make sure that older documents as well as new all have the correct properties. The add in does this automatically by being called by the events FileNewNotify2 and FileOpenPostNotify. It is working as intended for parts, but not for assemblies. When an assembly is open, it also opens every part in the assembly causing the FileOpenPostNotify event to be fired. If my assembly has 100 parts in it, then my add in is being called 100 times for each part, when i only need it to be called for the assembly only.  I thought about traversing the FeatureManager tree to tell if it is an assembly, but from what i understand, when the part is opened, the part becomes the Active Doc, meaning the feature tree will show the part tree and not the Assembly tree.

       

      My question is, is there a way for me to filter out the FileOpenPostNotify events for the parts in the assembly? Or, when the part is opened and it fires the event, can i tell that that part is in the assembly such as with a property, method, or feature tree, and therefore ignore the event call? Any advice would be greatly appreciated.

        • Re: Telling if a part is in an assembly
          Josh Brady

          Are you saying that your add-in is called 100 times (once for each part) or is it actually being called 100 times for each part (10,000 times in all)?

           

          1. Just because the file is opened in memory does not mean that it's the ActiveDoc.

          2. If the document that the user is trying to open is an assembly, that assembly may contain subassemblies.

          3. FileOpenPostNotify passes you the path of the file it opened.  Check that string for ".sldasm" at the end.

            • Re: Telling if a part is in an assembly
              Amen Allah Jlili

              passes you or you past to it?

               

               

              Public Delegate Function DSldWorksEvents_FileOpenPostNotifyEventHandler( _

                 ByVal FileName As System.String _

              ) As System.Integer

              • Re: Telling if a part is in an assembly
                Jordan Wigley

                i was saying 1 for each part for a total of 100 times. After some more experimentation i now realize that i was wrong, and the add in isn't being run 100 times. Like you said, the parts in the assembly are not being made ActiveDocs, but are still being affected. When it process the assembly it works with the ActiveDoc which in this case is the Assembly being opened, and adds properties, but for some reason the parts in the assembly are also being considered as being edited and changed, but no properties added. This is what lead me to believe that the Add in was running for each part, but was running incorrectly and causing longer load times. It seems my issue of load times are something else. So i guess, now that i have a better idea of whats going on i should revise my question to be; one, does changing/adding assembly properties in the custom and config specific properties in turn affect or change the parts in the assembly in any way; and two, is it possible that the add in could be conflicting with another add in that gets called by the FileOpenPostNotify event, causing long load times. Sorry for the confusion