@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

But what I can see is, there is no need to blame sub(groups or components), yet. Your plugin doesn't even work for two simple intersecting components. "def1=solid1.entities.parent" finds the definition of groups, not components. Component instances don't have the method for "entities". It's the component definition that has that method. That's why the error message saids undefine method. It should be something like "def1 = componentInstance.definition" for components.


