How to receive the size of a line Sketchup rubi

How to receive the size of a line Sketchup rubi

Postby Z11 » Wed Mar 02, 2011 6:02 pm

ruby script draw square
Code: Select all
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 ?
0

Z11 
 

Re: How to receive the size of a line Sketchup rubi

Postby TIG » Wed Mar 02, 2011 6:50 pm

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...
So face.edges.each{|e| puts e.length.to_m} would print the length of the face's edges - in your case 10m ...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: How to receive the size of a line Sketchup rubi

Postby Z11 » Thu Mar 03, 2011 6:30 am

I should draw simply in model a dimensional line.

What method Sketchup to construct a dimensional line
0

Z11 
 

Re: How to receive the size of a line Sketchup rubi

Postby thomthom » Thu Mar 03, 2011 10:44 am

Z11 wrote:What method Sketchup to construct a dimensional line

No access to dimensions via the Ruby API. :(
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: How to receive the size of a line Sketchup rubi

Postby Z11 » Thu Mar 03, 2011 12:07 pm

thomthom wrote:
Z11 wrote:What method Sketchup to construct a dimensional line

No access to dimensions via the Ruby API. :(

Thanks for the answer.
It is a pity.
:(
0

Z11 
 

Re: How to receive the size of a line Sketchup rubi

Postby TIG » Thu Mar 03, 2011 1:01 pm

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... :roll:
0
TIG
User avatar
TIG 
Global Moderator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 8 guests

Visit our sponsors: