App: Obiekt dokumentu

From FreeCAD Documentation
Revision as of 14:39, 30 March 2024 by Kaktus (talk | contribs) (Created page with "Niektóre z najważniejszych obiektów dokumentu to: * Klasa App: Właściwości Python, pusty obiekt, który może być używany do różnych celów, w zależności od dodanych atrybutów. * Klasa App: Cechy geometrii, podstawowy obiekt wszystkich obiektów geometrycznych, czyli obiektów posiadających atrybut Umiejscowienie, który definiuje ich pozycję w widoku 3D. * Klasa Part_Feature/...")

Wprowadzenie

Obiekt Dokumentu, lub formalnie App::DocumentObject, jest klasą bazową wszystkich klas obiektów obsługiwanych w dokumencie.

Ogólnie rzecz biorąc, "ObiektDokumentu" to dowolna "rzecz", która może pojawić się w widoku drzewa i która jest zapisywana i przywracana podczas otwierania dokumentu.

Widok drzewa pokazujący różne obiekty w dokumencie. Każdy z nich jest "obiektem dokumentu", wywodzącym się z klasy bazowej App::DocumentObject.

Uproszczony diagram zależności pomiędzy podstawowymi obiektami w programie FreeCAD.

Użycie

Obiekt dokumentu jest klasą wewnętrzną, więc nie może być tworzona z poziomu interfejsu graficznego, ani nie jest przeznaczona do samodzielnego użytku. Definiuje ona jedynie podstawowe zachowanie i właściwości obiektów w programie.

Niektóre z najważniejszych obiektów dokumentu to:

Właściwości

Zobacz stronę Właściwości dla wszystkich typów właściwości, które mogą mieć obiekty tworzone skryptami.

These are the basic properties that essentially all objects have. These properties can be accessed from the Python console.

  • DANELabel (String): the user editable name of this object, it is an arbitrary UTF8 string. By default, it is the same as the Name.
  • DANELabel2 (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 "".
  • DANEExpression Engine (ExpressionEngine): a list of expressions.
  • DANEVisibility (Bool): whether to display the object or not.

For derived objects, only DANELabel will be listed in the property editor by default. The other properties will be hidden.

Scripting

See also: FreeCAD Scripting Basics and scripted objects.

See Part Feature for the general information on adding objects to the document.

A DocumentObject is created with the addObject() method of the document. However, in general, there is no need to create this object manually. It is usually better to subclass one of the more complex classes, for example, App FeaturePython, App GeoFeature, Part Feature, Part Part2DObject, etc.

import FreeCAD as App

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