Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

"Magic" custom properties via API?

Status
Not open for further replies.

willwicker

Mechanical
Feb 12, 2003
7
I am trying to set some custom properties via the API to take advantage of SolidWorks' "magic" properties, like:

"SW-MATERIAL@Part1.SLDPRT" to get the material name
"D2@Sketch2@Part1.SLDPRT" to get a dimension's value
etc.

However, when I add these values in, what I get is the literal spelling of the magic property, not the evaluable version that SolidWorks generates. I've tried generating the property name with and without the surrounding quotes. Neither way seems to work.

Currently running SWX2007. The help is, as usual, not much help.

Is there a secret control character? Type code? handshake?

Please help.
 
Replies continue below

Recommended for you

[li]To get custom File Properties:[/li]
[ol I]
[li]Calls that were used with SW2006 and still do work[/li]
[ol i]
[li]swModel.GetCustomInfoValue[/li]
[li]swModel.AddCustomInfo3[/li]
[li]swModel.DeleteCustomInfo2[/li]
[/ol]
[li]Or use this one. It's new with SW2007 but I haven't used it yet:[/li]
[ol i]
[li]GetCustomProperties[/li]
[/ol]
[/ol]
[li]To get a dimension value:[/li]
[ol I]
[li]swModel.Parameter(DimName).SystemValue[/li]
[/ol]

Also try the Help, go to SolidWorks/Main Menu/SolidWorks and Add-Ins API Help Topics

Ken
 
In older versions of SW, these values would resolve. Now they don't. Sad.
 
Thanks to KenBolen and TheTick, I was motivated to experiment in more detail. Here's what I found:

It does not matter if you use the new CustomPropertyManager or the older Doc.AddCustomInfo calls.

The magic syntax for pretty much any of the SW-XXXX@PART values (Material, Mass, Volume, Density, Surface Area, Center-of-mass, moments of inertia, etc.) refuses to work if the callout is in all-caps.

"SW-MATERIAL@PART.SLDPRT" fails to resolve.
"SW-Material@Part.SLDPRT" works.
"SW-Material@PART.SLDPRT" works. The filename does NOT appear to be case-sensitive.

Interestingly, the dimension callouts are NOT case sensitive. This is good, because now I can make my code work. It's bad for my blood-pressure though.

Why? Why? I ask myself. Why couldn't the smart people in Concord make custom property names, values, and magic uniformly case-sensitive or case-insensitive? And why couldn't they document it either way?

I just know there's a fascinating explanation lurking behind it all.

William.
 
What I enjoy most about learning SW API is the insight it gives into how the program actually works. Sometimes it can be a bit spooky.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor