What SW version are you running, Jon? If you are using too old of a version, perhaps Add3 isn't implemented yet.
I am using 2017 sp3. I am sure that I have something wrong with the syntax but after spending several hours I looking at alot of posts I can't figure out what I have wrong.
Add2 and Add3 are the same except Add3 allows you to over-write the existing one
Basically, you can use Add2 to add a new CusProp while Add3 to replace an existing one
Add2: FieldName, FieldType,FieldValue
By the way, why you add chr(34) in your field???
So Add3 is just more versatile since it can add AND overwrite existing? If so then all I need is to figure out why it won't work for me...any thoughts on my syntax? Thanks.
I added chr(34) because I thought it was needed to be able to have the value show up as the correct variable instead of just a text. It worked for the Add2 and I assumed it was needed for the Add3.
As I mentioned - why you add chr(34) in the field?
"Gauge", swCustomInfoType_e.swCustomInfoText, Chr(34) & "Gauge_Number@" & FileName & Chr(34))
Fieldname = Gauge
FieldType = text
field Value = seems to have double quote here???
Make sure your variable "swCustProp" is declared / spelled / assigned correctly. In fact, try the same syntax with Add2, to be sure if you have to.
The other thing you could try is to use the return value, and compare the result to: 2017 SOLIDWORKS API Help - swCustomInfoAddResult_e Enumeration
Apparently it can fail due to a mismatched property type.
This might be the problem? Yes it was. Here is what works.
1. Added the swCustProp as Steven mentioned.
2. Changed swCustomInfoText to swCustomInfoType_e.swCustomInfoText as Christian mentioned.
3. Left the chr(34) so that it shows up as a variable instead of just the text
Set swCustProp = swModel.Extension.CustomPropertyManager("")
swCustProp.Add3 "Gauge", swCustomInfoType_e.swCustomInfoText, Chr(34) & "Gauge_Number@" & FileName & Chr(34), 1