×
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

Putting a check in macro

Putting a check in macro

Putting a check in macro

(OP)
Hey guys,

I have a macro that generates part properties automatically. What i would like to do is to put a check in, so the macro stop regenerating the properties if they already exists.

Image is attached for reference.

Script is below:

Language="VBSCRIPT"

Sub CATMain()

Set productDocument1 = CATIA.ActiveDocument
Set product1 = productDocument1.Product

Set parameters1 = product1.UserRefProperties
Set strParam1 = parameters1.CreateString("Project", "")
strParam1.ValuateFromString ""

Set parameters2 = product1.UserRefProperties
Set strParam2 = parameters1.CreateString("Title", "")
strParam2.ValuateFromString ""

Set parameters3 = product1.UserRefProperties
Set strParam3 = parameters1.CreateString("DrawingNumber", "")
strParam3.ValuateFromString ""


so the macro generates Project, Title and DrawingNumber... If the macro is run again, it shouldn't generate them again.

Please help guys, thanks.

Warm regards,
Akhtar Aziz

RE: Putting a check in macro

this make sens Ferdo!

The script will do what you ask the script to do

Eric N.
indocti discant et ament meminisse periti

RE: Putting a check in macro

(OP)
I know but how to do it ?

what's the script !

Warm regards,
Akhtar Aziz

RE: Putting a check in macro

google "VBA if then"

Eric N.
indocti discant et ament meminisse periti

RE: Putting a check in macro

well i also stuck on if parameter exists then do nothing

any help guys?

Set Document = MyCATIA.ActiveDocument
'---
'---CREATE USER PARAMETERS----
Set productDocument1 = MyCATIA.ActiveDocument
Set product1 = productDocument1.Product

Set parameters1 = product1.UserRefProperties
Set strParam1 = parameters1.CreateString("FILE FOR MANUFACTURING", "")
If strParam1.Value = "FILE FOR MANUFACTURING" Then
strParam1.ValuateFromString ""
strParam1.Value = "XXXXXXX.STP"
End If

RE: Putting a check in macro

CODE -->

Language="VBSCRIPT"

Sub CATMain()

Set productDocument1 = CATIA.ActiveDocument
Set product1 = productDocument1.Product

Set parameters1 = product1.UserRefProperties

On error resume next
Err.clear
Set strparam1 = parameters1.item("Project")
If err.number <> 0 then
Set strParam1 = parameters1.CreateString("Project", "")
On error go to 0

End if 

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