<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.labrps.com/index.php?action=history&amp;feed=atom&amp;title=Object_name</id>
	<title>Object name - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.labrps.com/index.php?action=history&amp;feed=atom&amp;title=Object_name"/>
	<link rel="alternate" type="text/html" href="https://wiki.labrps.com/index.php?title=Object_name&amp;action=history"/>
	<updated>2026-05-07T19:38:43Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>https://wiki.labrps.com/index.php?title=Object_name&amp;diff=2047&amp;oldid=prev</id>
		<title>LabRPS: Created page with &quot;== Introduction ==   {{TOCright}}  All objects in the program have an object name that uniquely identifies them in a given document.  This information applies to all objects derived from App DocumentObject ({{incode|App::DocumentObject}} class), which essentially comprises all objects that are possible to create in a document.  == Names ==   There are various properties for Names: * The {{incode|Name}} can only include simple alphan...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.labrps.com/index.php?title=Object_name&amp;diff=2047&amp;oldid=prev"/>
		<updated>2024-10-28T14:04:57Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Introduction ==   {{TOCright}}  All objects in the program have an &lt;a href=&quot;/Object_name&quot; title=&quot;Object name&quot;&gt;object name&lt;/a&gt; that uniquely identifies them in a given document.  This information applies to all objects derived from &lt;a href=&quot;/App_DocumentObject&quot; title=&quot;App DocumentObject&quot;&gt;App DocumentObject&lt;/a&gt; ({{incode|App::DocumentObject}} class), which essentially comprises all objects that are possible to create in a document.  == Names ==   There are various properties for Names: * The {{incode|Name}} can only include simple alphan...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Introduction == &lt;br /&gt;
