Offset in sketchup in ruby


#1

Hi there…
can anyone tell me… how do i offset a face and pushup the border in ruby …?
see example

@num_windows = 4
door_width = 3
door_height = 7
house_height = 9
house_length = (@num_windows + 1) * (door_width + 2) + 2
house_width = 10
roof_height = 2
ents = model.entities

  pl = ents.add_face([0, 0, 0], [0, house_length, 0],
     [house_width, house_length, 0], 
     [house_width, 0, 0], [0, 0, 0])

pl.offset 1
pl.pushpull 1


#2

SketchUp’s Ruby API does not provide an offset method. Many of the high-level GUI tools are available because such manual workflows hardly fit into a scripting environment. Methods in programming languages usually return aa reference to something on which the programmer can apply further actions. However the more complex geometry tools produce a lot of small edges and faces that have different roles. Not having any references to the produced geometry is little helpful and having references to entities where you do not know the order and the relation between them is not more helpful.

It is better to get used to a different paradigm of thinking.

Instead of building up and modifying geometry, compute the final positions of vertices using vector math and generate thee needed faces.

Offset works like that you compute a line (point and vector) parallel to each edge’s line and then intersect lines from neighboring edges to get the position of the new corner vertex for the offsetted edges.


#3

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.