Funzione Part
Introduzione
Un oggetto Part Feature, o formalmente un Part::Feature
, è un elemento semplice a cui è associato un Shape
topologico che può essere visualizzato nella Vista 3D.
A Part Feauture is the parent class of most 2D (Draft, Sketcher) and 3D (Part, PartDesign) objects, with the exception of meshes, which are normally based on Mesh Feature, or Fem FemMeshObject for FEM objects.
Diagramma semplificato delle relazioni tra gli oggetti principali in FreeCAD. La classe Part::Feature
è l'origine della maggior parte degli oggetti 2D (Draft, Sketcher) e 3D (Part, PartDesign).
Utilizzo
Part Feature è un oggetto interno, quindi non può essere creato dall'interfaccia grafica, ma solo dalla console Python come descritto nel paragrafo Script.
L'oggetto Part::Feature
è definito in Part ma può essere usato come classe base per script di oggetti in tutti gli ambienti che producono forme geometriche 2D e 3D. Ad esempio, è la classe genitrice del Corpo PartDesign e di Part Part2DObject, che à specializzata in forme 2D (planari).
Part::Feature
is also the parent class of the PartDesign Body, of the PartDesign Features, and of the Part Part2DObject, which is specialized for 2D (planar) shapes.
Un oggetto Part::Feature
ha proprietà semplici come il posizionamento e le proprietà vista per definire l'aspetto dei suoi vertici, bordi e facce. Gli ambienti possono aggiungere altre proprietà a questo elemento di base per produrre un oggetto con un comportamento complesso.
Proprietà
A Part Feature (Part::Feature
class) is derived from the basic App GeoFeature (App::GeoFeature
class), therefore it shares all the latter's properties.
In addition to the properties described in App GeoFeature, the Part Feature has the DatiShape property, which stores the Part TopoShape of this object; this is the geometry that is shown in the 3D view.
Other properties that this object has are those related to the appearance of its TopoShape, including VistaAngular Deflection, VistaDeviation, VistaDraw Style, VistaLighting, VistaLine Color, VistaLine Width, VistaPoint Color, VistaPoint Size, and also the hidden properties VistaDiffuse Color, VistaLine Color Array, VistaLine Material, VistaPoint Color Array, and VistaPoint Material.
Vedere Proprietà per tutti i tipi di proprietà che possono avere oggetti con script.
Queste sono le proprietà disponibili nell'editor delle proprietà.
Dati
Base
- DatiPlacement: la posizione dell'oggetto nella Vista 3D. Il posizionamento è definito da un punto
Base
(vettore) e unaRotation
(asse e angolo). Vedere Posizionamento.- DatiAngle: l'angolo di rotazione attorno al DatiAxis.
- DatiAxis: il vettore unitario che definisce l'asse di rotazione per il posizionamento. Ogni valore è compreso tra 0 e 1. Se un valore è superiore a 1, il vettore viene normalizzato in modo che l'entità del vettore sia 1.
- DatiPosition: le coordinate 3D del punto base del posizionamento.
- DatiLabel: la descrizione modificabile dall'utente di questo oggetto.
Hidden properties Data
- DatiExpression Engine (
ExpressionEngine
): a list of expressions. By default, it is empty[]
. - DatiLabel2 (
String
): a longer, user editable description of this object, it is an arbitrary UTF8 string that may include newlines. By default, it is an empty string""
. - DatiProxy (
PythonObject
): a class associated with this object. - DatiShape (
PartShape
): a Part TopoShape class associated with this object. - DatiVisibility (
Bool
): whether to display the object or not.
Vista
La maggior parte degli oggetti in FreeCAD ha quello che viene chiamato un "fornitore di viste", che è una classe che definisce l'aspetto visivo dell'oggetto nella vista 3D e nella vista ad albero. Il fornitore di viste predefinito degli oggetti Part Feature definisce le seguenti proprietà. Anche gli oggetti con script derivati da Part Feature hanno accesso a queste proprietà.
Base
- VistaAngular Deflection: accompagna VistaDeviation. È un altro modo per specificare la precisione con cui generare la mesh per il rendering sullo schermo o durante l'esportazione. Il valore predefinito è 28,5 gradi o 0,5 radianti. Minore è il valore, più uniforme sarà l'aspetto nella vista 3D e più fine sarà la mesh che verrà esportata.
- VistaBounding Box: se è
true
, l'oggetto mostra il parallelepipedo che lo contiene nella vista 3D. - VistaDeviation: accompagna VistaAngular Deflection. È un altro modo per specificare la precisione con cui generare la mesh per il rendering sullo schermo o durante l'esportazione. Il valore predefinito è 28,5 gradi o 0,5 radianti. Minore è il valore, più uniforme sarà l'aspetto nella vista 3D e più fine sarà la mesh che verrà esportata.
- VistaDisplay Mode: Flat lines (visualizzazione normale con facce piene), Ombreggiato (bordi leggeri), Wireframe (solo reticolo e facce vuote), Punti (solo vertici).
- VistaDraw Style: Solid, Dashed, Dotted, Dashdot; definisce lo stile dei bordi nella vista 3D.
- VistaLighting: Two side, One side; l'illuminazione proviene da due lati o un lato nella vista 3D.
- VistaLine Color: una tupla di tre valori
(r,g,b)
per definire il colore dei bordi nella vista 3D. - VistaLine Width: un flottante che determina la larghezza in pixel dei bordi nella vista 3D.
- VistaOn Top When Selected: Disabled, Enabled, Object, Element.
- VistaPoint Color: una tupla di tre valori
(r,g,b)
per definire il colore dei vertici nella vista 3D. - VistaPoint Size: un flottante che determina la dimensione in pixel dei vertici nella vista 3D.
- VistaSelectable: se è
true
, l'oggetto può essere selezionato con il puntatore nella vista 3D. Altrimenti, l'oggetto non può essere selezionato fino a quando questa opzione non è impostata sutrue
. - VistaSelection Style: Shape, BoundBox.
- VistaShape Color: una tupla di tre valori
(r,g,b)
per definire il colore delle facce nella vista 3D. - VistaShow In Tree: se è
true
, l'oggetto appare nella vista ad albero. Altrimenti, è impostato come invisibile. - VistaTransparency: un valore da 0 a 100 che determina il livello di trasparenza delle facce nella vista 3D. Un valore di 100 indica facce completamente invisibili; le facce che sono invisibili possono comunque essere selezionate se VistaSelectable è
true
. - VistaVisibility: se è
true
, l'oggetto appare nella vista 3D; altrimenti non è visibile. Per impostazione predefinita, questa proprietà può essere attivata e disattivata premendo la barra Spazio sulla tastiera.
The deviation is a value in percentage that is related to the dimensions in millimeters of the bounding box of the object. The deviation in millimeters can be calculated as follows:
deviation_in_mm = (w + h + d)/3 * deviation/100
where w
, h
, d
are the bounding box dimensions.
- VistaDisplay Mode (
Enumeration
):Flat Lines
(regular visualization),Shaded
(no edges),Wireframe
(no faces),Points
(only vertices). - VistaDraw Style (
Enumeration
):Solid
(default),Dashed
,Dotted
,Dashdot
; defines the style of the edges in the 3D view. - VistaLighting (
Enumeration
):Two side
(default),One side
; the illumination comes from two sides or one side in the 3D view. - VistaLine Color (
Color
): a tuple of three floating point RGB values(r,g,b)
to define the color of the edges in the 3D view; by default it is(0.09, 0.09, 0.09)
, which is displayed as[25,25,25]
on base 255, almost black . - VistaLine Width (
FloatConstraint
): a float that determines the width in pixels of the edges in the 3D view. It defaults to2.0
. - VistaOn Top When Selected (
Enumeration
):Disabled
(default),Enabled
,Object
,Element
. - VistaPoint Color (
Color
): similar to VistaLine Color, defines the color of the vertices. - VistaPoint Size (
FloatConstraint
): similar to VistaLine Width, defines the size of the vertices. - VistaSelectable (
Bool
): if it istrue
, the object can be picked with the pointer in the 3D view. Otherwise, the object cannot be selected until this option is set totrue
. - VistaSelection Style (
Enumeration
):Shape
(default),BoundBox
. If the option isShape
, the entire shape (vertices, edges, and faces) will be highlighted in the 3D view; if it isBoundBox
only the bounding box will be highlighted. - VistaShape Color (
Color
): similar to VistaLine Color, defines the color of the faces. It defaults to(0.8, 0.8, 0.8)
, which is displayed as[204,204,204]
on base 255, a light gray. - VistaShow In Tree (
Bool
): if it istrue
, the object appears in the tree view. Otherwise, it is set as invisible. - VistaTransparency (
Percent
): an integer from0
to100
(a percentage) that determines the level of transparency of the faces in the 3D view. A value of100
indicates completely invisible faces; the faces are invisible but they can still be picked as long as VistaSelectable istrue
. - VistaVisibility (
Bool
): if it istrue
, the object appears in the 3D view; otherwise it is invisible. By default this property can be toggled on and off by pressing the Space bar in the keyboard.
Hidden properties View
- VistaDiffuse Color (
ColorList
): it is a list of RGB tuples defining colors, similar to VistaShape Color. It defaults to a list of one[(0.8, 0.8, 0.8)]
. - VistaLine Color Array (
ColorList
): it is a list of RGB tuples defining colors, similar to VistaLine Color. It defaults to a list of one[(0.09, 0.09, 0.09)]
. - VistaLine Material (
Material
): an App Material associated with the edges in this object. By default it is empty. - VistaPoint Color Array (
ColorList
): it is a list of RGB tuples defining colors, similar to VistaPoint Color. It defaults to a list of one[(0.09, 0.09, 0.09)]
. - VistaPoint Material (
Material
): an App Material associated with the vertices in this object. By default it is empty. - VistaProxy (
PythonObject
): a custom view provider class associated with this object. By default it is empty. - VistaShape Material (
Material
): an App Material associated with this object. By default it is empty.
Script
Vedere anche: Script di base per FreeCAD, e script di oggetti.
Un oggetto Part Feature viene creato con il metodo addObject()
del documento.
import FreeCAD as App
doc = App.newDocument()
obj = App.ActiveDocument.addObject("Part::Feature", "Name")
obj.Label = "Custom label"
This basic Part::Feature
doesn't have a Proxy object so it can't be fully used for sub-classing.
Therefore, for Python scripting, the recommendation is to create the Part::FeaturePython
object.
import FreeCAD as App
doc = App.newDocument()
obj = App.ActiveDocument.addObject("Part::FeaturePython", "Name")
obj.Label = "Custom label"
Name
The addObject
function has two basic string arguments.
- Il primo argomento indica il tipo di oggetto, in questo caso,
"Part::Feature"
. - Il secondo argomento è una stringa che definisce l'attributo
Name
. Se non viene fornito, per impostazione predefinita è"Part__Feature"
.- Il
Name
viene stabilito al momento della creazione; non può essere modificato in seguito. - Il
Name
può includere solo caratteri alfanumerici semplici e il trattino basso,[_0-9a-zA-Z]
. Se vengono forniti altri simboli, questi verranno convertiti in caratteri di sottolineatura; per esempio,"A+B:C*"
viene convertito in"A_B_C_"
. - Il
Name
deve essere unico in tutto il documento. Se vengono creati più oggetti con lo stesso nome, viene aggiunto un numero sequenziale per distinguerli, ad esempio,"Name001"
,"Name002"
, etc.
- Il
- Se lo si desidera, l'attributo
Label
può essere modificato in un testo più significativo.- Di default,
Label
è uguale aName
. - A differenza di
Name
,Label
può accettare qualsiasi stringa UTF8, inclusi accenti e spazi. Poiché la vista ad albero visualizzaLabel
, è buona norma cambiareLabel
in una stringa più descrittiva. - Di default,
Label
deve essere univoco. Questo comportamento può essere modificato nell'editor delle preferenze, Modifica → Preferenze → Generale → Documento → Consenti la duplicazione delle etichette nel documento.
- Di default,
Label
If desired, the Label
attribute can be changed to a more meaningful text.
- Upon creating the object, the
Label
is the same as theName
. - However, unlike the
Name
, theLabel
can accept any UTF8 string, including accents and spaces. Since the tree view displays theLabel
, it is a good practice to change theLabel
to a more descriptive string. - By default the
Label
is unique, just like theName
. However, this behavior can be changed in the preferences editor, Edit → Preferences → General → Document → Allow duplicate object labels in one document. This means that in general theLabel
may be repeated in the same document; when testing for a specific element the user should rely on theName
rather than on theLabel
.
- Primitives: Box, Cylinder, Sphere, Cone, Torus, Tube, Create primitives, Shape builder
- Creation and modification: Extrude, Revolve, Mirror, Scale, Fillet, Chamfer, Make face from wires, Ruled Surface, Loft, Sweep, Section, Cross sections, 3D Offset, 2D Offset, Thickness, Projection on surface, Attachment
- Boolean: Make compound, Explode Compound, Compound Filter, Boolean, Cut, Fuse, Common, Connect, Embed, Cutout, Boolean fragments, Slice apart, Slice, XOR
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Assembly, BIM, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Surface, TechDraw, Test Framework
- Hubs: User hub, Power users hub, Developer hub