Thank you a lot!
This works great...
except two things
-
transforming with [12,34,56] will not set the position to these coordinates, but shift it by that vector. so if you want to set the position you will first have to calculate the offset and use this as the transformation
-
if i'm shifting vertices inside a component things get weired... sketchup crashes all the time.
What I actually want to do is round the coordinates of every Vertex in the whole model
For a reason I dont know have all my edges been shifted (I often rotated the model in very small angles, this was nessecary to simplify modelling)
So many edges lost their alignment on the axes and I cannot get them in the right place
If I zoom in very close on corners I can see that the lines are slightly not on the right place. its just that I can see a small gap before I zoom into the Front clipping plane - so very small.
My Ides war to round every Coordinate to an Integer value...
I was never scripting sketchup before but I wanted to try this
here's my code:
def execute_test
entities = Sketchup.active_model.entities
#Loop through all selected vertices
Sketchup.active_model.selection.each do |ent|
if(ent.kind_of? Sketchup;;Edge)
print ent.to_s+"\n"
#remember start and end vertex
es = ent.start.position
ee = ent.end.position
#transform each vertex
entities.transform_entities (Geom;;Point3d.new(es.x.round, es.y.round, es.z.round)-es), ent.start
entities.transform_entities (Geom;;Point3d.new(ee.x.round, ee.y.round, ee.z.round)-ee), ent.end
end
end
end
I substract the real vertex position from the rounded position to get the offset I need to align it
I think I need some help Sketchup crashes when I apply this inside a component with everything selected...
some of the vertices are shifted far away, when I deselect them Sketchup crashes
I attached the broken model.
try setting edge color to "by axis". you'll notice that many edges are not aligned to the axes and theres nomthing you can do about it (i tried rotating the model, using the axis tool etc...
thanks for every tip!!
Daniel
This is the model that is broken for some reason....