Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GoExcel.CurrentRowValue Throwing an Error on just 1/1000 variable.

2 REPLIES 2
Reply
Message 1 of 3
rzsla
63 Views, 2 Replies

GoExcel.CurrentRowValue Throwing an Error on just 1/1000 variable.

Hello, 

 

I have a rule written that is using an excel sheet to update parameters for the different components. In that rule, there are approximately a thousand local parameters and every single one of them is updating except the last one. (I have checked the syntax, spelling and whatnot).

Now, here's the mind-numbing part, if you save and close inventor and open it again it works without an error but after a few configurations through ilogic it re-appears.  Heres, the code and error: 

 

razaan_shahid_1-1728276573227.png 

Excel : 

razaan_shahid_2-1728276605378.png

Error: 

 

 

System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (0x80004005 (E_FAIL))
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Object[] aArgs, Boolean[] aArgsIsByRef, Int32[] aArgsWrapperTypes, Type[] aArgsTypes, Type retType)
at Inventor.Parameter.set_Expression(String )
at iLogic.ParamDynamicFinder.SetParamValueInner(Parameter param, Object value, Boolean doUpdate)
at iLogic.ParamDynamicFinder.SetParamValue(Parameter param, Object value, Boolean doUpdate)
at iLogic.ParamDynamic.set_Item(Object compoOrDocName, String paramName, Object value)
at ThisRule.Main() in rule: UPDATE, in document HDC.iam:line 144
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

 

 

 

 

Tags (3)
2 REPLIES 2
Message 2 of 3
WCrihfield
in reply to: rzsla

Hi @rzsla.  There is no way for us to know why it only seems to be causing an error sometimes and not others.  If the error always happens at that last line of code, when it does happen, then I would be very tempted to break that last line of code down into multiple lines of code, with some additional feedback.  For instance, I would first prepare a variable, then set the value of that variable using the GoExcel portion of that line, but without yet attempting to add the blue parameter's value to it yet.  Then I would write not only the value it got from Excel to the iLogic Logger window, but also the data Type of that value.  A common issue when interacting with Excel from Inventor is data type mismatch, due to cell formatting on Excel's side.  If the cell is formatted as text, but contains what looks like a numerical value, your code may be getting a String type value that contains numbers, instead of a direct Integer or Double data type value.  Or something like that.

 

When I look at the error message contents, the first line in there that I recognize is this:

at Inventor.Parameter.set_Expression(String )

That means it was attempting to set the value of the Parameter.Expression property, which requires a String, not an Integer or Double.  This has to do with the actual Inventor API Parameter object, not the iLogic rule object named Parameter, which really represents the IParamDynamic Interface.  The later lines in the error have to do with that iLogic rule object, but tell a similar story.  It sounds like it can find the parameter that it is supposed to set the value/expression of, but it simply can not set this new value/expression to it, for some reason.  This seems to indicate that it is getting something from either the GoExcel call, or the blue, unquoted parameter, that it does not know how to process properly.  The 'Parameter' iLogic rule object is pretty dynamic, as far as how or what you set as its value/expression, so I am not sure what it must be encountering.  It will allow us to specify a quoted value, which it understands as a String, and will automatically set that as the 'Expression' of the actual Parameter object for us, even if the parameter has numerical units, instead of text type units.  It can even work with mixed units, as long as they are compatible.  If it was trying to convert a String to a Double, or something like that, it seems like it would have given a different error, more specific to data Type conversion failure, but it did not.  This is why you will need to break that line of code down into multiple lines of code, and inspect every single step of it, with feedback, in order to attempt to figure out what is going on.  

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3
rzsla
in reply to: WCrihfield

Thankyou For such a detailed response. Unfortunately, I had tried type conversion and breaking down the code. i.e first pass the value to a local parameter then adding the values. Before posting the question here. I even declared the parameter as a global parameter and tried to set the units in the parameter form as well but no luck.

 

 

Fortunately though ever since I deleted the ilogic model state the error is gone. Hence, I am not getting into it too much.

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

Post to forums  

Autodesk Design & Make Report