Grasshopper

algorithmic modeling for Rhino

Create a GH_ButtonObject() in C#, its Attributes.Pivot not working!

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();

Views: 910

Attachments:

Replies to This Discussion

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!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service