Editing Rhino Geometry from Grasshopper/Python

I’ve been working on (what I thought would be) a simple script to move a selected rhino geometry to an adjacent geometry’s control point. I would like to use this for quicker snapping when moving program blocks around in Rhino. In the attached script, I’m able to move the blocks and create a Grasshopper geometry snapping to the correct point, but I would like for the actual Rhino Brep to move to that spot since the Brep has program information attached to the object attributes. From what I’ve been reading, it sounds like it is possible to manipulate the Rhino geometry using RhinoCommon, but I can’t get it work. I’ve also tried using Rhinoscriptsyntax and ScriptContext to move the object to no avail.

Anyone have any tips?

(The attached script has the gh move node to show what I’m hoping the result will be, but I want the Rhino object to move to that location, ideally without having to re-bake the geometry with every move.)

BlockConnector.gh (30.3 KB)

1 Like

This is a rough piece of code.
snap
snap.gh (5.4 KB)

It works with brep vertices (so no midpoint, center, quad, etc).
It take the selected brep (the first one) and move it so one of its vertices touch the vertices of the nearest brep.

Very rough code! It fails often if other types of geometry are on rhino or are selected.
(Restart it when it gives an error)

It can and probably will fail and give errors in other situations, so don’t rely on it and don’t use it for work stuff.

Just a “proof of concept”…

5 Likes

Hi @chrisjhazel, you can check this as well


Very cool, @maje90! This should totally get implemented as an optional, “magnetic” snap option in Rhino!

@maje90 This looks really cool, thanks for sharing; agreed that this should be a standard snapping option in the Rhino interface.

@ErickVasquez, This is what I’m looking to do. I looked through the video, and it seems like they are using rhinoscriptsyntax.MoveObject() to move the box in the active rhino doc. I’ve tried doing this, but it doesn’t seem to work; I can move the gh geometry, but it won’t move the rhino geometry.