Creating or editting properties with a macro
Creating or editting properties with a macro
(OP)
I have a written a macro to populate the properties table for new parts, I also want to use it to update the table for older parts that weren't created with the correct template.
I'm new to macros and vb so I need something simple. Using some borrowed code from this site I've manage to get something working:
Success = swModel.AddCustomInfo3("", "Finish", swCustomInfoText, "")
swModel.CustomInfo2("", "Finish") = "Natural"
This will populate the property 'finish' with the value 'natural' (our default) but if the property has already been set to something else then it overwrites it. I don't want that to happen I want it to keep the current value.
I'm new to macros and vb so I need something simple. Using some borrowed code from this site I've manage to get something working:
Success = swModel.AddCustomInfo3("", "Finish", swCustomInfoText, "")
swModel.CustomInfo2("", "Finish") = "Natural"
This will populate the property 'finish' with the value 'natural' (our default) but if the property has already been set to something else then it overwrites it. I don't want that to happen I want it to keep the current value.






RE: Creating or editting properties with a macro
1. if the property doesn't exist, create it and populate it with a set value
2. if the property exists then keep the current the value
RE: Creating or editting properties with a macro
If value in the "get" property exist and <> "" then do not change it else delete it and add it with the new value.
Thing get a little bit more complicated with CustomPropertyManager.
RE: Creating or editting properties with a macro
Get rid of your second line. The AddCustomInfo3 function will not overwrite an existing property. You can verify this by checking the value of the variable "Success" with a message box. All you need to do to get your desired behavior is put "Natural" in your AddCustomInfo3 line and get rid of the next line. So you'll have:
CODE
-handleman, CSWP (The new, easy test)
RE: Creating or editting properties with a macro