×
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

PropertyEditorGlobal

PropertyEditorGlobal

PropertyEditorGlobal

(OP)
I'm hoping someone here can help with me with an issue I'm having with this macro.

I have a large number of part files (~200) that I wish to add the property named "Weight" to. The value for this will be the mass calculated by SolidWorks.

The problem I'm having is that in defining the properties to add via the macro I don't know what to enter for the value of this Weight property. For instance, if I have a part open called Part1, when I choose the mass in the drop-down list it is "SW-Mass@@Default@Part1.SLDPRT". However, this is obviously specific to the filename of the part which is open, but I need the code which will update depending on the filename of the open file - I hope that all makes sense!

These parts have already been created which is why I am using this macro, the template has been corrected so any future parts will automatically include the weight.

The Propa-gator program looks as if it may be able to do what I need but my boss wouldn't pay for a program which we would only need to use once on these files then probably not need to use again. Any other macros/methods to achieve this which I am not aware of would also be good!

Thanks for any help

RE: PropertyEditorGlobal

I think this may help you. all the quotes are neccessary.

weight = """SW-Mass@" & partno & ".SLDPRT"""

PROP = swModel.AddCustomInfo3(configuration_name, "Weight", swCustomInfoText, weight)
 

RE: PropertyEditorGlobal

i forgot to mention that you must change partno and configuration_name to suit your needs.

RE: PropertyEditorGlobal

(OP)
Excellent!

"""SW-Mass@" & partno & ".SLDPRT""" is exactly what I was needing. This will save me hours going through hundreds of files and fixing them manually.

Thanks again Boilerbrad, have a star on me!  

RE: PropertyEditorGlobal

Glad to have helped!

RE: PropertyEditorGlobal

(OP)
In fact, I have just discovered it is much simpler. I feel like an eejit now! All I need to enter for the Weight field is "SW-Mass", the @@default@part1.sldprt isn't required.

The only problem I have now is that the macro doesn't like speech marks and will fail when it is run. I don't know how I managed to get Boilerbrad's code to work the first time as it wouldn't work on the second attempt. I can, however, use the SolidWorks Task Scheduler instead which doesn't appear to have any problems.

As you may have guessed I'm not very up to speed on the API side of SolidWorks...

Thanks both Boilerbrad and Corblimeylimey anyway!  

RE: PropertyEditorGlobal

Make sure you use all the quotes in my first example. To pass quotes to a string in VB, they have to be double quotes. For example, string = "text" would give string the value of text. string = """text""" would yeild "text".

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