algorithmic modeling for Rhino
Dear all,
I am trying to place a component called linkedCheckList at a specific location
(Not at the origin) on the GH canvas when it is initialized by another component
after calling: To add it to the canvas.
ghdoc.AddObject(linkedCheckList,true);
Next in the call stack is
public override void CreateAttributes()
{
this.m_attributes = new BESTCheckListAttributes(this);
}
which creates an instance of the class BESTCheckListAttributes, which are the attributes for linkedCheckList (please find it attached)
Within BESTCheckListAttributes I set the Pivot Attribute of the linkCheckList to the attribute of another component under the name space owner.linkedBESTNumberSlider, in the hope that linkedCheckList will be initialized right next to owner.linkedBESTNumberSlider on the canvas.
However it doesn't work and throws a null exception because the attributes of linkedCheckList have not been created yet.
I also tried running this code in some methods I override like Read and Write but these methods are either called after or before the attributes are created so either a null exception is throw or linkedCheckList is initialized and then moved!
So my question is where do I put my code to make sure that when linkedCheckList is initalized by ghdoc.AddObject(linkedCheckList,true); I can set its Pivot value?
Many thanks!
Tags:
Anton,
I have added a timer component into grasshopper canvas,here is the code:
private void ADD_TIMER(GH_Component component)
{
Grasshopper.Kernel.Special.GH_Timer g = new Grasshopper.Kernel.Special.GH_Timer();
Grasshopper.Kernel.Special.GH_TimerAttributes tt = new Grasshopper.Kernel.Special.GH_TimerAttributes(g);
tt.Pivot = new PointF(component.Attributes.Pivot.X - 120,component.Attributes.Pivot.Y + 50);
g.Attributes = tt;
g.NickName = "Panda_Translate_Timer";
g.AddTarget(component);
g.Interval = 1000;
Grasshopper.Instances.ActiveCanvas.Document.AddObject(g, false, OnPingDocument().ObjectCount);
}
You can use it as a reference!
Thanks, Panda it was a simple oversight on my part!
Did I mention that you're awesome ; )
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by