IF statement on Arrays?

 
 
 
Posted by:jcdeblok
Data created:19 October 2012

test=[true,false,false,true,false,true]

val_true=[a,b,c,d,e,f]

val_false=[A,B,C,D,E,F]

('val_true' and 'val_false' contain the same types)

If connect those to an 'if' node I was kinda hoping this would come out:

out=[a,B,C,d,E,f]

 

But instead I get an exception popup:

System.InvalidCastException: Specified cast is not valid.
   at Ephere.Utilities.Operator.IfInputValidator.Validate(IList`1 validities)
   at Ephere.Modeling.MetaWrap.OutputPort.ValidateInputsWithCustomInputValidation(ICollection`1 inputs, IList`1 threadSpecificInputValues, Action`2 validateInputs)
   at Ephere.Modeling.MetaWrap.Wrappers.Function.Instance.OutputPort.ValidateInputsWithCustomInputValidation(ICollection`1 inputs, IList`1 threadSpecificInputValues, Action`2 validateInputs)
   at Ephere.Modeling.MetaWrap.OutputPort.GetValueUnprotected(Object threadContext, ICollection`1 asyncNodes, IList`1 threadSpecificInputValues, Boolean validateInputs)
   at Ephere.Modeling.MetaWrap.OutputPort.GetValue(Object threadContext, ICollection`1 asyncNodes, IList`1 threadIndependentInputValues, Boolean validateInputs)
   at Ephere.Modeling.Cortex.GraphSchematic.b__30(Object obj, EventArgs args)
   at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

Are those string values (a,b,v,d,e,f,A,B,C,...)? If so how did you enter them into the node? Just trying to see if I can write a unit test for this.

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Nevermind, indeed it repros with char values. You've discovered a bug my friend :)

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Ok, it is fixed for next build. I am attaching a patch for you meanwhile. You just need to replace the Ephere.Utilities.dll assembly in


Attached Files:

>Release.zip (43616 bytes),

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Thx! but are you sure it is fixed for every data type?  I didn't try it with chars, I just used it as a simple example of comparing arrays :) I still get the exception with the latest build+patch. (I copied the dll to "C:\Program Files\Autodesk\3ds Max 2013\plugins" ) Attached is a ctx that shows the problem when you try to validate the ouput from the 'if' node. If you connect the output from the final meshnode to the plugin's output it gives multiple error popups.


Attached Files:

>if_on_array.ctx (31429 bytes),

Ahh, I copyied the dll to the wrong folder, it is now in my appdata location. But still no go.

One thing I've noticed it that the 'subtract' node has something wierd too, maybe related? When you add it the first time and connect it allright, the outputs are all the ContPolyData entries are decreased by 1)  but when you save en reload the ctx the node is red and outputs an array of nulls. 

I just fixed one issue with reloading an if node. Can you, however, give me some more description about the subtract node error? What is ContPolyData?

Marsel Khadiyev (Software Developer, EPHERE Inc.)

ContPolyData is short for  getContiguousPolygonData, CPD would work fine too.

 

About the subtract node, try this:

 

1) create a simple torus object with LabGemoetryModifier plugin

2) load ctx from previous post

3) rightclick on subtract's output connection -> validate

4) observe red lines and array full of 'null' outputs

5) delete subtract node

6) create new subtract and wire the same as the original

7) subtract's validate output now does work.

8) save file and reload it, then goto step 3 and it's red/null  again.

 

So it looks like something is lost at save/load?

 

And in addition to that, if you have recreated the subtract node and it validates, try this:

1) connect the right most mesh-nodes to the plugin's output.

2) expected is a valid mesh, minus one vertex, but it gives red lines and error popups.

 

(Next time i'll find something I'll make a seperate defect report for each one ;)

Thanks for the steps. The subtract issue will be fixed in next build (just fixed it). The issue is with saving so you will have to re-add the subtract node and resave the ctx file.

Marsel Khadiyev (Software Developer, EPHERE Inc.)