Part Part2DObject/it: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
(Updating to match new version of source page)
Line 17: Line 17:
</div>
</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]].

Revision as of 21:54, 13 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.