Is there a way to prompt for the average of the objects with the move command? I’m trying to automate via python and want to achieve this for selected objects:
Rhino.RhinoApp.RunScript(“_selall " “_move” “average of objects” “2000,2000,20” " Enter”, False)
Note the “average of objects” is a mouse command. Is there a means to select a point in the objects / middle of objects or equivalent?
See my reply to your other post… Here is some code using rhinoscriptsyntax:
import rhinoscriptsyntax as rs
#get all "normal" selectable objects (not ones that are locked or hidden)
objs=rs.NormalObjects()
if objs:
bb=rs.BoundingBox(objs)
#returns the 8 corner points of the bounding box in a list
#you can get the center by averaging the diagonal corner points
bb_center=(bb[0]+bb[6])/2
#create a point (you can also use rs.GetPoint() to ask user for a point)
#coerce3dpoint() can make a point object from a list of 3 numbers
target=rs.coerce3dpoint([2000,2000,20])
#move the objects from the center to a new point
#MoveObjects() wants a translation *vector*, which is typically endpt-startpt
rs.MoveObjects(objs,target-bb_center)
If you really want to program with native Rhino commands, you can also try doing it with rs.Command(), but I recommend trying to work with rhinoscriptsyntax commands to learn. One thing you can’t easily do with just calling Rhino commands is get the bounding box of the selected objects, for example.