Inventor Engineer-To-Order (Read-Only)
Welcome to Autodesk’s Inventor ETO Forums. Share your knowledge, ask questions, and explore popular Inventor ETO topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

In a UI how do I get default rule value?

10 REPLIES 10
Reply
Message 1 of 11
bsee1
596 Views, 10 Replies

In a UI how do I get default rule value?

I'm creatign a UI.  How can i get a rule's default value?  Looking at the api, it appears I need to use the RuleInfo property.  Is there an example of how to access that property?  I'm just looping through all parameter rules in a design, and I'd like to get the default value for each rule.

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
10 REPLIES 10
Message 2 of 11
AlexKorzun
in reply to: bsee1

Hi

 

Could you please provide more details? The answer depends on

 

1) Are you interested in default formula as specified in the Design?

2) Expression that was used when the Parameter value was supplied during Part instantiation?

3) Evaluation result?

Thank you,




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

Message 3 of 11
bsee1
in reply to: AlexKorzun

I'm looking to get the default formula specified in the design.  I'm able to get the entire formula, but wanted somethign that gave the default rule specifically.

 

I'm looking for this to work even if no part exists yet which uses the rule.

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
Message 4 of 11
JackGregory
in reply to: bsee1

bsee1:

You wrote: "I'm looking to get the default formula specified in the design."

Can you please show this rule here in its entirety?

 

Then you wrote: "I'm able to get the entire formula, but wanted somethign that gave the default rule specifically."

It is not clear what you mean here.  What is the "entire formula", if it isn't the default rule?  I am wondering if you mean you want something that gives you the expression, not including the flags, name, etc.  Is that correct?

 

Showing us what you have and what you want would be most instructive.

Message 5 of 11
bsee1
in reply to: JackGregory

In a design I have a rule called "direction?".  Its ETO code is below.

 

<%%Category("Trans"),_
%%Choices("Straight,Right,Left")>_
Parameter Rule direction? As String = "Straight"

 

From an addin for the UI, I'd like to be able to look at rule "direction?" and be able to determine that the default rule is "Straight".  

 

I specifically want what the design is set to.  I do not want what this rule is set to in various instances of parts.

 

So far, I've been able to use the api to give me the entire formula as a string, which looks like this: "<%%Category("Trans"),%%Choices("Straight,Right,Left")>Parameter Rule direction? As String = "Straight""

As you can see, this is rather difficult to accurately parse.

 

How can I use the API to show me that the default value of this rule is "Straight"?

 

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
Message 6 of 11
AlexKorzun
in reply to: bsee1

Hi

 

You have to cast to BasicRule type to get Formula source, similar to the fragment below:

 

 

BasicRule basicRule = theRule as BasicRule;

if (basicRule != null)
	formulaString = basicRule.Formula.ToString();
 

 

 

 

Thank you,




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

Message 7 of 11
bsee1
in reply to: AlexKorzun

This is better...but it still has a fair amount of extra formatting.  This is what it gives me for the above rule: "\"Straight\""  

I was hoping it would just return "Straight" exactly how it's coded.

 

I'll need to get the default rule of about 200 different rules, and I'd need to "clean" the extra formatting from each of them.  Is there some way to retrieve cleaner data?

 

Also, is there a way to return the default value as an Autodesk.Intent.Value?  If the default value is a number, the method you showed me returns a string.  However, I'm unable to cast directly from type Source to type Value. To kill 2 birds with one stone, I believe if I'm able to return the value as Autodesk.Intent.Value, it may also eliminate the extra formatting issue.

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
Message 8 of 11
JackGregory
in reply to: bsee1

bsee:

The "extra" formatting is not extra at all.  You request a formula, and you get the formula back.  In this case, the double quotes which are escaped, are actually part of the formula.  The outer double quotes are probably displayed by some formatter in Visual Studio or some other place that is trying to show you that you are looking at a string.  But the string itself contains double quotes.  This is necessary, because otherwise very confusing output could be produced.  How would we return the string "Foo" vs the rule refernce Foo ?  Even more important, how are you going to know which formatting to remove?  It isn't there by accident.

 

