Relative coordinate input through Ruby

Normally the input to the sketchup from ruby code is in absolute coordinate system.,

Could anyone guide or throw some light, how to input the values in relative coordinate system in ruby.

the below code is absolute coordinate system.

# Default code, use or delete...
mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
#declaration of variables
height = #Height of the cabinet
depth = #depth of the cabinet
wd = #width of the cabinet
thickness #thickness of the panel
# Left side Panel
pt = [0,1,2,3]
pt[0] = [0,0,0]
pt[1] = [thickness,0,0]
pt[2] = [thickness,depth,0]
pt[3] = [0,depth,0]

#creation of face - LH Side panel
face = ent.add_face(pt)
face.pushpull(height, true)
lh_group = ent.add_group face.all_connected "LH Panel"


A point relative to what ?

It would help us help you if you explain a bit more about what you are trying to do.

Hi Dan.,

The point relative to earlier coordinate position. Since in the ruby scripting, we have to give the coordinate in the array, which has been taken by the sketchup in absolute coordinate system for drawing the entities.
Would like sketchup to get the inputs from ruby in terms of relative coordinate system.

Ex: want to draw face of 18mm thk and 550 mm depth.
so the input of coordinates (x,y,z) is something similar to
0,0,0 # starts from origin
18,0,0 # draws a line at x axis of length of 18mm from origin
0,550,0 # draws a line at y axis of length 550 mm from earlier position
-18,0,0 # draws a line at x axis of length -18 mm from earlier position (negative x axis)
0,-550,0 # draws a line at y axis of length - 550 mm from earlier position (negative (y axis)


pt[0] = [0,0,0] 
pt[1] = [thickness,0,0] 
pt[2] = [thickness,depth,0] 
pt[3] = [0,depth,0]
#####pt[0] = [0,0,0]  Edited
pt[0] =, 0, 0)
pt[1] = pt[0] + [thickness,0,0] 
pt[2] = pt[1] + [0,depth,0] 
pt[3] = pt[2] + [-thickness,0,0]
1 Like

Thanks dezmo,

Is there is any other simple solution than this, instead of adding the array

Sure, a lot:



1 Like

Thanks a lot:)