From 90f3402437dc44d917bb882c8df18f507718ad26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9as=20Livet?= Date: Fri, 16 Dec 2022 12:20:53 +0100 Subject: [PATCH] anotation grouping : various fix --- ahb_cmd_view_annotate.py | 18 +++++++++++------- ahb_techdraw_extensions.py | 6 ++++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ahb_cmd_view_annotate.py b/ahb_cmd_view_annotate.py index a34d33e..90d8641 100644 --- a/ahb_cmd_view_annotate.py +++ b/ahb_cmd_view_annotate.py @@ -12,7 +12,7 @@ class AHB_View_Annotate: } def IsActive(self): - return ahb_utils.getCurrentView() is not None + return True def Activated(self): workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench @@ -70,13 +70,15 @@ class AHB_View_Annotate: doc.removeObject(balloon.Name) for partLink in view.XSource: - workbench.techDrawExtensions.add_or_update_balloon(view, partLink, '') - + balloonsCreated = workbench.techDrawExtensions.add_or_update_balloon(view, partLink, '') + if len(balloonsCreated) > 0: + regroupedBalloons = self.RegroupNearestSimilarBalloons(balloonsCreated) + self.PlaceBalloonsInCircle(regroupedBalloons) + #self.PlaceBalloonsInCircle(balloonsCreated) + workbench.techDrawExtensions.refreshOverlays(page) - regroupedBalloons = self.RegroupNearestSimilarBalloons(balloonsCreated) - self.PlaceBalloonsInCircle(regroupedBalloons) - + def CalculatePointsCenter(self, balloons): totalX = 0 totalY = 0 @@ -115,7 +117,9 @@ class AHB_View_Annotate: nbBalloons = len(balloons) balloonPosStep = (math.pi * 2) / nbBalloons for i in range(nbBalloons): - balloonPos = App.Base.Vector2d(center.x + 600 * math.cos(balloonPosStep * i), center.y + 600 * math.sin(balloonPosStep * i)) + xPos = round(center.x + 600 * math.cos(balloonPosStep * i)) + yPos = round(center.y + 600 * math.sin(balloonPosStep * i)) + balloonPos = App.Base.Vector2d(xPos, yPos) # Find nearest arrow to avoid arrow crossing each other smallestDistance = 0 balloonToUse = None diff --git a/ahb_techdraw_extensions.py b/ahb_techdraw_extensions.py index 0d9acd6..7336d69 100644 --- a/ahb_techdraw_extensions.py +++ b/ahb_techdraw_extensions.py @@ -499,12 +499,14 @@ class TechDrawExtensions: self.updateBalloon(balloon) - balloonsCreated.append(balloon) - if not self.isNewPartInView(view, part): balloon.ViewObject.Visibility = False + else: + balloonsCreated.append(balloon) else: self.updateBalloon(balloon) + + return balloonsCreated def updateBalloon(self, balloon): workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench