AnsweredAssumed Answered

Get custom properties of the model from within a drawing

Question asked by Cameron Taylor on May 30, 2020
Latest reply on May 30, 2020 by Cameron Taylor

Hi

 

Using VBA Im trying to read the "custom properties" of the model shown in the "default model view" in a drawing

 

After scouring the web, I can now read the custom properties of the current document

ie

if the "model" is current then reading "Revision" I get "A"

if "drawing" is current  then reading "Revision" I get ""

 

Could someone please point me in the correct direction.

 

Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim swModelDocExt As ModelDocExtension
Dim swCustProp As CustomPropertyManager


Dim val As String
Dim valout As String
Dim bool As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension

' Get the custom property data
Set swCustProp = swModelDocExt.CustomPropertyManager("")
val = swCustProp.Get4("Revision", True, val, valout)

MsgBox "val = " & val
MsgBox "valout = " & valout
MsgBox "bool = " & bool
End Sub

 

I ASSuME the "swCustProp" need tweaking 

Outcomes