Implement a condition

Implement a condition

ch_giacomo
Enthusiast Enthusiast
248 Views
2 Replies
Message 1 of 3

Implement a condition

ch_giacomo
Enthusiast
Enthusiast

Good morning everyone.

I have this piece of code and would like to implement a condition.

Basically this part should work like this:

if the rule runs in an .IPT file have this run

if the rule runs in an .IAM file ignore the part

Do you think it is possible?

'If "MaterialType" does not exist, create it and set up as above
oMyParameter = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
oParameter = oMyParameter.AddByValue("MaterialType", iProperties.Material, UnitsTypeEnum.kTextUnits)
MultiValue.List("MaterialType") = iProperties.Materials
InventorVb.DocumentUpdate(False)
iProperties.Material = InputListBox("Select a Material", MultiValue.List("MaterialType"), parameter("MaterialType"), Title := "iProperty Helper", ListName := "UNOFFICIAL INVENTOR")
parameter("MaterialType") = iProperties.Material
 

 

0 Likes
Accepted solutions (1)
249 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Try this:

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then Exit Sub
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oUParams As UserParameters = oPDoc.ComponentDefinition.Parameters.UserParameters
'If "MaterialType" does not exist, create it and set up as above
Try 'try to find existing parameter
	oUParam = oUParams.Item("MaterialType")
Catch 'that failed, so create it
	oUParam = oUParams.AddByValue("MaterialType", iProperties.Material, UnitsTypeEnum.kTextUnits)
End Try
MultiValue.List("MaterialType") = iProperties.Materials
InventorVb.DocumentUpdate(False)
iProperties.Material = InputListBox("Select a Material", MultiValue.List("MaterialType"), Parameter("MaterialType"), Title := "iProperty Helper", ListName := "UNOFFICIAL INVENTOR")
Parameter("MaterialType") = iProperties.Material

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3

ch_giacomo
Enthusiast
Enthusiast

wow super fast
Thank you very much
It works perfectly

0 Likes