Is it possible to lock component position on canvas?

Lots of sliders and graph mappers. Many times I want to adjust but wind up moving the component instead.

TIA, Robb

2 Likes

Locking objects is not possible. You can change the grip display style of Sliders to make erroneous clicks somewhat less likely, but that’s about it I’m afraid.

@DavidRutten, is it possible to make slider components look like PointOnCurve component?

Sometimes when clicking on the slider to change the value it at the same time changes the value and increases the size (length) of the slider component. This is a bug that happens randomly and I cannot catch “on camera”. But it never happens with the PointOnCurve.
Maybe the border of the slider component is not thick enough.

1 Like

Is it possible to make the slider moved only from this small area not from anywhere?
Or by adding a small circle to all components to move them from there.


awe

Somewhat, the slider editor window provides options for the grip display style. GH2 will have 3 grip styles: small and round (hard to grab, not the default any more), big enough to contain the value (default), a solid bar all the way from the left (easier to grab still, but mostly useful I think to signify which sliders represent values that are an amount of something.

@osuire caught bigfoot on camera once.

I haven’t been able to repeat it myself, but since GH2 slider code is 100% new I’ve stopped caring about this bug.

1 Like

You mean possible now, possible to add this in GH1 or possible for GH2?

It’s a possibility, although can get equally annoying if the name is short and thus the label area small. On the other hand, what would be more annoying; accidentally moving the slider when you meant to change it, or accidentally changing the value when you meant to drag it? My own feeling is that the latter is a far worse case.

Because the component can’t locked on the canvas ,i think if we can move it from the text area only ,not from the value area

1 Like

Or another idea if it is possible move components with right click instead of left click

I like this idea. Segment the movement from the changement…

I don’t like this idea since users muscle memory is already set to move the canvas with right-click.

But I like the idea to have a component locked on place. Perhaps some boolean parameter in context menu, default being movable.

In my opinion they are equally annoying but if you move the value and you have a heavy calculation depending on it, GH/Rhino will enter a non-responsive state.

The same quesion again?
We can see that the position of PlaceHolder Component is locked, can we do the same to other components?

@seghierkhaled
Of course you can.

using System.Linq;
using System.Drawing;
[...]
// Find the component by name (some components may not derive from GH_Component!)
GH_Component comp = GrasshopperDocument.Objects.Where(o => o.Name.Contains("Circle")).First() as GH_Component;
// Change the Pivot to something stupid...
comp.Attributes.Pivot = new PointF(float.NaN, float.NaN); 

lock-component.gh (4.1 KB)

6 Likes

Excellent thank you Tom

nice @TomTom!, how can I lock the position of a Cluster that has your c# inside?

I think you’ll need to find the cluster id, either by name, position or any other meta information. This is what the first code line does. Then all you need to do is set the pivot point to NaN and that should do the trick.

.Where is a Linq query providing an anonymous method, returning true or false depending if the name of the component contains a substring (of “Circle”). You should also make sure that you are in the correct Document. I think within the cluster you might no be in the GrasshopperDocument of your host. Could be an issue. I’m pretty sure you can retreive the information somehow.

I tried to modify this method of locking components to lock everything, but unfortunately it works for everything except sliders and other input components, which is what it’s needed the most for. The whole reason to want to lock components is so you don’t accidentally slide the whole component when trying to change the value of a slider.

Here is what I have:


.

lock-component all.gh (9.1 KB)

I added an input to the c# script so I can lock and unlock all the components, it does lock the components, but if I try to move the multidimensional slider for example, I get this:


.

I also notice that I can’t unlock objects, once locked by changing the pivot point to NaN they are apparently locked forever, even if you delete the C# script, and they are permanently locked.

If you save the document after setting the pivot points to NaN, when you open it, you now get:
Screenshot 2024-01-18 084200