FreeCAD Logo FreeCAD 1.0
  • English Afrikaans Arabic Belarusian Catalan Czech German Greek Spanish Spanish Basque Finnish Filipino French Galician Croatian Hungarian Indonesian Italian Japanese Kabyle Korean Lithuanian Dutch Norwegian Bokmal Polish Portuguese Portuguese Romanian Russian Slovak Slovenian Serbian Swedish Turkish Ukrainian Valencian Vietnamese Chinese Chinese
  • Features
  • Download
  • Blog
  • Documentation
    Documentation index Getting started Users documentation The FreeCAD manual Workbenches documentation Python coding documentation C++ coding documentation Tutorials Frequently asked questions Privacy policy About FreeCAD
  • Contribute
    How to help Sponsor Report a bug Make a pull request Jobs and funding Contribution guidelines Developers handbook Translations
  • Community
    Code of conduct Forum The FPA GitHub GitLab Codeberg Mastodon Matrix IRC IRC via Webchat Gitter Discord Reddit Twitter Facebook LinkedIn Calendar
  • ♥ Donate

Donate

$
SEPA Information
Please set up your SEPA bank transfer to:
Beneficiary: The FreeCAD project association
IBAN: BE04 0019 2896 4531
BIC/SWIFT: GEBABEBBXXX
Bank agency: BNP Paribas Fortis
Address: Rue de la Station 64, 1360 Perwez, Belgium

While Stripe doesn't support monthly donations, you can still become a sponsor! Simply make a one-time donation equivalent to 12 months of support, and you'll gain access to the corresponding sponsoring tier. It's an easy and flexible way to contribute.

If you are not sure or not able to commit to a regular donation, but still want to help the project, you can do a one-time donation, of any amount.

Choose freely the amount you wish to donate one time only.

You can support FreeCAD by sponsoring it as an individual or organization through various platforms. Sponsorship provides a steady income for developers, allowing the FPA to plan ahead and enabling greater investment in FreeCAD. To encourage sponsorship, we offer different tiers, and unless you choose to remain anonymous, your name or company logo will be featured on our website accordingly.

from 1 USD / 1 EUR per month. You will not have your name displayed here, but you will have helped the project a lot anyway. Together, normal sponsors maintain the project on its feet as much as the bigger sponsors.

from 25 USD / 25 EUR per month. Your name or company name is displayed on this page.

from 100 USD / 100 EUR per month. Your name or company name is displayed on this page, with a link to your website, and a one-line description text.

from 200 USD / 200 EUR per month. Your name or company name and logo displayed on this page, with a link to your website and a custom description text. Companies that have helped FreeCAD early on also appear under Gold sponsors.

Instead of donating each month, you might find it more comfortable to make a one-time donation that, when divided by twelve, would give you right to enter a sponsoring tier. Don't hesitate to do so!

Choose freely the amount you wish to donate each month.

Please inform your forum name or twitter handle as a notein your transfer, or reach to us, so we can give you proper credits!

Въведение

Всички обекти в програмата имат име на обект, което уникално ги идентифицира в даден документ.

Тази информация се прилага за всички обекти, получени от App DocumentObject (клас App::DocumentObject), който по същество включва всички обекти, които е възможно да се създадат в документ.

Бележки

Има различни свойства на името:

  • Name може да включва само прости буквено-цифрови знаци и долна черта, [_0-9a-zA-zA-Z].
  • Name не може да започне с число; трябва да започне с буква или долната черта, [_a-zA-Z].
  • Name се присвоява по време на създаването на обекта; след това то вече не може да се редактира. Обектът никога не може да бъде преименуван.
  • Name трябва да бъде уникално в целия документ. Няма значение дали два обекта са от съвсем различни типове, например, единият е PartDesign Pocket, а другият е Arch Wall. Трябва да имат различни имена.
  • При създаване на обект от същия тип, обикновено към името се добавя увеличаващ се последователен номер, по този начин Box, Box001, Box0012 и т.н. Това предотвратява конфликти с имената.
  • След като обектът бъде изтрит, неговото име Name става достъпно за използване от новосъздаден обект. Това означава, че ако Box, Box001, и Box002 съществуват, и изтрием първия елемент, следващото поле, създадено с Part Box, няма да бъде Box003, а ще бъде отново Box, защото този низ е наличен, за да се използва отново. Забележете, че не е възможно да преименувате Box001 или Box002 на Box, тъй като имената са фиксирани.

В обобщение, Name по същество действа като уникален идентификатор (UID) за обект. Тъй като уникалното име Name е много ограничително, всички обекти също имат свойство Label, което позволява "преименуване" на обекта на нещо по-описателно. Вътрешното име Name всъщност остава фиксирано, но потребителят може да редактира Label, и може да се го използва в повечето ситуации, в които ще се използва и Name. В обща употреба в програмата и документацията, "преименуване" означава промяна на Label, а не действителното име Name на обекта.

Етикети

