AnsweredAssumed Answered

Pulling Custom Properties in Macro

Question asked by Eric Jacobson on Nov 20, 2018
Latest reply on Nov 20, 2018 by Deepak Gupta

Hello, all;


I'm trying to learn how to pull data saved as a Custom Property in order to use it inside macros.


For example: I've found an old macro on here that will open a part drawing that I think will be a good place for me to start my learning.


We save our part drawing with the name: Custom Property 3 & "-" & Custom Property 2.


Our file path would be: G:\Fixtures\Custom Property 3\Details\Custom Property 3 & "-" & Custom Property 2.SLDDRW


Is anyone willing to walk me through how to alter this to access the part's custom properties?


Thanks for any help!




Option Explicit



Dim swApp As SldWorks.SldWorks

Dim swModel As ModelDoc2



Dim DocName As String

Dim DrwName As String



Dim swLoadErrors As Long

Dim swLoadWarnings As Long



Sub main()



Set swApp = Application.SldWorks



Set swModel = swApp.ActiveDoc



DocName = swModel.GetTitle



DrwName = Left$(documentname, 6) & ".slddrw"



DrwName = Replace(swModel.GetPathName, DocName, DrwName, 2, , vbTextCompare)



If Dir$(DrwName) <> "" Then



Set swModel = swApp.OpenDoc6(DrwName, swDocDRAWING, swOpenDocOptions_Silent, "", swLoadErrors, swLoadWarnings)



End If



End Sub