2 Replies Latest reply on Oct 28, 2013 7:41 PM by Brad Overstreet

    Get drawing path and filename while traversing component tree

    Brad Overstreet

      I have a macro that runs in an assembly which traverses the component tree recursively to collect and extract some information.  One piece of data that I am missing is the full path and filename for the drawing or sub-assembly.  I did not see a method in ModelDoc2 that would provide that information.  What is the process to get this data?

       

      I am using SolidWorks 2013 and my macro is written in c#. 

        • Re: Get drawing path and filename while traversing component tree
          Josh Brady

          Are you talking about the file path of the drawing (.slddrw) or the model (.sldprt/.sldasm)?  If you are looking for the drawing, there is none.  The drawing references the model.  The model does not reference the drawing.  No part knows what assemblies use it, and no part/assembly knows what drawings reference it.  You can use the Document Manager API to run a "Where Used" search to find documents that reference a given part/assembly file.

           

          If you just want the path of the referenced part/assy component, just use .GetPathName

            • Re: Get drawing path and filename while traversing component tree
              Brad Overstreet

              Yes I am looking for the path to the .slddrw.  What you said makes sense.  I already pull the path the part\assembly but the output of this macro ends up in the machine shop and they want to link to the drawing not the part\assembly.  Since 90+% of the time the drawing is the same name and in the same folder I guess I will have to make an assumption of the drawing path and then check the filesystem to see if it exists.