Help on scale
-
Hi,
I use the following code to draw a r=100 cyclinder. With the SketchUp runing in Archi mm template, what I got is a r=5080 cyclinder which is 25.4 times bigger. Thought it is in inch.
I was wondering should I specify what template to use in my code? If so, how to do that?
Thanks in advance
Cean
def my_cylinder x=0 y=0 z=0 idir=1 r=100 h=500 model = Sketchup.active_model $entities=model.entities p1 = Geom;;Point3d.new(x,y,z) vector= Geom;;Vector3d.new(1,0,10) circleI = $entities.add_circle p1, vector, r base = $entities.add_face circleI base.pushpull h end #def hw_cylinder UI.menu("Plugins").add_item("my") { my_cylinder }
-
Thanks Dan. So, I was right. It was in inch.
It's a bit hard to understand the API:
"
The mm method is used to convert a number to millimeters.It returns a Length value which is the same length as the given value. For example len = 25.4.mm returns 1 inch. Returns: mm a value in millimeters if successful value = 10 mm = value.mm
"
The result is the same length but with a different unit.
-
In the API a 'raw' number is always taken to be in inches when in the context of a 'length' so
500
is taken as 500".
To get it to be taken as 'mm' you write it as500.mm
[or50.cm
if you prefer 'cm' etc...]For 'angles' a 'raw' number is assumed to be 'radians' - but you can use
90.degrees
to set an angle you can readily understand... otherwise it'd have to be expressed as the more awkwardMath::PI/2
to be the equivalent in radians! -
-
Yes.. Sketchup and the Ruby API use Inches internally.
The "User Units" are only for display in dialogs.
-
Instead of writing every 'mm' in code, I thought it's more easy to draw as it is and scale back at the end.
That also cleared me from inserting a DWG file, need scale back to get the dimensions show in right number.
Thanks.
-
@shirazbj said:
Instead of writing every 'mm' in code, I thought it's more easy to draw as it is and scale back at the end. That also cleared me from inserting a DWG file, need scale back to get the dimensions show in right number.
Thanks.An imported DWG will use whatever units it has set in the import 'options' dialog opened from the main DWG import browser, So you can rely on that to always be correct.
Advertisement