What is the best ways to type cast (between GUID and Curve for example) to use built in rhinoscriptsyntax and RhinoCommon components that require these different type inputs in the same script?
an example of this is aligning a set of curves, flipping them based on direction and performing more operations.
based on my scraping of the API references on RhinoDeveloperDocs, it seems like things like “rs.ReverseCurve” “rs.CurveClosestPoint” “rs.CurveSeam” and “rs.CurvePerpFrame” take either a curve or a GUID input, but are not consistent.
does this mean you have to create different scripts to handle each operation and type cast with your inputs into the ghpython component itself. There must be a better way!
The guid you refer to is part of a RhinoObject instance. This wraps a geometrical instance in the RhinoDocument to uniquely identify it there. In Grasshopper they don’t exist in this document until you „bake“ it. So there are no GUIDs to work with. RS wraps RC so there nothing you could also achieve by using RC. In Rhino you can „cast“ inbetween by using the RS coerce methods. Its called coercing and not casting because you are not just redeclaring the type but finding a geometrical instance by id. Note that casting is not a type conversion, its a reinterpretation of bytes.
Again, this only works for Grasshopper if your geometry is already (“baked”) in the RhinoDocument. If it’s raw geometry created in Grasshopper, then there will be no way of modifying geometry using rhinoscriptsyntax with a GUID.
You’re not missing out by “only” using RhinoCommon. rhinoscriptsyntax is simply a wrapper around RhinoCommon functionality. You can inspect its source code to learn which RhinoCommon classes/methods it implements:
Thank you Anders, great links i will peruse. I will probably continue to have questions going forward regarding scripting RhinoCommon components so its always great to have a robust community that supports new people.