How to access Intent Design Rule items by category via .NET API?

How to access Intent Design Rule items by category via .NET API?

Anonymous
Not applicable
1,298 Views
4 Replies
Message 1 of 5

How to access Intent Design Rule items by category via .NET API?

Anonymous
Not applicable

Hi folks.  I have an Intent design which includes a few different types of assembly items which have a custom category name, "Component Parameters".

I am attempting to locate these parameters from the selected assembly via .the NET API.  As best as I can tell, the underlying values are stored in Rule objects.

Here's an example of the design code where you can see the "Component Parameters" category...

 

IntentModel_Partition_ComponentParameters_IntentDesignEditor.jpg

 


In the Intent Model browser, selecting an assembly of that type (Partition_Assembly, in this case) and right-clicking to choose "Parameters..." displays the editable parameters... 

IntentModel_Partition_Parameters.jpg

 

And here you can see the "Component Parameters" category items:

 

IntentModel_Partition_ComponentParameters_Dlg.jpg



So, my questions are...

1. How can I access this set of parameters by navigating the Active Document via the .NET API ?  (Currently, I have access to the Occurrences list of Occurrence objects at a high-level from the AssemblyComponentDefinition object).

2. How can I locate the Category with the specific name ("Component Parameters" in this case) ? 

3. Once located, is there a way to set the values, or are they limited to just being read-only from the .NET API ?

Thank you very much for any assistance!  (in case it isn't painfully obvious, this is my first foray into Inventor and Inventor ETO so it's a bit overwhelming).

Reply
Reply
0 Likes
Accepted solutions (1)
1,299 Views
4 Replies
Replies (4)
Message 2 of 5

AlexKorzun
Autodesk
Autodesk
Accepted solution

Hi,

 

If the occurrence was created by Intent, you can inspect the attribute set "Intent" on it. The Attribute "IntentName" will contain the reference string (address of the part in Intent model tree)

To get the Autotesk.Intent.Part that represents the occurrence, evaluate (in C# notation):

Part p = Autodesk.Intent.IntentAPI.Instance.ActiveRoot[ refstring]

Then,  p.Design will return the Design of the Part.

 

des.GetLocalRules() will return the collection of the Rules defined in this Design (not whole hierarchy)

 

For each Rule, you can determine whether if has annotation, via call to .Annotations["%%category"]

 

And yes, to create dynamic Rule (this is what "set rule value" is), you can use

 

p.SetRuleValue( ruleName, value). Value should be the of the same datatype as defined in the Design.

 

[‎ hope this is in support of an existing ETO customer.  As you should know, we are not selling ETO to new customers. 

 

Thank you,




Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.

Reply
Reply
Message 3 of 5

Anonymous
Not applicable

Hi Alex,

Thanks very much for your reply!  I had figured out to use GetRuleFormula() and SetRuleValue() which has made me some good progress at the top-level of the assembly.  My big issue now is how to traverse down into child parts?  In this specific case, there is a category of rules that was created called "Project Parameters" on the root assembly.  I can get to those.  But several of the child-items have a category of rules that was created called "Component Parameters".  I need to get to those as well, but cannot figure out how to iterate through the assembly tree to find them.  Is that something simple?

Reply
Reply
0 Likes
Message 4 of 5

AlexKorzun
Autodesk
Autodesk

Hi Jeff,

 

You can use p.GetChildren() or p.GetAssemblyChildren() to get the collection of the child Parts.

Then, for each of these parts, you can determine whether its Design is of your interest, similarly

 

p.Design.IsKindOf("MyAssembly")

 

 

Thank you,




Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.

Reply
Reply
Message 5 of 5

Anonymous
Not applicable

Thank you very much, Alex!

Reply
Reply
0 Likes