1 Reply Latest reply on Feb 17, 2016 12:32 PM by Josh Brady

    VBA Macro get custom property value from drawing when run from model

    Paul Chaplin

      My company currently has a macro that will create a flat pattern drawing of a sheet metal part and save it as a DXF. In saving the flat pattern drawing as a DXF it grabs the part number, configuration name, and revision of the model from which the flat pattern drawing was made. However we have found that there are certain instances where the revision letter of the model may not be the same as the revision letter of the solidworks drawing for that part (this generally occurs when there are multiple configurations of the part that might have gotten added after the initial revisions, or when one configuration may require a revision that does not apply to the other), and I would like to pull the custom property value for "Revision" from the drawing document. So far I have gotten a macro to pull the custom property value for "Revision" from the drawing, but only by first opening the drawing in question. Depending on the part this could add considerable time to the running of the DXF macro. Is there a way that I can pull the custom property value for "Revision" (or really any custom property value from the drawing document) when the macro is run from the part model (without having the drawing document open), or must I first open the drawing to read its custom properties? All this is being coded in VBA.

        • Re: VBA Macro get custom property value from drawing when run from model
          Josh Brady

          It is possible to read drawing custom properties without opening the drawing document using the Document Manager API.  To do this you have to request a license key on the SW website.  Of course, you also need to have some way to know where the drawing file is.  Assuming it's in the same directory as the part file with the same name (or following some predictable convention) that should be straightforward, but there is no link in the part file itself to the drawing file.