|
@@ -37,11 +37,44 @@ def printTheTypeObject(type):
|
|
|
#按类型查找出所有某种图元
|
|
|
for text in acad.iter_objects(type):
|
|
|
conf.myprint(text.name)
|
|
|
-def addCurrentScoreToScores():
|
|
|
+# 保存正确方案的分数
|
|
|
+def addCurrentScoreToScores(moveResult):
|
|
|
temp = []
|
|
|
for item in currentScore:
|
|
|
temp.append(item)
|
|
|
- scores.append(temp)
|
|
|
+ if moveResult > 0:
|
|
|
+ scores.append(temp)
|
|
|
+# 根据scores给方案打分
|
|
|
+def scoreModule():
|
|
|
+ moduleScores = []
|
|
|
+ tempLength = len(scores[0])-1
|
|
|
+ # socres中目前存储 位置、入口雷达半径、入口与模块连线长度、模块间连线长度,入口与模块间撞点,模块与模块间撞点
|
|
|
+ maxs = [0]*tempLength
|
|
|
+ mins = [0]*tempLength
|
|
|
+ detarLength = [0]*tempLength
|
|
|
+ fullSocres = [10,10,10,5,5]
|
|
|
+ fullSocresDirect = [1,-1,-1,-1,-1]
|
|
|
+ # 先获取最大值和最小值
|
|
|
+ for item in scores:
|
|
|
+ for itemIndex in range(tempLength):
|
|
|
+ if item[itemIndex+1]>maxs[itemIndex]:
|
|
|
+ maxs.pop(itemIndex)
|
|
|
+ maxs.insert(itemIndex,item[itemIndex+1])
|
|
|
+ elif item[itemIndex+1]<mins[itemIndex]:
|
|
|
+ mins.pop(itemIndex)
|
|
|
+ mins.insert(itemIndex,item[itemIndex+1])
|
|
|
+ for i in range(tempLength):
|
|
|
+ detarLength[i] = maxs[i]-min(i)
|
|
|
+ templateScore = []
|
|
|
+ for item in scores:
|
|
|
+ templateScore.append(item[0])
|
|
|
+ for itemIndex in range(tempLength):
|
|
|
+ if(fullSocresDirect[itemIndex] == 1):
|
|
|
+ templateScore.append((item[itemIndex+1]-mins[itemIndex])*fullSocres[itemIndex]/detarLength[itemIndex])
|
|
|
+ else:
|
|
|
+ templateScore.append(fullSocres[itemIndex] - (item[itemIndex+1]-mins[itemIndex])*fullSocres[itemIndex]/detarLength[itemIndex])
|
|
|
+ moduleScores.append(templateScore)
|
|
|
+ conf.myprint("moduleScores=",moduleScores)
|
|
|
# 方案不合适返回0,否则返回方案评分
|
|
|
def moveBlockReference(position):
|
|
|
positoins.clear()
|
|
@@ -60,7 +93,7 @@ def moveBlockReference(position):
|
|
|
if(result == 0):
|
|
|
moveResult = result
|
|
|
conf.myprint("currentScore size =",len(currentScore),",scores size=",len(scores))
|
|
|
- addCurrentScoreToScores()
|
|
|
+ addCurrentScoreToScores(moveResult)
|
|
|
conf.myprint("scores=",scores)
|
|
|
for blockReference in needDeleteBlockReferences:
|
|
|
blockReference.delete()
|
|
@@ -115,7 +148,7 @@ def moveBlockReferenceWithNewIndex(position,moduleIndex):
|
|
|
if(result == 0):
|
|
|
moveResult = result
|
|
|
conf.myprint("currentScore size =",len(currentScore),",scores size=",len(scores))
|
|
|
- addCurrentScoreToScores()
|
|
|
+ addCurrentScoreToScores(moveResult)
|
|
|
conf.myprint("scores=",scores)
|
|
|
for blockReference in needDeleteBlockReferences:
|
|
|
blockReference.delete()
|
|
@@ -151,7 +184,7 @@ def isWorkable(position):
|
|
|
return 1
|
|
|
# 获取组件的四点坐标
|
|
|
def getCenterPoint(wallIndex, x, y, blockIndex):
|
|
|
- height = conf.moduleLengths[blockIndex];
|
|
|
+ height = conf.moduleLengths[blockIndex]-conf.moduleLengthOffsets[blockIndex];
|
|
|
width = conf.moduleHeights[blockIndex];
|
|
|
useHeight = conf.moduleUseLength[blockIndex]
|
|
|
useWidth = conf.humenLenght
|
|
@@ -281,7 +314,7 @@ def getDistince(point1,point2):
|
|
|
detarY = point1[1]-point2[1]
|
|
|
return math.sqrt(detarX**2+detarY**2)
|
|
|
def getDoorBeginPoint():
|
|
|
- return ((conf.doorAlign[0]+conf.doorLength+conf.doorAlign[1])/2,0)
|
|
|
+ return (conf.doorAlign[0]+conf.doorLength/2,0)
|
|
|
def drawLines(includePoints):
|
|
|
lineLength = 0;
|
|
|
if(len(includePoints)>1):
|