Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Undo last changed parameter

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
919 Views, 5 Replies

Undo last changed parameter

 Hi all,

 

I'm creating a form/configurator to produce an assembly.

 

I'd like to write a rule that if someone changes a parameter which will in turn put parameter 'x' above an allowed limit, it will undo this change.

 

The changed parameter could be one of a few different ones.

 

Eg.

 

Parameter 'y' is changed, putting 'x' over it's limit. The change in parameter 'y' is undone.

 

Parameter 'z' is changed putting 'x' over it's limit. The change in parameter 'z' is undone.

 

So the rule will know what parameter was changed and set it back to it's previous value.

 

Any help would be greatly appreciated!

 

- Richard

5 REPLIES 5
Message 2 of 6
ThomasB44
in reply to: Anonymous

Hi @Anonymous

 

First idea :

In your iLogic form you can set the mini and maxi values, check here :

 

Capture.JPG

 

Second idea :

I've wrote this code, it works well, try it.

The parameters must be in blue to run the rule automatically.

 

SyntaxEditor Code Snippet

triggerA = ParamA
triggerB = ParamB

If ParamA < 25 Or ParamA > 100 Then
MessageBox.Show("Please set a value between 25 and 100", "iLogic")
oDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppUndoCmd")
oDef.execute
End If

If ParamB < 25 Or ParamB > 100 Then
MessageBox.Show("Please set a value between 25 and 100", "iLogic")
oDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppUndoCmd")
oDef.execute
End If

 


Thomas
Mechanical Designer / Inventor Professionnal 2025
Inventor Professional EESignature

Message 3 of 6
Anonymous
in reply to: ThomasB44

Hi Thomas,

 

Thanks for the response! I've been trying this code and it works - but only the first time! If I re-enter the value the same it sticks.

 

E.g.

 

I open the form

 

Parameter A is '200'

 

I enter '500' in parameter A

 

This causes Parameter B to be above it's limit of '1000'

 

The message box comes up and tells me, and the parameter change is undone.

 

I enter '500' in parameter A again.

 

The form shows parameter A as 500, but in the parameter dialogue it is set to the original value.

 

 

 

If this was just for me to use it would be fine, but unfortunately i need to make this idiot proof 😄

 

 

Kind regards,

 

Richard

Message 4 of 6
ThomasB44
in reply to: Anonymous

Unfortunately it seems you are right.

The rule works well in part environment when editing dimensions in sketches.

But with an iLogic form the undo command seems to don't work correctly.

Try to add "oDef.execute" 2 times instead of one, it is strange but it seems to be the key.

 

In your form, perhaps a set of a value or a hit of apply is an action ?

But it is not logical in my mind.


Thomas
Mechanical Designer / Inventor Professionnal 2025
Inventor Professional EESignature

Message 5 of 6
ThomasB44
in reply to: Anonymous

Hi @Anonymous,

I was just thinking to something else which could work better to your needs.

I think the "undo" command is dangerous and unstable...

So, the goal is to capture current state of your parameters and store then in custom properties. Each time you change a (blue) parameter in your form, it will be compared to a custom property. At the end of the rule, the (blue) parameter is saved in the custom property.

 

Look at this and please try :

 

SyntaxEditor Code Snippet

'You must run the rule one time first to create and set the custom properties
'Then you can active the MessageBox below

'Check the parameters values and custom iProperties values 'MessageBox.Show("ParamA = " & ParamA _ '& vbNewLine & "iPropA = " & iProperties.Value("Custom", "ParamA") _ '& vbNewLine & "ParamB = " & ParamB _ '& vbNewLine & "iPropB = " & iProperties.Value("Custom", "ParamB"), "Title") 'Check parameters values If ParamA < 25 Or ParamA > 100 Then MessageBox.Show("Please set a value between 25 and 100", "iLogic") ParamA = iProperties.Value("Custom", "ParamA") End If If ParamB < 25 Or ParamB > 100 Then MessageBox.Show("Please set a value between 25 and 100", "iLogic") ParamB = iProperties.Value("Custom", "ParamB") End If 'Create or save current parameters in custom properties oMyParameter = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters Try iProperties.Value("Custom", "ParamA") = ParamA iProperties.Value("Custom", "ParamB") = ParamB Catch oMyParameter.AddByExpression ("ParamA", ParamA, UnitsTypeEnum.kMillimeterLengthUnits) oMyParameter.AddByExpression ("ParamB", ParamB, UnitsTypeEnum.kMillimeterLengthUnits) End Try iLogicVb.UpdateWhenDone = True

I think this code will allow you more possibilities to play with your parameters.

Hope this help Smiley Wink


Thomas
Mechanical Designer / Inventor Professionnal 2025
Inventor Professional EESignature

Message 6 of 6
Anonymous
in reply to: ThomasB44

Hi Thomas,

 

That's working great! Thankyou!

 

I managed to pare down my ilogic functions to have very minimal 'undo' commands, and this works for the last few that I couldn't avoid 😄

 

Kind regards,

 

Richard

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

Post to forums  

Autodesk Design & Make Report