|
@@ -30,12 +30,19 @@ def printTheTypeObject(type):
|
|
|
conf.myprint(text.name)
|
|
|
def moveBlockReference(position):
|
|
|
positoins.clear()
|
|
|
+ useAreaPositions.clear()
|
|
|
conf.myprint(conf.moduleLengths)
|
|
|
+ moveResult = 1
|
|
|
for blockReference in acad.iter_objects("BlockReference"):
|
|
|
conf.myprint(blockReference.name)
|
|
|
for item in conf.names:
|
|
|
if(blockReference.name == item):
|
|
|
- moveBlockReferenceToWall(blockReference,position[conf.names.index(item)])
|
|
|
+ currentPosition[0] = position
|
|
|
+ currentPosition[1] = conf.names.index(item)
|
|
|
+ result = moveBlockReferenceToWall(blockReference,position[conf.names.index(item)])
|
|
|
+ if(result == 0):
|
|
|
+ moveResult = result
|
|
|
+ return moveResult
|
|
|
def moveBlockReferenceToWall(blockReference,wallIndex):
|
|
|
wallIndex = int(wallIndex)
|
|
|
blockReference.rotate(APoint(blockReference.InsertionPoint),0.5*(wallIndex+1)*math.pi)
|
|
@@ -56,9 +63,14 @@ def moveBlockReferenceToWall(blockReference,wallIndex):
|
|
|
checkPositionIntersect = tempStoragePosition(blockReference.InsertionPoint[0],blockReference.InsertionPoint[1],wallIndex,blockIndex)
|
|
|
if(checkPositionIntersect == 0):
|
|
|
conf.myprint("wallIndex=",wallIndex,blockReference.name," not walkable......")
|
|
|
+ return 0
|
|
|
+ else:
|
|
|
+ return 1
|
|
|
# 根据新顺序移动模块
|
|
|
def moveBlockReferenceWithNewIndex(position,moduleIndex):
|
|
|
+ moveResult = 1
|
|
|
positoins.clear()
|
|
|
+ useAreaPositions.clear()
|
|
|
conf.myprint(conf.moduleLengths)
|
|
|
blockReferences = []
|
|
|
for blockReference in acad.iter_objects("BlockReference"):
|
|
@@ -70,7 +82,10 @@ def moveBlockReferenceWithNewIndex(position,moduleIndex):
|
|
|
currentPosition[0] = position
|
|
|
currentPosition[1] = moduleIndex
|
|
|
currentPosition[2] = moduleIndex.index(index)
|
|
|
- moveBlockReferenceToWall(blockReferences[index],position[moduleIndex.index(index)])
|
|
|
+ result = moveBlockReferenceToWall(blockReferences[index],position[moduleIndex.index(index)])
|
|
|
+ if(result == 0):
|
|
|
+ moveResult = result
|
|
|
+ return moveResult
|
|
|
# 重置已使用墙的长度
|
|
|
def resetConfUsed():
|
|
|
conf.roomUsedLengths=[1200,0,0,1000]
|
|
@@ -157,18 +172,22 @@ def drawPointCircle(points):
|
|
|
# 从插入点开始顺时针记录已摆放的组件
|
|
|
def tempStoragePosition(x,y,wallIndex,blockIndex):
|
|
|
positoin = getCenterPoint(wallIndex, x, y, blockIndex);
|
|
|
+ usePosition = (positoin[3],positoin[4])
|
|
|
result = 1
|
|
|
for item in positoins:
|
|
|
# 判断实体是否相交
|
|
|
result = isPositionFeasible(positoin,positoins[item],0)
|
|
|
if(result == 1):
|
|
|
- # 判断可用区域是否与实体相交
|
|
|
- usePosition = (positoin[3],positoin[4])
|
|
|
- result = isPositionFeasible(usePosition,positoins[item],1)
|
|
|
+ # 判断当前实体是否与已摆放的可用区域相交
|
|
|
+ result = isPositionFeasible(positoin,useAreaPositions[item],1)
|
|
|
+ if(result == 1):
|
|
|
+ # 判断可用区域是否与实体相交
|
|
|
+ result = isPositionFeasible(usePosition,positoins[item],1)
|
|
|
if(result == 0):
|
|
|
return result
|
|
|
if(result == 1):
|
|
|
positoins[len(positoins)] = positoin
|
|
|
+ useAreaPositions[len(useAreaPositions)] = usePosition
|
|
|
return result
|
|
|
|
|
|
# 计算位置是否可行type:0 实体 1可用区域
|
|
@@ -177,7 +196,7 @@ def isPositionFeasible(position1,position2,type):
|
|
|
if type==0:
|
|
|
acad.model.AddLine(APoint(position1[0][0],position1[0][1]),APoint(position2[0][0],position2[0][1]))
|
|
|
acad.model.AddCircle(APoint(position1[0][0],position1[0][1]), 50)
|
|
|
- areaName = "实体"
|
|
|
+ areaName = "实体区域"
|
|
|
if(abs(position1[0][0]-position2[0][0]) < (position1[1][0]+position2[1][0])/2 and abs(position1[0][1]-position2[0][1]) < (position1[1][1]+position2[1][1])/2):
|
|
|
conf.myprint(areaName,"sorry! can not put here",currentPosition,"position1=",position1,"position2=",position2)
|
|
|
return 0
|
|
@@ -192,4 +211,4 @@ def isPositionFeasible(position1,position2,type):
|
|
|
# a=[0,1,2]
|
|
|
# moveBlockReferenceWithNewIndex('001',a)
|
|
|
# conf.myprint(isWorkable('222'))
|
|
|
-getCenterPoint(3,4162.85,0,2)
|
|
|
+# getCenterPoint(3,4162.85,0,2)
|