|
@@ -155,32 +155,34 @@ def tempStoragePosition(x,y,wallIndex,blockIndex):
|
|
result = 1
|
|
result = 1
|
|
for item in positoins:
|
|
for item in positoins:
|
|
# 判断实体是否相交
|
|
# 判断实体是否相交
|
|
- result = isPositionFeasible(positoin,positoins[item])
|
|
|
|
|
|
+ result = isPositionFeasible(positoin,positoins[item],0)
|
|
if(result == 0):
|
|
if(result == 0):
|
|
positoins.clear()
|
|
positoins.clear()
|
|
return result
|
|
return result
|
|
else:
|
|
else:
|
|
# 判断可用区域是否与实体相交
|
|
# 判断可用区域是否与实体相交
|
|
- usePoint = positoin[3]
|
|
|
|
- positoin[0] = usePoint
|
|
|
|
- positoin[1] = positoin[4]
|
|
|
|
- result = isPositionFeasible(positoin,positoins[item])
|
|
|
|
|
|
+ usePosition = (positoin[3],positoin[4])
|
|
|
|
+ result = isPositionFeasible(usePosition,positoins[item],1)
|
|
if(result == 1):
|
|
if(result == 1):
|
|
positoins[len(positoins)] = positoin
|
|
positoins[len(positoins)] = positoin
|
|
return result
|
|
return result
|
|
|
|
|
|
-# 计算位置是否可行
|
|
|
|
-def isPositionFeasible(position1,position2):
|
|
|
|
- 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)
|
|
|
|
- if(math.ceil(position1[0][0]-position2[0][0]) < (position1[1][0]+position2[1][0])/2):
|
|
|
|
- if(math.ceil(position1[0][1]-position2[0][1]) < (position1[1][1]+position2[1][1])/2):
|
|
|
|
- print("sorry! can not put here")
|
|
|
|
|
|
+# 计算位置是否可行type:0 实体 1可用区域
|
|
|
|
+def isPositionFeasible(position1,position2,type):
|
|
|
|
+ areaName = "可用区域"
|
|
|
|
+ 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 = "实体"
|
|
|
|
+ if(abs(position1[0][0]-position2[0][0]) < (position1[1][0]+position2[1][0])/2):
|
|
|
|
+ print(areaName,"begin to check y")
|
|
|
|
+ if(abs(position1[0][1]-position2[0][1]) < (position1[1][1]+position2[1][1])/2):
|
|
|
|
+ print(areaName,"sorry! can not put here","position1=",position1,"position2=",position2)
|
|
return 0
|
|
return 0
|
|
- print("can put here 1")
|
|
|
|
|
|
+ print(areaName,"can put here 1")
|
|
return 1
|
|
return 1
|
|
else:
|
|
else:
|
|
- print("can put here 2")
|
|
|
|
|
|
+ print(areaName,"can put here 2")
|
|
return 1
|
|
return 1
|
|
# printObjects()
|
|
# printObjects()
|
|
# printBlockObjects()
|
|
# printBlockObjects()
|