|
|
@ -69,12 +69,14 @@ class AHB_View_Annotate: |
|
|
|
print(balloon.Name + " references missing object " + ref_name + ", removing balloon") |
|
|
|
print(balloon.Name + " references missing object " + ref_name + ", removing balloon") |
|
|
|
doc.removeObject(balloon.Name) |
|
|
|
doc.removeObject(balloon.Name) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
balloonsCreated = [] |
|
|
|
for partLink in view.XSource: |
|
|
|
for partLink in view.XSource: |
|
|
|
balloonsCreated = workbench.techDrawExtensions.add_or_update_balloon(view, partLink, '') |
|
|
|
balloonsCreated.extend(workbench.techDrawExtensions.add_or_update_balloon(view, partLink, '')) |
|
|
|
if len(balloonsCreated) > 0: |
|
|
|
|
|
|
|
regroupedBalloons = self.RegroupNearestSimilarBalloons(balloonsCreated) |
|
|
|
if len(balloonsCreated) > 0: |
|
|
|
self.PlaceBalloonsInCircle(regroupedBalloons) |
|
|
|
regroupedBalloons = self.RegroupNearestSimilarBalloons(balloonsCreated) |
|
|
|
#self.PlaceBalloonsInCircle(balloonsCreated) |
|
|
|
#self.PlaceBalloonsInCircle(regroupedBalloons) |
|
|
|
|
|
|
|
self.PlaceBalloonsInCircle(balloonsCreated) |
|
|
|
|
|
|
|
|
|
|
|
workbench.techDrawExtensions.refreshOverlays(page) |
|
|
|
workbench.techDrawExtensions.refreshOverlays(page) |
|
|
|
|
|
|
|
|
|
|
@ -86,13 +88,13 @@ class AHB_View_Annotate: |
|
|
|
realBalloon = balloon[0] if type(balloon) is list else balloon |
|
|
|
realBalloon = balloon[0] if type(balloon) is list else balloon |
|
|
|
totalX = totalX + int(realBalloon.OriginX) |
|
|
|
totalX = totalX + int(realBalloon.OriginX) |
|
|
|
totalY = totalY + int(realBalloon.OriginY) |
|
|
|
totalY = totalY + int(realBalloon.OriginY) |
|
|
|
return App.Base.Vector2d(totalX / len(balloons), totalY / len(balloons)) |
|
|
|
return App.Vector(totalX / len(balloons), totalY / len(balloons)) |
|
|
|
|
|
|
|
|
|
|
|
def IsSimilarBalloonNear(self, balloonA, balloonB): |
|
|
|
def IsSimilarBalloonNear(self, balloonA, balloonB): |
|
|
|
MAX_DISTANCE_BETWEEN_REGROUPED_BALLOONS = 50 |
|
|
|
MAX_DISTANCE_BETWEEN_REGROUPED_BALLOONS = 50 |
|
|
|
if balloonA.Text == balloonB.Text: |
|
|
|
if balloonA.Text == balloonB.Text: |
|
|
|
pos = App.Base.Vector2d(balloonA.OriginX, balloonA.OriginY) |
|
|
|
pos = App.Vector(balloonA.OriginX, balloonA.OriginY) |
|
|
|
dist = pos.distance(App.Base.Vector2d(balloonB.OriginX, balloonB.OriginY)) |
|
|
|
dist = pos.distanceToPoint(App.Vector(balloonB.OriginX, balloonB.OriginY)) |
|
|
|
return dist < MAX_DISTANCE_BETWEEN_REGROUPED_BALLOONS |
|
|
|
return dist < MAX_DISTANCE_BETWEEN_REGROUPED_BALLOONS |
|
|
|
else: |
|
|
|
else: |
|
|
|
return False |
|
|
|
return False |
|
|
@ -119,13 +121,13 @@ class AHB_View_Annotate: |
|
|
|
for i in range(nbBalloons): |
|
|
|
for i in range(nbBalloons): |
|
|
|
xPos = round(center.x + 600 * math.cos(balloonPosStep * i)) |
|
|
|
xPos = round(center.x + 600 * math.cos(balloonPosStep * i)) |
|
|
|
yPos = round(center.y + 600 * math.sin(balloonPosStep * i)) |
|
|
|
yPos = round(center.y + 600 * math.sin(balloonPosStep * i)) |
|
|
|
balloonPos = App.Base.Vector2d(xPos, yPos) |
|
|
|
balloonPos = App.Vector(xPos, yPos) |
|
|
|
# Find nearest arrow to avoid arrow crossing each other |
|
|
|
# Find nearest arrow to avoid arrow crossing each other |
|
|
|
smallestDistance = 0 |
|
|
|
smallestDistance = 0 |
|
|
|
balloonToUse = None |
|
|
|
balloonToUse = None |
|
|
|
for balloon in balloons: |
|
|
|
for balloon in balloons: |
|
|
|
realBalloon = balloon[0] if type(balloon) is list else balloon |
|
|
|
realBalloon = balloon[0] if type(balloon) is list else balloon |
|
|
|
dist = balloonPos.distance(App.Base.Vector2d(realBalloon.OriginX, realBalloon.OriginY)) |
|
|
|
dist = balloonPos.distanceToPoint(App.Vector(realBalloon.OriginX, realBalloon.OriginY)) |
|
|
|
if smallestDistance == 0 or dist < smallestDistance: |
|
|
|
if smallestDistance == 0 or dist < smallestDistance: |
|
|
|
smallestDistance = dist |
|
|
|
smallestDistance = dist |
|
|
|
balloonToUse = balloon |
|
|
|
balloonToUse = balloon |
|
|
|