Part Part2DObject/it: Difference between revisions

From FreeCAD Documentation
(Created page with "{{Emphasis|Vedere anche:}} Script di base per FreeCAD, e script di oggetti.")
(Updating to match new version of source page)
(9 intermediate revisions by 2 users not shown)
Line 5: Line 5:
[[File:Tree_Part2D.svg|32px]]
[[File:Tree_Part2D.svg|32px]]


<div class="mw-translate-fuzzy">
Un [[Part Part2DObject/it|Part Part2DObject]], o formalmente un {{incode|Part::Part2DObject}}, è un elemento semplice a cui è associato un {{incode|Shape}} topologico che può essere visualizzato nella [[3D view/it|Vista 3D]].
Un [[Part Part2DObject/it|Part Part2DObject]], o formalmente un {{incode|Part::Part2DObject}}, è un elemento semplice a cui è associato un {{incode|Shape}} topologico che può essere visualizzato nella [[3D view/it|Vista 3D]].
</div>


{{Incode|Part::Part2DObject}} è derivato da una [[Part Feature/it|Part Feature]], ma è specializzato nella geometria 2D, dato che la sua forma è posizionata su un piano. Il piano è definito dalla sua proprietà {{PropertyData|Placement}} (posizione, normale e rotazione). Tuttavia, il piano può anche essere definito supportando elementi geometrici, come il piano creato da tre vertici arbitrari o una faccia di un corpo solido.
{{Incode|Part::Part2DObject}} è derivato da una [[Part Feature/it|Part Feature]], ma è specializzato nella geometria 2D, dato che la sua forma è posizionata su un piano. Il piano è definito dalla sua proprietà {{PropertyData|Placement}} (posizione, normale e rotazione). Tuttavia, il piano può anche essere definito supportando elementi geometrici, come il piano creato da tre vertici arbitrari o una faccia di un corpo solido.
Line 11: Line 13:
[[File:FreeCAD_core_objects.svg|800px]]
[[File:FreeCAD_core_objects.svg|800px]]


<div class="mw-translate-fuzzy">
{{Caption|Diagramma semplificato delle relazioni tra gli oggetti principali in FreeCAD. La classe {{incode|Part::Part2DObject}} è specializzata per le forme 2D, quindi è la classe di base per gli oggetti planari creati con gli ambienti Draft e Sketcher.}}
{{Caption|Diagramma semplificato delle relazioni tra gli oggetti principali in FreeCAD. La classe {{incode|Part::Part2DObject}} è specializzata per le forme 2D, quindi è la classe di base per gli oggetti planari creati con gli ambienti Draft e Sketcher.}}
</div>


<div class="mw-translate-fuzzy">
== Utilizzo ==
== Utilizzo ==
</div>


[[Part Part2DObject|Part Part2DObject]] è un oggetto interno, quindi non può essere creato dall'interfaccia grafica, ma solo dalla [[Python console/it|console Python]] come descritto nel paragrafo [[Part_Part2DObject/it#Script|Script]].
[[Part Part2DObject|Part Part2DObject]] è un oggetto interno, quindi non può essere creato dall'interfaccia grafica, ma solo dalla [[Python console/it|console Python]] come descritto nel paragrafo [[Part_Part2DObject/it#Script|Script]].
Line 27: Line 33:
Un [[Part_Part2DObject/it|Part Part2DObject]] (classe {{incode|Part::Part2DObject}}) è derivato da una [[Part_Feature/it|Part Feature]] (classe {{incode|Part::Feature}}), pertanto condivide tutte le proprietà di quest'ultimo.
Un [[Part_Part2DObject/it|Part Part2DObject]] (classe {{incode|Part::Part2DObject}}) è derivato da una [[Part_Feature/it|Part Feature]] (classe {{incode|Part::Feature}}), pertanto condivide tutte le proprietà di quest'ultimo.


<div class="mw-translate-fuzzy">
Oltre alle proprietà descritte in [[Part Feature/it|Part Feature]], Part Part2DObject ha le seguenti proprietà nell'[[property editor/it|editor delle proprietà]].
Oltre alle proprietà descritte in [[Part Feature/it|Part Feature]], Part Part2DObject ha le seguenti proprietà nell'[[property editor/it|editor delle proprietà]].
</div>