&lt;br /&gt;
{{TOCright}}&lt;br /&gt;
&lt;br /&gt;
All objects in the program have an [[Object_name|object name]] that uniquely identifies them in a given document.&lt;br /&gt;
&lt;br /&gt;
This information applies to all objects derived from [[App_DocumentObject|App DocumentObject]] ({{incode|App::DocumentObject}} class), which essentially comprises all objects that are possible to create in a document.&lt;br /&gt;
&lt;br /&gt;
== Names == &lt;br /&gt;
&lt;br /&gt;
There are various properties for Names:&lt;br /&gt;
* The {{incode|Name}} can only include simple alphanumeric characters, and the underscore, {{incode|[_0-9a-zA-Z]}}.&lt;br /&gt;
* The {{incode|Name}} cannot start with a number; it must start with a letter or the underscore, {{incode|[_a-zA-Z]}}.&lt;br /&gt;
* The {{incode|Name}} is assigned at the creation time of the object; afterwards it is no longer editable. The object can never be renamed.&lt;br /&gt;
* The {{incode|Name}} must be unique in the entire document.&lt;br /&gt;
* When creating an object of the same type, normally the name is increased with a sequential number, thus {{incode|Sim}}, {{incode|Sim001}}, {{incode|Sim002}}, etc. This prevents naming collision.&lt;br /&gt;
* Once the object is deleted, its {{incode|Name}} becomes available to be used by a newly created object. This means that if {{incode|Sim}}, {{incode|Sim001}}, and {{incode|BSim002}} exist, and we delete the first item, the next sim created will not be {{incode|Sim003}}, it will be {{incode|Sim}} again, because this string is available to be used once more. Notice that it is not possible to rename {{incode|Sim001}} or {{incode|Sim002}} to {{incode|Sim}} since their names are fixed.&lt;br /&gt;
&lt;br /&gt;
In summary, the {{incode|Name}} essentially acts like a unique identifier (UID) for an object. Since a unique {{incode|Name}} is very restrictive, all objects also have a {{incode|Label}} property which allows &amp;quot;renaming&amp;quot; the object to something more descriptive. The internal {{incode|Name}} actually remains fixed, but the user editable {{incode|Label}} can be used in most situations where the {{incode|Name}} would be used. In common usage in the program and the documentation, &amp;quot;renaming&amp;quot; means changing the {{incode|Label}} and not the actual {{incode|Name}} of the object.&lt;br /&gt;
&lt;br /&gt;
== Labels == &lt;br /&gt;
&lt;br /&gt;
There are various properties for Labels:&lt;br /&gt;
* The {{incode|Label}} can accept any UTF8 string, including accents and spaces.&lt;br /&gt;
* The [[tree_view|tree view]] actually displays the {{incode|Label}} of the object, not the {{incode|Name}}. Therefore, whenever a new object is created, it is a good practice to change the {{incode|Label}} to a more descriptive string. To rename (relabel) the object, select it in the tree view and press {{KEY|F2}} (or rather {{KEY|Return}} on macOS), or open the context menu (right-click) and choose {{MenuCommand|Rename}}.&lt;br /&gt;
* Even after an object was renamed (relabelled), the internal {{incode|Name}} will still be reported in many places, for example, in the [[Status_bar|status bar]] or in the [[Selection_view|selection view]], when the object is selected.&lt;br /&gt;
* Since the internal functions of the program refer to the objects by {{incode|Name}}, many dialogs will display the {{incode|Name}} first, followed by the user editable {{incode|Label}} in parentheses, for example, {{incode|Sim (Wind Simulation)}}.&lt;br /&gt;
* By default the {{incode|Label}} is unique, just like the {{incode|Name}}. However, this behavior can be changed in the [[Preferences_Editor|preferences editor]], {{MenuCommand|Edit → Preferences → General → Document → Allow duplicate object labels in one document}}. This means that in general the {{incode|Label}} is not unique in the document, and may actually be repeated. However, the recommendation is to keep the {{incode|Label}} unique, as this is probably what is most useful to identify different objects. When writing custom functions that manipulate objects, the methods should use the {{incode|Name}} of the object rather than its {{incode|Label}} to guarantee that the correct object is used.&lt;br /&gt;
* When using [[Expressions|expressions]], for example, in the [[Property_editor|property editor]] or in a [[Spreadsheet|spreadsheet]], the Label can be referenced using double brackets made of the less than and greater than symbols.&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
&amp;lt;&amp;lt;Custom Label With Spaces&amp;gt;&amp;gt;.Height&lt;br /&gt;
&amp;lt;&amp;lt;Label may use UTF8 characters&amp;gt;&amp;gt;.Width&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Label2 === &lt;br /&gt;
&lt;br /&gt;
It is a simple string that can contain arbitrary text, and therefore can be used for documenting (describing with more detail) the created object.&lt;br /&gt;
* In the [[Tree_view|tree view]] edit the field next to the icon, under &amp;quot;Description&amp;quot;, by clicking on it and pressing {{KEY|F2}} (or rather {{KEY|Return}} on macOS).&lt;br /&gt;
* You can also change this property by modifying the {{incode|Label2}} attribute from the [[Python_console|Python console]].&lt;br /&gt;
* The {{PropertyData|Label2}} attribute is normally hidden in the [[Property_editor|property editor]] but can be made visible by opening the context menu (right click) and selecting {{MenuCommand|Show all}}.&lt;br /&gt;
&lt;br /&gt;
== Scripting == &lt;br /&gt;
&lt;br /&gt;
{{Emphasis|See also:}} [[LabRPS_Scripting_Basics|LabRPS Scripting Basics]], and [[Scripted_objects|scripted objects]].&lt;br /&gt;
&lt;br /&gt;
Any object in the software is internally created with the {{incode|addObject()}} method of the document.&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
import LabRPS as App&lt;br /&gt;
&lt;br /&gt;
doc = App.newDocument()&lt;br /&gt;
obj = doc.addObject(&amp;quot;WindLab::Simulation&amp;quot;, &amp;quot;Name&amp;quot;)&lt;br /&gt;
obj.Label = &amp;quot;Custom label&amp;quot;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Name === &lt;br /&gt;
&lt;br /&gt;
The {{incode|addObject}} function has two basic string arguments.&lt;br /&gt;
&lt;br /&gt;
* The first argument indicates the type of object, in this case, {{incode|&amp;quot;WindLab::Simulation&amp;quot;}}.&lt;br /&gt;
* The second argument is a string that defines the {{incode|Name}} attribute. If it is not provided, it defaults to the same name as the class of the object, that is, {{incode|&amp;quot;WindLab_Simulation&amp;quot;}}, where the two invalid symbols, the colons {{incode|::}}, are replaced by two underscores {{incode|__}}.&lt;br /&gt;
** The {{incode|Name}} can only include simple alphanumeric characters, and the underscore, {{incode|[_0-9a-zA-Z]}}. If other symbols are given, these will be converted to underscores; for example, {{incode|&amp;quot;A+B:C*&amp;quot;}} is converted to {{incode|&amp;quot;A_B_C_&amp;quot;}}.&lt;br /&gt;
** The {{incode|Name}} cannot start with a number; it must start with a letter or the underscore, {{incode|[_a-zA-Z]}}. For example, {{incode|&amp;quot;123ABC&amp;quot;}} is converted to {{incode|&amp;quot;_23ABC&amp;quot;}}.&lt;br /&gt;
** The {{incode|Name}} is fixed at creation time; it cannot be modified afterwards.&lt;br /&gt;
** The {{incode|Name}} must be unique in the entire document. If the same {{incode|&amp;quot;Name&amp;quot;}} is used, a sequential number will be appended automatically so that the resulting names are unique; for example, if {{incode|&amp;quot;Name&amp;quot;}} already exists, then new objects will be called {{incode|&amp;quot;Name001&amp;quot;}}, {{incode|&amp;quot;Name002&amp;quot;}}, {{incode|&amp;quot;Name003&amp;quot;}}, etc.&lt;br /&gt;
&lt;br /&gt;
=== Label === &lt;br /&gt;
&lt;br /&gt;
The {{incode|Label}} is a property of the created object and can be changed to a more meaningful text.&lt;br /&gt;
* Upon creating the object, the {{incode|Label}} is the same as the {{incode|Name}}.&lt;br /&gt;
* However, unlike the {{incode|Name}}, the {{incode|Label}} can accept any UTF8 string, including accents and spaces.&lt;br /&gt;
* The {{incode|Label}} can be changed at any point in time just by assigning the desired string, &amp;lt;code&amp;gt;obj.Label = &amp;quot;New label&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Getting an object by Name or Label === &lt;br /&gt;
&lt;br /&gt;
All objects in a document are data attributes of the corresponding [[App_DocumentObject|Document]] object. The attribute&amp;#039;s name correspond to the internal {{incode|Name}} of the object.&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
import LabRPS as App&lt;br /&gt;
&lt;br /&gt;
obj1 = App.ActiveDocument.Sim&lt;br /&gt;
obj2 = App.ActiveDocument.Sim001&lt;br /&gt;
obj3 = App.ActiveDocument.Sim002&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This is equivalent to using the {{incode|getObject}} method of the Document.&lt;br /&gt;
{{Code|code=&lt;br /&gt;
import LabRPS as App&lt;br /&gt;
&lt;br /&gt;
obj1 = App.ActiveDocument.getObject(&amp;#039;Sim&amp;#039;)&lt;br /&gt;
obj2 = App.ActiveDocument.getObject(&amp;#039;Sim001&amp;#039;)&lt;br /&gt;
obj3 = App.ActiveDocument.getObject(&amp;#039;Sim002&amp;#039;)&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
However, it is also possible to get the object by the more descriptive {{incode|Label}}.&lt;br /&gt;
{{Code|code=&lt;br /&gt;
import LabRPS as App&lt;br /&gt;
&lt;br /&gt;
obj1 = App.ActiveDocument.getObjectsByLabel(&amp;quot;Simulation of wind on the south building&amp;quot;)[0]&lt;br /&gt;
obj2 = App.ActiveDocument.getObjectsByLabel(&amp;quot;Cable-stayed bridge wind simulation&amp;quot;)[0]&lt;br /&gt;
obj3 = App.ActiveDocument.getObjectsByLabel(&amp;quot;Wind for buffeting analyis&amp;quot;)[0]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Given that the {{incode|Label}} is in general not unique, the {{incode|getObjectsByLabel}} method returns a list with all objects found with that {{incode|Label}}. However, if the {{incode|Label}} is unique in the document then the first element in that list should be the desired object.&lt;br /&gt;
&lt;br /&gt;
{{Userdocnavi}}&lt;/div&gt;</summary>
		<author><name>LabRPS</name></author>
	</entry>
</feed>