@jolran said:
I'm getting it to work almost.
@unknownuser said:
vector.length=20.0
The copied distance will always be desired length on the vectors line, but depending on the angle of diagonal the edges will not be same distance apart. So I guess I will have to do another compensation? Or is there some Quick fix like the last one(thank you TIG)
I'm guessing will have to do a comparison between Diagonal, user(desired angle, here 45 deg) and somehow
compensate the copy distance for that. Boy this is hard..
Here is a example of finding the normal vector of a grouped line, using a cross product. The cross product of two vectors prduces a third vector, at right angles to the original ones.
model = Sketchup.active_model
ent = model.entities
sel = model.selection
line = ent.add_line [3,3,0], [5,5,0]
group = ent.add_group line
v1 = line.vertices[0].position.transform(group.transformation)
v2 = line.vertices[1].position.transform(group.transformation)
v = v1.vector_to v2
# I used z vector as 2nd vector, but can try "face.normal" for general case
normal_vec = v.cross([0,0,1]) #cross product to get normal vector
pt = [0,0,0]
demo = ent.add_line pt, pt.offset(normal_vec) #drew demo line representing normal vector
demo.material = 'red'
n = normal_vec
n.length = 1
g1 = group.copy
g1.transform! n # moved copied group using normal vector