Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading 'evaluated value' from custom properties

Status
Not open for further replies.

nickjb

Mechanical
Joined
Jun 19, 2007
Messages
35
Location
GB
I am trying to read the Evaluated Value from my property table but I keep getting text expression. eg. "sw-Material@part.sldprt" rather than Stainless steel.
 
Do you use CustomPropertyManager::Get3 method?

The fourth out parameter of this method "ResolvedValOut" should return evaluated value.


Artem Taturevich
CSWP
 
After a quick search it looks like I've become obsolete. I'm using ModelDoc2.CustomInfo2, so I need to update to the CustomPropertyManager method.

I've not used this before so if anyone has a few lines of sample code that would be nice.
 
Please take a look at the following macro:

evalValOut is the evaluated value.

Note this macro gets the general custom property named "TestField". To get configuration specific custom property specify the configuration name while retrieving the pointer to Custom Property Manager (Set swCustPropMgr = swModel.Extension.CustomPropertyManager("ConfName"))

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swCustPropMgr As SldWorks.CustomPropertyManager

Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

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

Dim valOut As String
Dim evalValOut As String
swCustPropMgr.Get3 "TestField", False, valOut, evalValOut

End Sub

Artem Taturevich
CSWP
 
Thanks ArtemTat

I couldn't get your code to work. I Adjusted it to this:

swCustPropMgr.Get2 "Material", valOut, evalValOut

...and it worked for me

Is the get3 something special? My autocomplete in the compiler doesn't offer it.
 
This method is available starting from SolidWorks 2008 SP4.

Do you have an earlier version of SolidWorks?

Artem Taturevich
CSWP
 
2007 SP5 here so that explains it.

 
It's ok to use CustomPropertyManager::Get2. It will work as expected as well.

Artem Taturevich
CSWP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top