CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products []
CZ | EN | DE
Login or
  Visitors: 7238

CAD tip CAD tip # 12024:

Question CAD 
 %  platform  category 
Q - question

How to create a custom iProperty or Parameter with iLogic?

A - answer How can I use an iLogic rule to automatically create custom parameters of a model or custom iProperties? How to handle situations when they already exist?

For both cases, you can use the coding construction Try Catch, ie. attempt to access the parameter or iProperty and catch any possible failure of this access.

The code for creating the iProperty "MyProperty" then looks as follows:

Dim propertyName As String = "MyProperty"
Dim propertyValue As String = "Test"

customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")
      prop = customPropertySet.Item(propertyName)
      customPropertySet.Add("", propertyName)
End Try

iProperties.Value("Custom", propertyName) = propertyValue

The iLogic rule code for conditional creation of a custom/user parameter "MyParameter" can look e.g. as follows (assuming running the rule in an IPT part document):

Dim oParams As Parameters
Dim oPartDoc As PartDocument = ThisDoc.Document
Dim oPartCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
oParams = oPartCompDef.Parameters

Dim oUserParams As UserParameters = oParams.UserParameters

  p = Parameter("MyParameter")
  oUserParams.AddByValue("MyParameter","MyValue", UnitsTypeEnum.kTextUnits)
End Try
100% *  CAD 
7.10.2018    17823×  
Prices - CAD eShop:
applies to: Inventor ·

See also:
Tip 13963:Sum of pipe element lengths in Inventor (iLogic).
Tip 13884:How to send e-mails with an iLogic macro?
Tip 13611:BOM with multi-line items in Inventor.
Tip 13211:Automatic numbering/renaming of multi-volume bodies in a part.
Tip 13197:How to transfer a model or sketch parameter to iProperties?

Back   All CAD Tips

Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD:    OS:    Categ: 
Text:  FAQ glossary   

Extend your AutoCAD LT productivity with our popular add-on
CADstudio LT Extension More info

Please use these tips at your own risk.
Arkance Systems is not responsible for possible problems that may occur as a result of using any of these tips.