=== Dati ===
=== Dati ===


<div class="mw-translate-fuzzy">
{{TitleProperty|Attachment}}
{{TitleProperty|Attachment}}
* {{PropertyData|Map Mode}}: "Deactivated" by default. This property determines a plane which the object will use as reference for 2D geometry. Clicking on the ellipsis (three dots), to the right of the entry field opens the [[Part Attachment|Part Attachment]] [[task panel|task panel]] that allows selecting the supporting plane by picking different elements in the [[3D view|3D view]]. The different modes are: Deactivated, Translate origin, Object's XY, Object's XZ, Object's YZ, Plane face, Tangent to surface, Normal to edge, Frenet NB, Frenet TN, Frenet TB, Concentric, Revolution section, Plane by 3 points, Normal to 3 points, Folding, Inertia 2-3, Align O-N-X, Align O-N-Y, Align O-X-Y, Align O-X-N, Align O-Y-N, Align O-Y-X.
* {{PropertyData|Map Mode}}: "Deactivated" di default. Questa proprietà definisce il piano che l'oggetto utilizza come riferimento per la geometria 2D. Facendo clic sui puntini di sospensione (tre puntini), a destra del campo di immissione si apre il pannello [[Part Attachment/it|Part Attachment]] della [[task panel/it|scheda azioni]] che consente di selezionare il piano di supporto selezionando diversi elementi nella [[3D view/it|vista 3D]]. Le diverse modalità sono: Deactivated, Translate origin, Object's XY, Object's XZ, Object's YZ, Plane face, Tangent to surface, Normal to edge, Frenet NB, Frenet TN, Frenet TB, Concentric, Revolution section, Plane by 3 points, Normal to 3 points, Folding, Inertia 2-3, Align O-N-X, Align O-N-Y, Align O-X-Y, Align O-X-N, Align O-Y-N, Align O-Y-X.
</div>


Vedere [[Part Attachment/it|Part Attachment]] per ulteriori informazioni su tutte le modalità di associazione.
Vedere [[Part Attachment/it|Part Attachment]] per ulteriori informazioni su tutte le modalità di associazione.

The following two properties are normally hidden. They become visible once {{PropertyData|Map Mode}} is something other than {{value|Deactivated}}.
* {{PropertyData|Map Reversed|Bool}}: it defaults to {{FALSE}}; if it is {{TRUE}} the Z direction will be reversed. For example, a [[sketch|sketch]] will be flipped upside down.
* {{PropertyData|Attachment Offset|Placement}}: the position of the object in the [[3D view|3D view]], with respect to the attachment object's placement. The placement is defined by a {{incode|Base}} point (vector), and a {{incode|Rotation}} (axis and angle). See [[Placement|Placement]].

==== Hidden properties Data ====

{{TitleProperty|Base}}

