Bake user text (attributes) for new curves in the Rhino document

I am working on a script that requires every curve to have specific attributes, because I use curves and modify them with Grasshopper based on the specific attribute values they have. To automate my workflow, I would like to auto-bake specific attributes to newly created curves in a specific layer. Is there a way to detect that new curves were added to a layer in Rhino with Grasshopper?

By the way, I am using the new bake component to update my geometry.

I was wondering, is it possible to detect changes in the Rhino document with Grasshopper in general? What options are there (e.g. detect when I moved a polyline or when I changeattribute values)? I might want to bake the outcome of my script every time I saved the Rhino document, for instance.

You can use the User Text node to assign meta data prior to baking or to read meta data on model objects. The node works as a get/set component meaning the if you leave the K/V blank it will show the current K/V of C but if you input K/V it will merge, replace, or remove the K/V items depending on your setting on the component.

Separate from that, your second question:

Most times with referenced geometry from Rhino, if you move/modify it in Rhino GH will run downstream logic accordingly.

If you are wanting to listen for specific changes then you need to handle it with scripting and subscribe to event handlers or define some other function that detects specific changes like an example in psuedo code:

if obj_crv moved > 100 print "curve moved" else print "please move curve further"

or

on mouse hover(obj_crv) display "(obj_curve_name)"

because in these above examples GH won’t care if you move it 10 ft or 100 ft because once you move it will, yes, retrigger the downstream logic in GH but the new position is current and it no longer recalls the last position (there are ways you can store or reference previous positions but I just mean in general)

and GH doesn’t care about your mouse hover event unless you have logic telling it to care

Elefront has a reference by layer component (_RefLay). The new Rhino tab in the R8 WIP Grasshopper has a query objects component (_Objects) which can filter by layer. The problem lies in identifying what constitutes a new curve. A solution might by to add a new curves layer to your model and put new curves on it until processed, then move them to their “normal” layer.

Alternatively, you can filter by User Attribute so you should be able to find curves that don’t have your attribute set and bake it just to them.

Regards
Jeremy

1 Like

Yeah, thought about it. I’ll look for the attributes and query the same attributes that I use for baking.

It’s actually surprisingly simple to record changes. I used a data dam with a 0,25s interval and list length to check for the number of referenced objects on a layer.