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, pt4
How to receive the size of a line Sketchup rubi ?
-
The
len=edge.length
returns the length in inches,len.to_m
returns 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...
Advertisement