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!

PropertyEditorGlobal 1

Status
Not open for further replies.

sharester

Computer
Joined
Jun 26, 2008
Messages
7
Location
GB
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
 
I think this may help you. all the quotes are neccessary.

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

PROP = swModel.AddCustomInfo3(configuration_name, "Weight", swCustomInfoText, weight)
 
i forgot to mention that you must change partno and configuration_name to suit your needs.
 
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!
 
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!
 
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".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top