karamme / Parachute

A Grasshopper plugin to display components's names on the canvas
MIT License
14 stars 1 forks source link

Invalidation of gh component instance referencing #3

Open Kane-BorgMarkkula opened 2 weeks ago

Kane-BorgMarkkula commented 2 weeks ago

Came across an incorrect referencing of the last object placed on GH_Canvas. The observed method mentioned here by David points to use the method below for instantiating and referencing instantiated components.

ghdoc.Objects[ghdoc.Objects.Count-1]

Since Parachute adds the groups in-step with the placement of the object. The last thing that is placed on the canvas is the ParachuteGroup Object parachute utilizes and not the Gh Component itself.

This potentially makes any other plugin that utilizes this component instancing method to stop working if Parachute is installed and activated.

karamme commented 1 week ago

Thanks for reaching out. Parachute wraps the last placed item into a group, which mirrors the behaviour a user could do. It's kind of a hack or misuse of the group component. The upside is, that it stays within the document and is Rhino native. This could also be a downside and there are other components that manipulate the canvas view to show the info.

Regarding your concern, and without investigating it further, the question is whether other components want to make use of how a group was created, if by the user or by another component like Parachute. A potential workaround for the general case would be to check if the last created object is a group and if so, take the previous one until a "real" component is found. Would this method also solve, what you had in mind?