Exact, bien vu

Code: Select all
# (c) Florian Foinant-Willig
# sous licence CC-BY-SA 4.0
import math
def main():
doc = App.ActiveDocument
# view, page and vertex from selection
selEx = Gui.Selection.getSelectionEx()
if (not selEx or selEx[0].Object.TypeId != 'TechDraw::DrawViewPart'):
Err("Sélectionnez le point d'origine\n")
return
view = selEx[0].Object
page = [obj for obj in view.InList if obj.TypeId == 'TechDraw::DrawPage'][0]
vertexName = selEx[0].SubElementNames[0]
try:
vertexOrig = view.getVertexBySelection(vertexName)
except:
Err("le point sélectionné est inutilisable.")
return
origX = vertexOrig.X
origY = vertexOrig.Y
def balloonXY(x, y, decimals=3):
df = math.pow(10, decimals)
bln = doc.addObject('TechDraw::DrawViewBalloon', 'XY')
bln.SourceView = view
bln.BubbleShape = u"Inspection"
bln.ViewObject.Fontsize=3
bln.OriginX = x
bln.OriginY = y
bln.X = x + math.copysign(origX, x)
bln.Y = y + math.copysign(origY, y)
page.addView(bln)
dx = x - origX
dy = y - origY
labelX = math.ceil(dx*df)/df
labelY = math.ceil(dy*df)/df
bln.Text = f"{labelX};{labelY}"
doc.recompute()
i = 0
while True:
try:
v = view.getVertexByIndex(i)
i += 1
balloonXY(v.X, v.Y, 2)
except:
break
main()
Comment fais-tu pour sélectionner le point?
Code: Select all
bln.Text = f"X={labelX}\nY={labelY}"
Si tu ne vois pas les points, Il est très possible que l'affichage des "cadres" soit désactivé