Youen
2 years ago
2 changed files with 40 additions and 12 deletions
@ -1,17 +1,42 @@ |
|||||||
doc = App.activeDocument() |
import FreeCADGui as Gui |
||||||
view = doc.getObject('View') |
import FreeCAD as App |
||||||
|
|
||||||
if len(Gui.Selection.getSelection()) != 1: |
class AHB_View_Annotate: |
||||||
raise Exception("Veuillez sélectionner exactement un objet") |
def GetResources(self): |
||||||
|
return {"MenuText": "View/Annotate", |
||||||
|
"ToolTip": "Annotates a TechDraw view with object names", |
||||||
|
"Pixmap": "" |
||||||
|
} |
||||||
|
|
||||||
object = Gui.Selection.getSelection()[0] |
def IsActive(self): |
||||||
|
return True |
||||||
|
|
||||||
# Get object center in view space |
def Activated(self): |
||||||
objectCenterWorld = object.LinkPlacement.Matrix.multiply(object.LinkedObject.Shape.CenterOfGravity) |
doc = App.activeDocument() |
||||||
vertId = view.makeCosmeticVertex3d(objectCenterWorld) |
page = doc.getObject('Page') |
||||||
vert = view.getCosmeticVertex(vertId) |
view = page.Views[0] |
||||||
objectCenterView = vert.Point |
|
||||||
view.removeCosmeticVertex(vertId) |
|
||||||
|
|
||||||
# Create Balloon |
if len(Gui.Selection.getSelection()) != 1: |
||||||
|
raise Exception("Veuillez sélectionner exactement un objet") |
||||||
|
|
||||||
|
object = Gui.Selection.getSelection()[0] |
||||||
|
|
||||||
|
# Get object center in view space |
||||||
|
objectCenterWorld = object.LinkPlacement.Matrix.multiply(object.LinkedObject.Shape.CenterOfGravity) |
||||||
|
vertId = view.makeCosmeticVertex3d(objectCenterWorld) |
||||||
|
vert = view.getCosmeticVertex(vertId) |
||||||
|
objectCenterView = vert.Point |
||||||
|
view.removeCosmeticVertex(vertId) |
||||||
|
|
||||||
|
# Create Balloon |
||||||
|
balloon = App.ActiveDocument.addObject("TechDraw::DrawViewBalloon", "Balloon") |
||||||
|
balloon.SourceView = view |
||||||
|
balloon.OriginX = objectCenterView.x |
||||||
|
balloon.OriginY = objectCenterView.y |
||||||
|
balloon.Text = "1" |
||||||
|
balloon.Y = objectCenterView.x + 20 |
||||||
|
balloon.X = objectCenterView.y + 20 |
||||||
|
page.addView(balloon) |
||||||
|
|
||||||
|
from ahb_command import AHB_CommandWrapper |
||||||
|
AHB_CommandWrapper.addGuiCommand('AHB_view_annotate', AHB_View_Annotate()) |
||||||
|
Loading…
Reference in new issue