How to move a group?
-
i want to move a selected group,and select the group with the code
model = Sketchup.active_model entities = model.entities selectgroup = model.selection select_entity = selectgroup[0]
how to move it to other location?
-
Use a
Geom::Transformation
- either.new
to a point or.translation
by a vector...
http://code.google.com/apis/sketchup/docs/ourdoc/transformation.html -
@mcdull said:
i want to move a selected group,and select the group with the code
model = Sketchup.active_model > entities = model.entities > selectgroup = model.selection > select_entity = selectgroup[0]
how to move it to other location?
You are really creating more alias than you need. Actually you could do this script with just one line. If your never going to call an alias more than once why waste the CPU cycles?
Sketchup.active_model.selection[0].transform!(Geom;;Transformation.translation([0,0,50]))
...but you may want to popup a dialog if the user forgot to select something or the selected "something" is not a group or component, or you may want the user to input an amount to move etc..! The script rolling is left as an exercise for the reader
-
@jessejames said:
@mcdull said:
i want to move a selected group,and select the group with the code
model = Sketchup.active_model > > entities = model.entities > > selectgroup = model.selection > > select_entity = selectgroup[0]
how to move it to other location?
You are really creating more alias than you need. Actually you could do this script with just one line. If your never going to call an alias more than once why waste the CPU cycles?
> Sketchup.active_model.selection[0].transform!(Geom;;Transformation.translation([0,0,50]))
...but you may want to popup a dialog if the user forgot to select something or the selected "something" is not a group or component, or you may want the user to input an amount to move etc..! The script rolling is left as an exercise for the reader
i have tried this method
Sketchup.active_model.selection[0].move!
before,i want to the group move from the boundingbox center the other point,and then this point turn to be the boundingbox center of the group's bounding box.according the above method,the group move form one corner edge to the point,and that target point turn to be the corner,not the center...
-
the move! method moves it only by the vector you provide, it dooes not care about boundinb boxes and points. It just uses a direction and length (vector). So what you need to look at is how you are creating your vector. Try finding the point that is the center of your box. Then find the point you want to move to. Then find the vector from one point to the other. Then use that vector to do your move. Then it will move the correct amount and direction.
Show more of your code, specifically the part where you are finding the vector, to get more precise feedback,
Chris
-
thank uοΌi have got it...
Advertisement