×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Macro to check for Custom Property Field

Macro to check for Custom Property Field

Macro to check for Custom Property Field

(OP)
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
www.assembly-testww.com
Automated Assembly & Test Systems

RE: Macro to check for Custom Property Field

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...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources