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 TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to check for Custom Property Field

Status
Not open for further replies.

Phadreus

Mechanical
Joined
Feb 28, 2005
Messages
54
Location
US
Greetings all,

I am running SW2005 and have a need to check for the existence of a custom property field (non configuration specific) in a macro. I am currently running the following VB Routine to create a custom field called "Manufacturer".

Sub main()
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
retval = Part.AddCustomInfo3(ConfigName, "Manufacturer", 30, "AAA")
End Sub


Before creating the custom field, I would first like to check for the existence of that field, and simply leave it alone if it exists. This way, I will not overwrite a custom property value if it allready exists. If it does not exist, then I would like to create it and populate it as shown in the above code.

Is it possible to check for the existence of an existing custom property field? What would the code look like to do this? Thanks in advance for any advice!


Mark Price
Automated Assembly & Test Systems
 
Use the CustomInfo2 call. You can try to retrieve the information and if you don't get anything back, then you know it doesn't exist.

BTW - you code above will add the custom property at the configuration level. If you want to add it at the document level, you need to pass an empty string where you are currently passing ConfigName.

Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top