How to receive the size of a line Sketchup rubi
-
ruby script draw square
model = Sketchup.active_model entities = model.entities pt1 = [0.m, 0.m, 0.m] pt2 = [10.m, 0.m, 0.m] pt3 = [10.m, 10.m, 0.m] pt4 = [0.m, 10.m, 0.m] new_face = entities.add_face pt1, pt2, pt3, pt4How to receive the size of a line Sketchup rubi ?
-
The
len=edge.lengthreturns the length in inches,len.to_mreturns it in meters.
In your example you know the length from the code but the len= method works for any edge...
Soface.edges.each{|e| puts e.length.to_m}would print the length of the face's edges - in your case 10m ... -
I should draw simply in model a dimensional line.
What method Sketchup to construct a dimensional line
-
@z11 said:
What method Sketchup to construct a dimensional line
No access to dimensions via the Ruby API.

-
-
You CAN sort of fudge it... make a separate SKP file containing a dimension 1" long and 1" offset.
Then in code load it as a component into your SKP.
Add an instance at a point and scale it in the X to match the length to another point and in the Y for the offset needed.
You also need to transform-rotate it so that it aligns with the vector of the two points etc...
When done you can explode the dim-component instance back into a plain dimension.
An dims added this way will ever be linked to an edge or vertex as in a manually added one...
You could perhaps include a 1" long edge in the dim-component that the dim refers to... and if that then replaced the original line below it when exploded it might keep some linking ?
It's better than nothing... but only just...
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