As for wanting the value, you are assuming too much, I think.  You stated you wanted the default formula from the Design.  But Designs can't produce values, only Parts (models) can.  In general, a formula is evaluated in a Part context, and this can affect the value.  So you can't assume your formula in a Design can even be evaluated correctly.  Only literals (like your example) can be evaluated without context.  And if you want to evaluate them, just use EvaluateExpression on the root Part.

 

Let me know if these answers don't address your question.

Message 9 of 11
bsee1
in reply to: JackGregory

I understand you're tying to help. Thank you for that. I really do not understand how this method could work on a large scale.  If this is better suited for ADN, let me know and I'll post there.

 

For the scale part, lets assume I have 5 different groups of assemblies. Within each of those groups, I have 15 types of assemblies I'd be inserting to ETO.  Each of those assemblies has roughly 20 parameters, every one of them unique.  In total, that's 1500 different parameters, and none of them are shared with different assemblies.  If I were to explicitly define each button definition, I'd also need to have a label for each.  That's 3000 different button control definitions.  This is where my entire question stems from.  My intention is to dynamically define and implement functionality for every one of these controls in the UI.  I have already defined each of these parameters(rules) inside of ETO.  All I want to do is stick a UI on top of the functioning business logic.

 

In the UI, the values in the controls must come from somewhere.  Preferably, each control would have a default value.  These default values are what I keep referring to in the prior posts.  

 

At the simplest level, I want to retrieve a rule from ETO, display the various options to the user, let them choose one, then turn that value into a parameter and send it back to ETO so a part can be inserted into the model.  Lets say in ETO my rule is defined as an integer numberOfRails = 5, with choices of 0, 5, 15.   Using the method you mentioned, I'd retrieve that value of 5 as a string.  Before submitting the parameter back to ETO, the UI code would have to do a conversion to the proper type...without knowing what the proper type is.  It would be much easier if when retrieving the default rule value from the design, it was able to pass the value in the type the design defines it in.  For example, if numberOfRails is defined as an integer, ideally it would pass it to the UI as an integer.

 

I suppose my original question has changed.  I'm looking for the proper/suggested way to create a UI addin for ETO when large numbers of parameters are involved.  The current conveyor system demo does an excellent job of showing the basics of a UI, but is a bit sparse on how it could be expanded to a larger project.

 

I am sure the recommended way to build a large UI is not to explicitly define 3000+ controls.  Please let me know what practice you recommend to dynamically populate the default value of a rule so it can be easily passed back to ETO as the proper variable type.

 

Thank you,

Brandon

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
Message 10 of 11
ebachrach
in reply to: bsee1

Regarding the challenge of building a UI in a way that avoids the explosion of definitions on the UI side:

 

One of the concepts that we consultants emphasize is the use of a UI "framework", in which the intent entities provide in a consistent way, the details you would want to include in a UI. Rather than get into all the technical details to start, let me direct you to a filter demonstration that is posted at http://etosamples.autodesk.com  (top link).  Leaving aside the graphics display that is using silverlight for another conversation, what you can see on the left side of the demonstration are a tree view showing specific branches of the ETO tree that you want to display, and for each branch, whatever parameters, with their default values and options.

 

The underlying notion is that you can use instances of ETO designs to capture this information, and have it be ready by a generic UI structure to display the input choices and more.

 

ETO 2013 includes a framework like this,  that can be used (or imitated) in development and the ETO designs that support it are described in the wiki here. http://wikihelp.autodesk.com/Inventor_ETO/enu/2013/Help/0148-Inventor148/0525-Library_525/1211-UI_To...

 

Elly


--
Autodesk
Elly Bachrach
ETO/CTO Solutions Designer
Intelligent Configuration Solutions
Mobile +1 (773) 401-6980
elly.bachrach@gmail.com

************************************************************************************
If this post helps, please click the "thumbs up" to give kudos
If this post answers your question, please click "Accept as Solution"
************************************************************************************
Message 11 of 11

 

And here is a link to a topic that has a detailed description of the mechanism that Elly refers to:

 

http://wikihelp.autodesk.com/Inventor_ETO/enu/2013/Help/0148-Inventor148/0307-Inventor307/0324-Tools...

 

Sanjay-

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report