Macro to create parameter and iLogic Rule

Macro to create parameter and iLogic Rule

Anonymous
Not applicable
727 Views
3 Replies
Message 1 of 4

Macro to create parameter and iLogic Rule

Anonymous
Not applicable

I need some help to make the below macro to run in some ipt already created.

 

  • Create parameter "Part_Area" with m^2 as Unit/Type and 1,0 m^2 as Equation > Export Parameter > Add (iLogic) Rule: Part_Area = iProperties.Area > Save & Run > Save IPT

 

Any suggestion where I could learn it will be appreciated too.

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

danmachen
Advocate
Advocate

Hi,

 

Can you be more specific about the part property you want to capture?

 

I am assuming you want to measure the area, but the area of what? 

 

There is some script you can learn on setting user parameters through ilogic here: 

 

https://forums.autodesk.com/t5/inventor-customization/ilogic-code-to-create-a-user-parameter/td-p/31...

Dan Machen
Autodesk Inventor 2019 Certified Professional
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

Ideas that need support:
Circular / Rectangular Point Matrix
Allow Axis & Plane Selection on Rectangular / Circular pattern
Graphical iLogic Programming
0 Likes
Message 3 of 4

Anonymous
Not applicable

oh sorry! I need to assign the total area already written at model's iProperty to a new Parameter called Area_Part.

 

  1. Create the Area_Part parameter, with Unit/Type = m^2 and with the Export box selectedParameter.png
  2. Create a rule to assign the iProperties.Area to the parameter created (Part_Area)
  3. Save & RuniLogic.png
  4. Save the part

In this way I may use the parameter in my Parts List to show the painting area.

 

 

0 Likes
Message 4 of 4

danmachen
Advocate
Advocate
Accepted solution

Try running the following code within the part rule and see if it works first. 

Then you can try executing on save.

 

If you wish to display the trailing zeros, then change the parameter within the code as you wish.

 

Dim oDoc As PartDocument = ThisDoc.Document

Try
prop = oDoc.ComponentDefinition.Parameters.UserParameters.item ("Area_Part")
Catch
newprop = oDoc.ComponentDefinition.Parameters.UserParameters.AddByExpression("Area_Part", "100", "m^2")
End Try

param = Parameter.Param("Area_Part") 
param.ExposedAsProperty = True 
param.CustomPropertyFormat.ShowTrailingZeros = False 
param.CustomPropertyFormat.ShowLeadingZeros = False 
param.CustomPropertyFormat.ShowUnitsString = False 

 

Dan Machen
Autodesk Inventor 2019 Certified Professional
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

Ideas that need support:
Circular / Rectangular Point Matrix
Allow Axis & Plane Selection on Rectangular / Circular pattern
Graphical iLogic Programming