Има различни свойства на етикетите:

  • Label може да приеме всеки UTF8 низ, включително с ударения и интервали.
  • Дървовидният изглед всъщност показва етикета Label на обекта, а не Name. Следователно, когато се създава нов обект, е добра практика да се промени неговия етикет Label на по-описателен низ. За да преименувате (преетикетирате) обекта, изберете го в дървовидния изглед и натиснете F2 (или само Return на macOS), или отворете контекстното меню (щракване с десния бутон) и изберете Rename.
  • Дори след като обект е преименуван (преетикетиран), вътрешният Name все още ще бъде показвано на много места, например в Status Bar или в Selection View, когато обектът е избран.
  • Тъй като вътрешните функции на програмата се обръщат към обектите чрез Name, много диалози ще покажат първо Name, последвани от етиката в скоби Label, който може да се редактира, например Box (екструдирана част).
  • По подразбиране Label е уникален, точно като Name. Това поведение обаче може да бъде променено в preferences editor, Edit → Preferences → General → Document → Allow duplicate object labels in one document. Това означава, че като цяло Label не е уникален в документа и всъщност може да се повтори. Препоръката обаче е да се запази уникалният Label, тъй като това е може би това, което е най-полезно за идентифициране на различни обекти. Когато пишете персонализирани функции, които манипулират обекти, методите трябва да използват Name на обекта, а не неговия Label, за да гарантират, че се използва правилният обект.
  • Когато използвате expressions, например, в Преглед на свойствата или в spreadsheet, етикетът може да бъде заграден с два символа по-малко и два символа по-голямо.
<<Custom Label With Spaces>>.Height
<<Label may use UTF8 characters>>.Width

Label2

Това е прост низ, който може да съдържа произволен текст и следователно може да се използва за документиране (описване с повече подробности) на създадения обект.

  • В Преглед на свойствата редактирайте полето до иконата, под "Описание", като кликнете върху него и натиснете F2 (или Return на macOS).
  • Можете също да промените това свойство, като модифицирате атрибута Label2 от Python console.
  • Атрибутът ДанниLabel2 обикновено е скрит в Преглед на свойствата, но може да бъде направен видим чрез отваряне на контекстното меню (щракване с десния бутон) и избиране на Show hidden.

Scripting

See also: FreeCAD Scripting Basics, and scripted objects.

Any object in the software is internally created with the addObject() method of the document. The majority of 2D and 3D objects that the user will see in the 3D View are derived from a Part Feature. In the following example, the object created is a Part Box.

import FreeCAD as App

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

Name

The addObject function has two basic string arguments.

  • The first argument indicates the type of object, in this case, "Part::Box".
  • The second argument is a string that defines the Name attribute. If it is not provided, it defaults to the same name as the class of the object, that is, "Part__Box", where the two invalid symbols, the colons ::, are replaced by two underscores __.
    • The Name can only include simple alphanumeric characters, and the underscore, [_0-9a-zA-Z]. If other symbols are given, these will be converted to underscores; for example, "A+B:C*" is converted to "A_B_C_".
    • The Name cannot start with a number; it must start with a letter or the underscore, [_a-zA-Z]. For example, "123ABC" is converted to "_23ABC".
    • The Name is fixed at creation time; it cannot be modified afterwards.
    • The Name must be unique in the entire document. If the same "Name" is used, a sequential number will be appended automatically so that the resulting names are unique; for example, if "Name" already exists, then new objects will be called "Name001", "Name002", "Name003", etc.

Label

The Label is a property of the created object and can be changed to a more meaningful text.

  • Upon creating the object, the Label is the same as the Name.
  • However, unlike the Name, the Label can accept any UTF8 string, including accents and spaces.
  • The Label can be changed at any point in time just by assigning the desired string, obj.Label = "New label"

Getting an object by Name or Label

All objects in a document are data attributes of the corresponding Document object. The attribute's name correspond to the internal Name of the object.

import FreeCAD as App

obj1 = App.ActiveDocument.Box
obj2 = App.ActiveDocument.Box001
obj3 = App.ActiveDocument.Box002

This is equivalent to using the getObject method of the Document.

import FreeCAD as App

obj1 = App.ActiveDocument.getObject('Box')
obj2 = App.ActiveDocument.getObject('Box001')
obj3 = App.ActiveDocument.getObject('Box002')

However, it is also possible to get the object by the more descriptive Label.

import FreeCAD as App

obj1 = App.ActiveDocument.getObjectsByLabel("Concrete wall")[0]
obj2 = App.ActiveDocument.getObjectsByLabel("Custom parallelepiped")[0]
obj3 = App.ActiveDocument.getObjectsByLabel("Some special name for this cube__002")[0]

Given that the Label is in general not unique, the getObjectsByLabel method returns a list with all objects found with that Label. However, if the Label is unique in the document then the first element in that list should be the desired object.

This page is retrieved from https://wiki.freecad.org/Object_name

Get in touch!
Forum GitHub Mastodon Matrix IRC Gitter.im Discord Reddit Twitter Facebook LinkedIn

© The FreeCAD Team. Homepage image credits (top to bottom): ppemawm, r-frank, epileftric, regis, rider_mortagnais, bejant.

This project is supported by: , KiCad Services Corp. and other sponsors

GitHubImprove this page on GitHub