# Wish: Quicker "Set one..."

Hi…,

I have some curves which I have to set in the context-menu of the curve component by hand.

Can I define a hot key or an icon somewhere to use “Set one…” faster?

Thanks

Michael

2 Likes

No such shortcut exists I’m afraid.

Have you ever used the pipeline components?
There’s a OOTB version and one in the Human plugin. Can’t remember which one I use, but you can set them to dynamically reference all object in the document, and filter by type/layer/name etc. This is one way of avoiding lots of right click menus

1 Like

Hi dharman,

no I have not. Thank you for the tip.

Cheers

Michael

If your curves are (uniquely) named, you can also use a direct text \rightarrow curve conversion:

1 Like

Hi David,

no, they are not. I am searching for a one click setting (now I have two clicks and searching the “Set one…” entry).

Thanks

Michael

Ideally a double click on any parameter which supports local data would fire up whatever UI is needed to specify the internals, but that doesn’t work in GH1.

Just to playing around with c# …
This some code set any selected (or none if none) geometries on rhino as referenced geometry on the first found selected “Geo” param.

(script fixed and updated on 12th post )

I’ve not tested it thoroughly, but it seems to work good.
Comments inside, should be easy to edit… maybe.

Hope it helps XD

code:

private void RunScript(bool Set)
{
if(Set){
foreach (IGH_DocumentObject obj in this.GrasshopperDocument.Objects){
// Setting string type of param to search for
string type = obj.Attributes.DocObject.ToString();
// Finding first selected Geometry param on canvas
if(type.Equals("Grasshopper.Kernel.Parameters.Param_Geometry") && (obj.Attributes.Selected)){
Grasshopper.Kernel.Parameters.Param_Geometry geo = (Grasshopper.Kernel.Parameters.Param_Geometry) this.GrasshopperDocument.FindParameter(obj.InstanceGuid);
// Checking it have no input sources
if(geo.SourceCount == 0){
// Deleting current data on Geometry param
geo.PersistentData.Clear();
// Getting currently selected objects on rhino document
System.Collections.Generic.IEnumerable<Rhino.DocObjects.RhinoObject> objs = this.RhinoDocument.Objects.GetSelectedObjects(false, false);
foreach(Rhino.DocObjects.RhinoObject obje in objs){
Grasshopper.Kernel.Types.IGH_GeometricGoo goo = GH_Convert.ToGeometricGoo(obje.Id);
// Appending GeometricGoo to Geometry param
geo.PersistentData.Append(goo);
}
geo.ExpireSolution(true);
// Exiting foreach cycle
break;
}
}
}
}
}
3 Likes

Hi Riccardo,

this looks like a very nice solution. I have tried this here in Rhino 6 with Grasshopper 1, but it doesn’t work.

May you have a look:
ListFromPoints.gh (16.7 KB)

Thanks

Michael

Please use it as shown in the gif , that’s the only way to make it work.
Use a Geometry (Geo) params, not Curve.
Select geometries on rhino and the Geometry params and trigger the script with a “True” …

Hi Riccardo,

ah, I see. But this will not speed up my process.

Cheers

Michael

set_geometry_button.gh (7.3 KB)

Try this, then:
just select geometries on rhino and click the button, it will set as refecenced geometries the first found near “Geo” param. (and moving Geo param near c# component)
You can move away or delete c# after use, but it could be (maybe) useful to have a copy of the script for every geo param you use… play a bit with it (inside you can edit “toll” value for a longer/shorter “pull” range)

Fixed an error on the method on old (and new) script thanks to @DavidRutten
In the file there is both old and new solutions.

code:

private void RunScript(bool Set)
{
if(Set){    // Getting top-left corner coordinates
float xx0 = this.Component.Attributes.Bounds.Left;
float yy0 = this.Component.Attributes.Bounds.Top;
foreach (IGH_DocumentObject obj in this.GrasshopperDocument.Objects){
// Setting string type of param to search for
string type = obj.Attributes.DocObject.ToString();
// Finding first selected Geometry param on canvas
if(type.Equals("Grasshopper.Kernel.Parameters.Param_Geometry")){
Grasshopper.Kernel.Parameters.Param_Geometry geo = (Grasshopper.Kernel.Parameters.Param_Geometry) this.GrasshopperDocument.FindParameter(obj.InstanceGuid);
// Checking it have no input sources
if(geo.SourceCount == 0){
// Getting parameter component bottom-left corner coordinates
float xx1 = geo.Attributes.Bounds.Left;
float dx = xx0 - xx1;
float yy1 = geo.Attributes.Bounds.Bottom;
float dy = yy0 - yy1;
// Setting distance tollerance for the component to found
int toll = 30;
if (Math.Abs(dx) < toll){
if (Math.Abs(dy) < toll){
if (true){ // Fround a param near!
// Moving it
float xx2 = geo.Attributes.Bounds.Right;
float yy2 = geo.Attributes.Bounds.Top;
float xx3 = xx0 + (xx2 - xx1) / 2;
float yy3 = yy0 - 1 + (yy2 - yy1) / 2;
geo.Attributes.Pivot = new System.Drawing.PointF(xx3, yy3);
// Deleting current data on Geometry param
geo.PersistentData.Clear();
// Getting currently selected objects on rhino document
System.Collections.Generic.IEnumerable<Rhino.DocObjects.RhinoObject> objs = this.RhinoDocument.Objects.GetSelectedObjects(false, false);
foreach(Rhino.DocObjects.RhinoObject obje in objs){
Grasshopper.Kernel.Types.IGH_GeometricGoo goo = GH_Convert.ToGeometricGoo(obje.Id);
// Appending GeometricGoo to Geometry param
geo.PersistentData.Append(goo);
}
geo.ExpireSolution(true);
// Exiting foreach cycle
break;
}
}
}
}
}
}
}
}
4 Likes

Hi Riccardo,

great, this works and is what I want.

Thank you very much again

Michael

That’s a nice little feature there, you should add it to food4rhino. The snapping is a nice touch.

I’m playing with c# time by time… I’d like to start making plug-ins but I really don’t know where to start from.
Once I open visual studio I’m already lost…
Coding c# directly in grasshopper is so simple…

1 Like