I am having trouble with trying to pick up the custom properties of files in an assembly. I have been successful in picking this up from within the part, but I am stuck as to how to do it from an assembly. I am trying to pick up the value of the Custom property field "Code", for the configeration used in the assembly. Could somebody please help?
SolidworksApi macros
This is the code I am using in the part file, now to use it from the assembly......
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swConfigMgr As SldWorks.ConfigurationManager
Dim swConfig As SldWorks.Configuration
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim nNbrProps As Long
Dim j As Long
Dim vPropNames As Variant
Dim valOut As String
Dim custPropType As Long
Dim Code As String
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swConfigMgr = swModel.ConfigurationManager
Set swConfig = swConfigMgr.ActiveConfiguration
Set swCustPropMgr = swConfig.CustomPropertyManager
nNbrProps = swCustPropMgr.Count
vPropNames = swCustPropMgr.GetNames
For j = 0 To nNbrProps - 1
swCustPropMgr.Get2 vPropNames(j), valOut, valOut
custPropType = swCustPropMgr.GetType2(vPropNames(j))
If vPropNames(j) = "CODE" Then
Code = valOut
Debug.Print Code
Exit Sub
End If
Next j
End Sub
Try codes/macros from these posts:
https://forum.solidworks.com/message/127910#127910
https://forum.solidworks.com/message/152196#152196
https://forum.solidworks.com/message/223855#223855
Thanks a lot, it is now working for me.