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
www.flexiCAD.com
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
www.flexiCAD.com
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
Hi dharman,
no I have not. Thank you for the tip.
Cheers
Michael
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;
}
}
}
}
}
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;
}
}
}
}
}
}
}
}
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…
I have figured out another solution to solve this little annoyance. I used a workflow automating software named “Quicker” (https://getquicker.net/ ,unfortunately this software is in Chinese, and no Eng version yet) to write a little script. I’m sure you could also use similar softwares such as Autoit, Autohotkey etc.
the workflow for “Set one” is like this:
The workflow for “Set multiple” is similar, just change “shift+tab” to six times.
The difficulty is that I have to make sure when I launch the script the position of the mouse must be hovering above the component. Otherwise the menu will not show.
My solution is that before I trigger Quicker’s scripts panel, I zoom in the component in Grasshopper. Then I trigger Quicker’s scripts launching panel by clicking and dragging within the component’s boundary. I could select “Set one” or “Set multiple” from the panel.
After testing, this workflow works as expected.
If you use other automation software such as autoit or autohotkey, you could write a similar script and assign a shortcut key. Then you could move mouse over the component, and then use shortcut key to launch the script.
Hi Riccardo,
Pretty cool script. I tried modifying it on my own so that it would work on Brep and Mesh components but I had no luck with it. I’m kinda new to C#, can you help me out?