forked from SDMrFeng/NestingForRhino6Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroupMove.py
18 lines (17 loc) · 966 Bytes
/
groupMove.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import rhinoscriptsyntax as rs
from System.Drawing import Color
from pointsReorder import PointsReorder
# tranform group of objects together
def GroupMove(rectOutlineList, objects, objCenter, rotatedAngle, movingCenter):
for objs, rect, center, rotAngle, centerStart in zip(objects, rectOutlineList, objCenter, rotatedAngle, movingCenter):
# rotate everything by center with rotatedAngle
rs.RotateObjects(objs, center, rotAngle)
# find vector to move from obj location to rectangle(obj center to rect center)
boxCenter = rs.CurveAreaCentroid(rect)[0]
moveVector = rs.VectorCreate(boxCenter, center)
# check if object is in box
rectPt = rs.PolylineVertices(rect)
rectPt = PointsReorder(rectPt, 1)
if rs.Distance(rectPt[0], rectPt[1]) > rs.Distance(rectPt[1], rectPt[2]):
rs.RotateObjects(objs, center, 90)
rs.MoveObjects(objs, moveVector)