AnsweredAssumed Answered

Adding PDM access/functions to a simple macro (VBA)

Question asked by Cad Admin on Mar 3, 2017
Latest reply on Mar 3, 2017 by Jason Kerns

I have a (few) simple macros i use that has code to update a models custom properties from a drawing. Currently It does everything silently, without opening the file.  Current code works fine.  Now i have a PDM system that requires the file to be checked out to change the model.

 

I have (2) options:

 

First option: Is there a way to add "silently" checkout so the properties can be updated. (don't really care about checking it back in)

or

Second option: find out if the part model associated with the drawing "is" checked out, and if i can then prompt to do so

Option Explicit 

    Dim swApp                       As SldWorks.SldWorks 

    Dim swModel                     As SldWorks.ModelDoc2 

    Dim swDraw                      As SldWorks.DrawingDoc 

    Dim swView                      As SldWorks.View 

    Dim swCustProp               As CustomPropertyManager

 

Sub main() 

 

    Set swApp = Application.SldWorks 

    Set swDraw = swApp.ActiveDoc 

   

    Set swView = swDraw.GetFirstView 

    Set swView = swView.GetNextView 

    Set swModel = swView.ReferencedDocument 

   

    Set swCustProp = swModel.Extension.CustomPropertyManager("") 

    swCustProp.Set "Description", "Test" 

     

End Sub

Outcomes