Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations The Obturator 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
Feb 28, 2005
54
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
 
Replies continue below

Recommended for you

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