Set Vertex Position?
-
Hello!
I was trying to manually set the Position of single Vertices.
I was trying something likeedge.start.position = Geom;;Point3d.new (10,20,30)
but you cannot set the position on a vertex that way....
any ideas?
-
You've returned a point doing that. The end [or start] of an edge is returned as a vertex anyway. You need to 'transform' that vertex to move the the end/start of an edge...
model=Sketchup.active_model ents=model.active_entities newendpoint=[12,34,56] ### this is a new point end=edge.end ### this is a vertex ents.transform_entities(newendpoint,end) ### this moves the 'end' vertex
this snippet will move the edge's start-vertex to newendpoint...
-
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 crashesI 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
-
-
I think you'd better use Transform by vector, since each vertex would have a different transformation. So you create a list of vectors for each vertex between the original point and the rounded points.
Note that this may not work fine as Transforming elements in Sketchup follows the same rules as in the User Interface, allowing or not the transformation based on privileged direction.
In my opinion, just rounding the coordinates of vertex will destroy the planarity of faces if you had some in your model.
-
You are right, It destroys my faces... well it splits them into triangles but they stay planar... so I just have to delete the created lines manually. I can live with that
But the bad thing is that rounding coordinates does not solve the problem I have...
It seems to be a known bug! It happens with complex models when you often change the axes with the axis tool.I need some way to re-align edges to the axes (even their start and end-points are (almost) exactly on one axis, they are not recognised so)
Advertisement