Finding start and end point of a component
-
I need to find the two points of the top line inside an instance of a component.
At first it looked like an easy task, but when I tried actually doing it,
I found out it is not that easy.
sampleTest
I need to run a ruby script and get the [x,y,z] of the points that are measured.can you help pleas?
Thank you.
-
Would need more context to how to you want to determine these points.
Is the object always this configuration?
Is it based on what vertices have dimension objects attached?
Are you trying to make a custom tool to pick the points?
A use-case would be good because the question is currently to ambiguous with too many possible answers.
Also, what have you tried?
-
The component instance has a boundingbox - see the API docs.
bb=obj.bounds
From that you can find its 8 corners.
You can also find things like its min/max/center.
So for example you can find the two points that define one bottom-end edge, find the point mid-way between them, and change its z.value to bb.max.z.
You can repeat this for the other end's vertices.
Then you have two Point3d references with the needed XYZ ?BUT if for example this 'ridge' is not central or perhaps it's even not level, and you want to find its end points 'in the model' then an alternative is to find all edges in the
edges=instance.definition.entities.grep(Sketchup::Edge), then sort through their vertex points for the two highest... and those are then the two points you need [almost] - let's call thempt1andpt2. Find the 'transormation'...tr=instance.transformationand then apply that to the two points (pt1.transform!(tr)andpt2.transform!(tr)) and they will then be the points you want to get the XYZ from... -
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement