algorithmic modeling for Rhino
Hello, I am trying to use C# to create a ButtonObject(), but its attributes.pivot seems not working! I also checked the Attributes.Bounds, same. This happens to BooleanToggle() as well, but there is no problem with ValueList().
Does anyone know about this? Thanks!
Here is the code:
Grasshopper.Kernel.Special.GH_ButtonObject flyButton = new Grasshopper.Kernel.Special.GH_ButtonObject();
flyButton.CreateAttributes();float xCoord = Component.Attributes.Pivot.X - 200;
float yCoord = Component.Attributes.Pivot.Y;
PointF cornerPt = new PointF(xCoord, yCoord);
SizeF sizeDim = new SizeF(104, 22);
RectangleF loctSize = new RectangleF(cornerPt, sizeDim);flyButton.Attributes.Pivot = cornerPt;
flyButton.Attributes.Bounds = loctSize;
GrasshopperDocument.AddObject(flyButton, false);
this.Component.Params.Input[1].AddSource(flyButton);
this.Component.Params.Input[1].CollectData();
Tags:
You need to expire the layout once you've changed the pivot. The Bounds are usually computed by the attributes themselves, you cannot (or should not) set it.
Thanks so much David, it is working now!
Welcome to
Grasshopper
© 2025 Created by Scott Davidson.
Powered by