×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

"Magic" custom properties via API?

"Magic" custom properties via API?

"Magic" custom properties via API?

(OP)
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.

RE: "Magic" custom properties via API?

  
  • To get custom File Properties:
    1. Calls that were used with SW2006 and still do work
      1. swModel.GetCustomInfoValue
      2. swModel.AddCustomInfo3
      3. swModel.DeleteCustomInfo2
    2. Or use this one. It's new with SW2007 but I haven't used it yet:
      1. GetCustomProperties
      
  • To get a dimension value:
    1. swModel.Parameter(DimName).SystemValue
    Also try the Help, go to SolidWorks/Main Menu/SolidWorks and Add-Ins API Help Topics

    Ken

    RE: "Magic" custom properties via API?

    In older versions of SW, these values would resolve.  Now they don't.  Sad.

    RE: "Magic" custom properties via API?

    (OP)
    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.

    RE: "Magic" custom properties via API?

    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.

    Red Flag This Post

    Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

    Red Flag Submitted

    Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
    The Eng-Tips staff will check this out and take appropriate action.

    Reply To This Thread

    Posting in the Eng-Tips forums is a member-only feature.

    Click Here to join Eng-Tips and talk with other members!


    Resources