* {{PropertyData|Proxy|PythonObject}}: a custom class associated with this object. This only exists for the [[Python|Python]] version. See [[Part_Part2DObject#Scripting|Scripting]].

{{TitleProperty|Attachment}}

* {{PropertyData|Attacher Type|String}}: class name of the attach engine object driving the attachment. It defaults to {{incode|Attacher::AttachEnginePlane}}.
* {{PropertyData|Support|LinkSubList}}: it is the plane or face supporting the 2D geometry. It defaults to an empty list {{incode|[]}}.
* {{PropertyData|Map Path Parameter|Float}}: sets point of curve to map a [[sketch|sketch]] to. It goes from {{value|0}} to {{value|1}}, which corresponds to the {{value|start}} and {{value|end}}. It defaults to {{value|0}}.


===Vista===
===Vista===


<div class="mw-translate-fuzzy">
{{TitleProperty|Grid}}
{{TitleProperty|Grid}}
* {{PropertyView|Grid Size}}: un valore che determina la dimensione della spaziatura delle linee della griglia locale nella [[3D view/it|vista 3D]].
* {{PropertyView|Grid Size}}: un valore che determina la dimensione della spaziatura delle linee della griglia locale nella [[3D view/it|vista 3D]].
Line 44: Line 71:
* {{PropertyView|Show Grid}}: se è {{TRUE}} nella [[3D view/it|vista 3D]] viene visualizzata una griglia locale all'oggetto. Questa griglia è indipendente dalla griglia di [[Draft_ToggleGrid/it|Draft]].
* {{PropertyView|Show Grid}}: se è {{TRUE}} nella [[3D view/it|vista 3D]] viene visualizzata una griglia locale all'oggetto. Questa griglia è indipendente dalla griglia di [[Draft_ToggleGrid/it|Draft]].
* {{PropertyView|Tight Grid}}: se è {{TRUE}} la griglia locale è localizzata attorno all'origine della forma, altrimenti si estende oltre.
* {{PropertyView|Tight Grid}}: se è {{TRUE}} la griglia locale è localizzata attorno all'origine della forma, altrimenti si estende oltre.
</div>

==== Hidden properties View ====

{{TitleProperty|Base}}

* {{PropertyView|Proxy|PythonObject}}: a custom view provider class associated with this object. This only exists for the [[Python|Python]] version. See [[Part_Part2DObject#Scripting|Scripting]].

All other view properties, including hidden properties, are those of the base [[Part_Feature|Part Feature]] object.


== Script ==
== Script ==
Line 49: Line 85:
{{Emphasis|Vedere anche:}} [[FreeCAD Scripting Basics/it|Script di base per FreeCAD]], e [[scripted objects/it|script di oggetti]].
{{Emphasis|Vedere anche:}} [[FreeCAD Scripting Basics/it|Script di base per FreeCAD]], e [[scripted objects/it|script di oggetti]].


<div class="mw-translate-fuzzy">
See [[Part_Feature|Part Feature]] for the general information.
Vedere [[Part_Feature/it|Part Feature]] per le informazioni generali.
</div>


<div class="mw-translate-fuzzy">
A Part Part2DObject is created with the {{incode|addObject()}} method of the document.
Un Part Part2DObject viene creato con il metodo {{incode|addObject()}} del documento.
</div>
{{Code|code=
{{Code|code=
import FreeCAD as App
import FreeCAD as App
Line 60: Line 100:
}}
}}


This basic {{incode|Part::Part2DObject}} doesn't have a Proxy object so it can't be fully used for sub-classing.
{{Part Tools navi/it}}

Therefore, for [[Python|Python]] subclassing, you should create the {{incode|Part::Part2DObjectPython}} object.

{{Code|code=
import FreeCAD as App

doc = App.newDocument()
obj = App.ActiveDocument.addObject("Part::Part2DObjectPython", "Name")
obj.Label = "Custom label"
}}

For example, most tools from the [[Draft_Workbench|Draft Workbench]], like [[Draft_Line|Draft Line]], [[Draft_Rectangle|Draft Rectangle]], [[Draft_Polygon|Draft Polygon]], etc., are {{incode|Part::Part2DObjectPython}} objects with a custom icon and additional properties.


{{Part Tools navi{{#translation:}}}}
{{Userdocnavi/it}}
{{Userdocnavi{{#translation:}}}}
{{clear}}

Revision as of 22:23, 26 February 2020

Introduzione

Un Part Part2DObject, o formalmente un Part::Part2DObject, è un elemento semplice a cui è associato un Shape topologico che può essere visualizzato nella Vista 3D.

Part::Part2DObject è derivato da una Part Feature, ma è specializzato nella geometria 2D, dato che la sua forma è posizionata su un piano. Il piano è definito dalla sua proprietà DatiPlacement (posizione, normale e rotazione). Tuttavia, il piano può anche essere definito supportando elementi geometrici, come il piano creato da tre vertici arbitrari o una faccia di un corpo solido.

Diagramma semplificato delle relazioni tra gli oggetti principali in FreeCAD. La classe Part::Part2DObject è specializzata per le forme 2D, quindi è la classe di base per gli oggetti planari creati con gli ambienti Draft e Sketcher.

Utilizzo

Part Part2DObject è un oggetto interno, quindi non può essere creato dall'interfaccia grafica, ma solo dalla console Python come descritto nel paragrafo Script.

Part::Part2DObject è definito nell'ambiente Part ma può essere usato come classe base per gli oggetti da script in tutti gli [[Workbenches/it|ambienti] ] che producono forme geometriche 2D. Ad esempio, è l'oggetto base per gli (Sketcher SketchObject) degli schizzi e per la maggior parte degli oggetti creati con Draft.

I workbench possono aggiungere diverse proprietà a questo elemento di base per produrre un oggetto con comportamento complesso.

Proprietà

Vedere Proprietà per tutti i tipi di proprietà che possono avere gli oggetti con script.

Un Part Part2DObject (classe Part::Part2DObject) è derivato da una Part Feature (classe Part::Feature), pertanto condivide tutte le proprietà di quest'ultimo.

Oltre alle proprietà descritte in Part Feature, Part Part2DObject ha le seguenti proprietà nell'editor delle proprietà.

Dati

Attachment

  • DatiMap Mode: "Deactivated" di default. Questa proprietà definisce il piano che l'oggetto utilizza come riferimento per la geometria 2D. Facendo clic sui puntini di sospensione (tre puntini), a destra del campo di immissione si apre il pannello Part Attachment della scheda azioni che consente di selezionare il piano di supporto selezionando diversi elementi nella vista 3D. Le diverse modalità sono: Deactivated, Translate origin, Object's XY, Object's XZ, Object's YZ, Plane face, Tangent to surface, Normal to edge, Frenet NB, Frenet TN, Frenet TB, Concentric, Revolution section, Plane by 3 points, Normal to 3 points, Folding, Inertia 2-3, Align O-N-X, Align O-N-Y, Align O-X-Y, Align O-X-N, Align O-Y-N, Align O-Y-X.

Vedere Part Attachment per ulteriori informazioni su tutte le modalità di associazione.

The following two properties are normally hidden. They become visible once DatiMap Mode is something other than Deactivated.

  • DatiMap Reversed (Bool): it defaults to false; if it is true the Z direction will be reversed. For example, a sketch will be flipped upside down.
  • DatiAttachment Offset (Placement): the position of the object in the 3D view, with respect to the attachment object's placement. The placement is defined by a Base point (vector), and a Rotation (axis and angle). See Placement.

Hidden properties Data

Base

  • DatiProxy (PythonObject): a custom class associated with this object. This only exists for the Python version. See Scripting.

Attachment

  • DatiAttacher Type (String): class name of the attach engine object driving the attachment. It defaults to Attacher::AttachEnginePlane.
  • DatiSupport (LinkSubList): it is the plane or face supporting the 2D geometry. It defaults to an empty list [].
  • DatiMap Path Parameter (Float): sets point of curve to map a sketch to. It goes from 0 to 1, which corresponds to the start and end. It defaults to 0.

Vista

Grid

  • VistaGrid Size: un valore che determina la dimensione della spaziatura delle linee della griglia locale nella vista 3D.
  • VistaGrid Snap: se è true la griglia può essere utilizzata per agganciare i punti.
  • VistaGrid Style: Dashed or Light; lo stile delle linee della griglia.
  • VistaShow Grid: se è true nella vista 3D viene visualizzata una griglia locale all'oggetto. Questa griglia è indipendente dalla griglia di Draft.
  • VistaTight Grid: se è true la griglia locale è localizzata attorno all'origine della forma, altrimenti si estende oltre.

Hidden properties View

Base

  • VistaProxy (PythonObject): a custom view provider class associated with this object. This only exists for the Python version. See Scripting.

All other view properties, including hidden properties, are those of the base Part Feature object.

Script

Vedere anche: Script di base per FreeCAD, e script di oggetti.

Vedere Part Feature per le informazioni generali.

Un Part Part2DObject viene creato con il metodo addObject() del documento.

import FreeCAD as App

doc = App.newDocument()
obj = App.ActiveDocument.addObject("Part::Part2DObject", "Name")
obj.Label = "Custom label"

This basic Part::Part2DObject doesn't have a Proxy object so it can't be fully used for sub-classing.

Therefore, for Python subclassing, you should create the Part::Part2DObjectPython object.

import FreeCAD as App

doc = App.newDocument()
obj = App.ActiveDocument.addObject("Part::Part2DObjectPython", "Name")
obj.Label = "Custom label"

For example, most tools from the Draft Workbench, like Draft Line, Draft Rectangle, Draft Polygon, etc., are Part::Part2DObjectPython objects with a custom icon and additional properties.