Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Putting a check in macro 1

Status
Not open for further replies.

akhtar07

Mechanical
Mar 8, 2015
59
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
 
 http://files.engineering.com/getfile.aspx?folder=2c580b9b-54b8-4b46-84a4-d8b2c585701d&file=part_properties.jpg
Replies continue below

Recommended for you

this make sens Ferdo!

The script will do what you ask the script to do


Eric N.
indocti discant et ament meminisse periti
 
I know but how to do it ?

what's the script !

Warm regards,
Akhtar Aziz
 
google "VBA if then"

Eric N.
indocti discant et ament meminisse periti
 
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
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor