Grasshopper

algorithmic modeling for Rhino

in many cases  I need obtain the component's Attributes from DA.Getdata() or calculate from that. but as I notice , CreateAttributes() runs before SolveInstance(), is there any way to recall or postpone it after getting data?

Views: 586

Replies to This Discussion

CreateAttributes ideally only runs once. Once created, attributes typically aren't destroyed so they stick around. You can use the Attributes property to get the current attributes. These may be null if a component has never been displayed on screen.

Thanks David, I tried to set a new value for base.Attributes  in SolveInstance(), but as soon as I input an item to the component it jumps to the origin of canvas , it may be fixed by saving pivot to prevent resetting the position of component.

Do not assign new attributes all the time. The attributes that are already there are just fine.

You should never have to call CreateAttributes() or assign attributes in any other way.

What is it you need these attributes for every solution iteration?

I need to render some curves in canvas ,just above the component,Indeed I've just designed a component that works like  Graph-Mapper  component in Gh but with some more abilities, I embedded simpler version of this component in Heteroptera named Number-Biaser  and Heteraph-Mapper . now Im developing those and for better visualizing need too render a graph curve right above the component that the shape of this curves defined by input parameters values , does it cause any confliction with canvas?

The way to override the display of a component is to create custom attributes. However you should not be assigning these attributes over and over again, you should only assign them once. The attribute class you assign needs to be smart enough to draw different curves when the canvas redraws.

(A completely different approach (which is a possibility, although I do not recommend it for drawing stuff that's always supposed to be there) would be to use regular attributes, but instead draw your geometry using a TagArtist.)

I can make an example of how to implement different attributes,do you prefer VB or C#?

Thank you so much David , I'd rather write C#.

Attachments:

wow w , incredibly this is what exact i was looking for,

thank you again David 

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service