algorithmic modeling for Rhino
I'm looking for some help getting a very simple C# component to work. My goal is to execute the MatchMeshEdge command from within Grasshopper. Since this command is not exposed in the RhinoCommonSDK, I modified a working C# component that does something similar (ReduceMesh, written by Andrew Heumann). Both scripts are attached.
Aside from changing the component name and eliminating the P parameter, I made two modifications to the script:
1) changed line 87 from
private void RunScript(Mesh M, double P, ref object A)
private void RunScript(Mesh M, ref object A)
2) changed line 93 from:
Rhino.RhinoApp.RunScript("_-ReduceMesh _ReductionPercentage " + Convert.ToString(P) + " _Enter", false);
Rhino.RhinoApp.RunScript("_-MatchMeshEdge " + " _Enter", false);
When I run the ReduceMesh component, the mesh object I feed it gets baked, the ReduceMesh command is run, the temporary object is deleted, and the reduced mesh result is returned. (Thanks, Andrew).
When I run the MatchMeshEdge component, the mesh object I feed it is baked, the MatchMeshEdge command is run, but the temporary object is not deleted and no result is returned. The runtime error reads: "Sequence contains no elements (line 0)".
I have a feeling that the command line string I am handing to RunScript is incomplete. When I enter it manually on the Rhino command line I see that it wants a mesh and three parameters. Of course I can hit Enter to accept the default values, but when you invoke a command through RunScript do you have to supply all parameters regardless? Also, where would I find details on the argument types that the command wants? For example, the last parameter reads "RatchetMode=On" or "RatchetMode=Off". How do I know if the type is Bool or the literal string "On" or "Off"?
I am a complete novice at this so any help you can provide would be greatly appreciated!
This works a little bit different here...anyway it's not that much of a change...just look at the c# in the attached file
The match works...i've added some lines for disabling redraw and changed the delete to purge to save some RAM if you're working with it a lot...you might do that with the ReduceMesh Comp from Andrew as well, because i think it takes to much computational power.
I hope this is was you were searching for. Best regards
Thanks very much for tweaking this so it works correctly, and sorry for the long pause in my reply.
glad it worked....your welcome