App DocumentObject/pl: Difference between revisions

From FreeCAD Documentation
(Created page with "==Właściwości==")
(Created page with "Zobacz stronę Właściwości dla wszystkich typów właściwości, które mogą mieć obiekty tworzone skryptami.")
Line 33: Line 33:
==Właściwości==
==Właściwości==


Zobacz stronę [[Property/pl|Właściwości]] dla wszystkich typów właściwości, które mogą mieć obiekty tworzone skryptami.
See [[Property|Property]] for all property types that scripted objects can have.


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

Revision as of 14:34, 30 March 2024

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.

Some of the most important DocumentObjects are the following:

  • The App FeaturePython class, an empty object that can be used for different purposes, depending on the added properties.
  • The App GeoFeature class, the base object of all geometrical objects, that is, of objects that have a Placement property that defines their position in the 3D view.
  • The Part Feature class, derived from App GeoFeature, and the parent class of objects with 2D and 3D topological shapes.
  • The Mesh Feature class, derived from App GeoFeature, and the parent class of objects with 2D and 3D meshes.

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"