Get the coordinates of the corners of the "blue box"
-
Hello, I would like to know how I can get the coordinates of the 8 corners of the "blue box" of a group or component that has been rotated and scaled
I tried to
bounds.corner
orlocal_bounds.corner
but do not work properly for what I need, I have been looking and I could not find the appropriateness.
-
help
-
-
I know you helped me very much, sorry for asking much just I want to learn
-
Check out the source of this plugin that draws edges of the boundingbox: http://forums.sketchucation.com/viewtopic.php?t=29377#p256536
-
@thomthom said:
Check out the source of this plugin that draws edges of the boundingbox: http://forums.sketchucation.com/viewtopic.php?t=29377#p256536
Thom thank you very much.
I know I need this in lines 66 to 68 of your code:definition = self.get_definition(entity) bb = definition.bounds pts = self.bound_points(bb).map { |pt| pt.transform( entity.transformation )
is a shame that is not yet ready to understand these lines clearly, however I will be very useful, very grateful
(sorry for my bad English)
-
Get's the ComponentDefinition of the ComponentInstance or Group
definition = self.get_definition(entity)
Get's the bounds of the definition - note that if you get the bounds of the instance it will be a Boundingbox aligned to the model axis - not the instance axis. Which is why you need to get the definition bounds.
bb = definition.bounds
Now transform the points of the definition boundingbox with the transformation of the instance.
pts = self.bound_points(bb).map { |pt| pt.transform( entity.transformation )
In other words, get the boundingbox of the definition and apply the instance transformation to the coordinates of that boundingbox.
Advertisement