×
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

Bug in Solidworks API for Custom Properties?

Bug in Solidworks API for Custom Properties?

Bug in Solidworks API for Custom Properties?

(OP)
I seem to have found a Solidworks API oddity or bug...
When I use the following code (below) to add a custom property Name "Volume" with a Value of
"SW-Mass@P-24-3-6.SLDPRT", it almost works as expected.  The value is added correctly, exactly as it should be.

However, when I check the results of the macro by opening the part and looking at the custom properties, the evaluated value is not "evaluated" properly.  It is still displayed as "SW-Mass@P-24-3-6.SLDPRT".  But if I click the drop-down list and select the "Volume" property, the Evaluated Value changes to an actual number, (0.06) as it should, although the value "SW-Mass@P-24-3-6.SLDPRT" doesn't change at all, not one character.

Is this a bug, or am I missing something?

[code]
'Check for missing props and add as needed
If ThkDef = False Then Part.AddCustomInfo3 "", "Thickness", swCustomInfoText, Chr(34) & "Thickness@" & CStr(ShortName) & Right(swChildComp3.GetPathName, 7) & Chr(34)

If VolDef = False Then Part.AddCustomInfo3 "", "Volume", swCustomInfoText, Chr(34) & "SW-Mass@" & CStr(ShortName) & Right(swChildComp3.GetPathName, 7) & Chr(34)
[/code}

Shawn Oelschlager
Production Control Ass't
Transco Products Inc.
http://www.transcoproducts.com

SolidWorks Office Premium 2006 - SP4.1
Pentium 4 (2.8 GHz) - 2GB RAM

RE: Bug in Solidworks API for Custom Properties?

I've been unable to reproduce your issue on my machine.  My only suggestion at this point would be to bring this function down to its simplest form and test it from there.  Try this macro, changing the part name in the code to whatever part is active when you run it.

CODE

Sub main()
Const PARTNAME as String = "Part1.SLDPRT"
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
swModel.AddCustomInfo3 "", "TestName1", swCustomInfoText, Chr(34) & "SW-Mass@" & PARTNAME & Chr(34)
swModel.AddCustomInfo3 "", "TestName2", swCustomInfoText, Chr(34) & "Thickness" & "@" & PARTNAME & Chr(34)

MsgBox "Mass: " & swModel.GetCustomInfoValue("", "TestName1")
MsgBox "Thickness: " & swModel.GetCustomInfoValue("", "TestName2")
End Sub

RE: Bug in Solidworks API for Custom Properties?

(OP)
handleman,

I have to apologize because this seems to be another case of my "jumping to conclusions".  I'm not sure what happened, but this was a problem I was having on Saturday and when I tried again today, I too was unable to duplicate the issue.  It seems to be working fine now, so I guess we can call this one "case dismissed"! purpleface

P.S. - I couldn't find an emoticon for "DOH?!"
Maybe something like [homersimpson]? LOL
Anyway, thanks handleman and have a great day!

Shawn Oelschlager
Production Control Ass't
Transco Products Inc.
http://www.transcoproducts.com

SolidWorks Office Premium 2006 - SP4.1
Pentium 4 (2.8 GHz) - 2GB RAM

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