Macro Make Arc 3 Points/it: Difference between revisions
Renatorivo (talk | contribs) (Created page with "==Script== L'icona per la barra degli strumenti: 36px") |
(Updating to match new version of source page) |
||
Line 1: | Line 1: | ||
{{Macro/it|Icon=Macro_Make_Arc_3_Points|Name=Macro Make Arc 3 Points|Name/it=Macro Arco da 3 punti|Description=Crea un arco da 3 punti selezionati.|Author=Mario52}} |
{{Macro/it|Icon=Macro_Make_Arc_3_Points|Name=Macro Make Arc 3 Points|Name/it=Macro Arco da 3 punti|Description=Crea un arco da 3 punti selezionati.|Author=Mario52}} |
||
== |
==Description== |
||
This macro creates a arc on 3 selected points. |
|||
==Uso== |
==Uso== |
||
Selezionare 3 punti, o 3 punti di sub-oggetti ed eseguire la macro. |
Selezionare 3 punti, o 3 punti di sub-oggetti ed eseguire la macro. |
||
(PS: It is not required to hold down the Ctrl key) |
|||
==Script== |
==Script== |
||
L'icona per la barra degli strumenti: [[File:Macro Make Arc 3 Points.png|36px]] |
L'icona per la barra degli strumenti: [[File:Macro Make Arc 3 Points.png|36px]] |
||
Line 16: | Line 19: | ||
__author__ = "Mario52" |
__author__ = "Mario52" |
||
__url__ = "http://www.freecadweb.org/index-fr.html" |
__url__ = "http://www.freecadweb.org/index-fr.html" |
||
__version__ = "00. |
__version__ = "00.01" |
||
__date__ = " |
__date__ = "14/07/2016" |
||
selectedObject = FreeCADGui.Selection.getSelection() # select one element |
|||
selectedEdge = FreeCADGui.Selection.getSelectionEx() # select one subElement |
|||
global selected; selected = [] |
|||
try: |
|||
App = FreeCAD |
|||
⚫ | |||
point0 = selectedObject[0].Shape.Point # element |
|||
point1 = selectedObject[1].Shape.Point |
|||
point2 = selectedObject[2].Shape.Point |
|||
except: |
|||
point0 = selectedEdge[0].SubObjects[0].Point # subElement |
|||
point1 = selectedEdge[0].SubObjects[1].Point |
|||
point2 = selectedEdge[0].SubObjects[2].Point |
|||
class SelObserver: |
|||
FreeCAD.Console.PrintMessage(str(point0)+" "+str(point1)+" "+str(point2)) |
|||
print "Create Arc to 3 points ..." |
|||
def addSelection(self,doc,obj,sub,pnt): # Selection |
|||
global selected |
|||
selected.append(pnt) |
|||
if len(selected) == 1: |
|||
print "Point 1 : ",FreeCAD.Vector(selected[0]) |
|||
elif len(selected) == 2: |
|||
print "Point 2 : ",FreeCAD.Vector(selected[1]) |
|||
elif len(selected) == 3: |
|||
print "Point 3 : ",FreeCAD.Vector(selected[2]) |
|||
⚫ | |||
C1 = Part.Arc(FreeCAD.Vector(selected[0]),FreeCAD.Vector(selected[1]),FreeCAD.Vector(selected[2])) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
App.ActiveDocument.ActiveObject.Label = "Arc_3_Points" |
|||
print "Length : ",W.Length |
|||
except Exception: |
|||
print "Three points are collinear or bad selection" |
|||
del selected[:] |
|||
FreeCADGui.Selection.removeObserver(s) |
|||
print "End Make_Arc_3_Points" |
|||
print "_____________________" |
|||
s=SelObserver() |
|||
C1 = Part.Arc(point0,point1,point2) |
|||
FreeCADGui.Selection.addObserver(s) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
except: |
|||
FreeCAD.Console.PrintError("Select tree points or tree subObjects points"+"\n") |
|||
</syntaxhighlight> |
</syntaxhighlight> |
Revision as of 10:11, 14 July 2016
File:Macro Make Arc 3 Points Macro Make Arc 3 Points |
Descrizione |
---|
Crea un arco da 3 punti selezionati. Autore: Mario52 |
Autore |
Mario52 |
Download |
None |
Link |
Raccolta di macro Come installare le macro Personalizzare la toolbar |
Versione macro |
1.0 |
Data ultima modifica |
None |
Versioni di FreeCAD |
None |
Scorciatoia |
Nessuna |
Vedere anche |
Nessuno |
Description
This macro creates a arc on 3 selected points.
Uso
Selezionare 3 punti, o 3 punti di sub-oggetti ed eseguire la macro.
(PS: It is not required to hold down the Ctrl key)
Script
L'icona per la barra degli strumenti:
Macro_Make_Arc_3_Points.FCMacro
# -*- coding: utf-8 -*-
from FreeCAD import Base
__title__ = "Macro_Make_Arc_3_points"
__author__ = "Mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.01"
__date__ = "14/07/2016"
global selected; selected = []
App = FreeCAD
class SelObserver:
print "Create Arc to 3 points ..."
def addSelection(self,doc,obj,sub,pnt): # Selection
global selected
selected.append(pnt)
if len(selected) == 1:
print "Point 1 : ",FreeCAD.Vector(selected[0])
elif len(selected) == 2:
print "Point 2 : ",FreeCAD.Vector(selected[1])
elif len(selected) == 3:
print "Point 3 : ",FreeCAD.Vector(selected[2])
try:
C1 = Part.Arc(FreeCAD.Vector(selected[0]),FreeCAD.Vector(selected[1]),FreeCAD.Vector(selected[2]))
S1 = Part.Shape([C1])
W = Part.Wire(S1.Edges)
Part.show(W)
App.ActiveDocument.ActiveObject.Label = "Arc_3_Points"
print "Length : ",W.Length
except Exception:
print "Three points are collinear or bad selection"
del selected[:]
FreeCADGui.Selection.removeObserver(s)
print "End Make_Arc_3_Points"
print "_____________________"
s=SelObserver()
FreeCADGui.Selection.addObserver(s)