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!

macro to add properties properties (right click - properties - define other properties)

Status
Not open for further replies.

L2S512

Aerospace
Nov 20, 2013
9
GB
Hi
I write a small code to add properties in a prodcut:
but when I run it, it shows a time-run error at "Set parameters1 = prdDoc1.UserRefProperties "
any idea to solve it ?

thx

Sub CATMain()

Dim productDocument1 As Document
Dim product1 As Product
Dim products1 As Products

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

partcount = product1.Products.Count
MsgBox (partcount)

Dim i As Integer
For i = 1 To partcount

products1.Item(i).ApplyWorkMode DESIGN_MODE

Dim prdDoc1 As Product
Set prdDoc1 = products1.Item(i)

Dim parameters1 As Parameters
Set parameters1 = prdDoc1.UserRefProperties 'shows a "run time error:automation error and unspecified error"

Dim strparam1 As strparam
Set strparam1 = parameters1.CreateString("string1", "")

strparam1.ValuateFromString ""

prdDoc1.Update

Next i
End Sub
Sub CATMain()

Dim productDocument1 As Document
Dim product1 As Product
Dim products1 As Products

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

partcount = product1.Products.Count
MsgBox (partcount)

Dim i As Integer
For i = 1 To partcount

products1.Item(i).ApplyWorkMode DESIGN_MODE

Dim prdDoc1 As Product
Set prdDoc1 = products1.Item(i)

Dim parameters1 As Parameters
Set parameters1 = prdDoc1.UserRefProperties

Dim strparam1 As strparam
Set strparam1 = parameters1.CreateString("string1", "")

strparam1.ValuateFromString ""

prdDoc1.Update

Next i
End Sub

Sub CATMain()

Dim productDocument1 As Document
Dim product1 As Product
Dim products1 As Products

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

partcount = product1.Products.Count
MsgBox (partcount)

Dim i As Integer
For i = 1 To partcount

products1.Item(i).ApplyWorkMode DESIGN_MODE

Dim prdDoc1 As Product
Set prdDoc1 = products1.Item(i)

Dim parameters1 As Parameters
Set parameters1 = prdDoc1.UserRefProperties

Dim strparam1 As strparam
Set strparam1 = parameters1.CreateString("string1", "")

strparam1.ValuateFromString ""

prdDoc1.Update

Next i
End Sub


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top