<?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=Scripting_tutorial</id>
	<title>Scripting tutorial - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.labrps.com/index.php?action=history&amp;feed=atom&amp;title=Scripting_tutorial"/>
	<link rel="alternate" type="text/html" href="https://wiki.labrps.com/index.php?title=Scripting_tutorial&amp;action=history"/>
	<updated>2026-05-07T13:59: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=Scripting_tutorial&amp;diff=2416&amp;oldid=prev</id>
		<title>LabRPS at 23:18, 22 November 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.labrps.com/index.php?title=Scripting_tutorial&amp;diff=2416&amp;oldid=prev"/>
		<updated>2024-11-22T23:18:00Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://wiki.labrps.com/index.php?title=Scripting_tutorial&amp;amp;diff=2416&amp;amp;oldid=1875&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>LabRPS</name></author>
	</entry>
	<entry>
		<id>https://wiki.labrps.com/index.php?title=Scripting_tutorial&amp;diff=1875&amp;oldid=prev</id>
		<title>LabRPS: /* Vectors and placements */</title>
		<link rel="alternate" type="text/html" href="https://wiki.labrps.com/index.php?title=Scripting_tutorial&amp;diff=1875&amp;oldid=prev"/>
		<updated>2024-10-12T15:01:06Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Vectors and placements&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:01, 12 October 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l114&quot;&gt;Line 114:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 114:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Another common feature of LabRPS objects is their [[Placement|placement]]. Each object has a {{PropertyData|Placement}} property, which contains the {{PropertyData|Base}} (position) and {{PropertyData|Rotation}} (orientation) of the object. It is easy to manipulate, for example to move our object:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Another common feature of LabRPS &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;geometry &lt;/ins&gt;objects is their [[Placement|placement]]. Each object has a {{PropertyData|Placement}} property, which contains the {{PropertyData|Base}} (position) and {{PropertyData|Rotation}} (orientation) of the object. It is easy to manipulate, for example to move our object:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Code|code=&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Code|code=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>LabRPS</name></author>
	</entry>
	<entry>
		<id>https://wiki.labrps.com/index.php?title=Scripting_tutorial&amp;diff=1874&amp;oldid=prev</id>
		<title>LabRPS: /* Writing Python code */</title>
		<link rel="alternate" type="text/html" href="https://wiki.labrps.com/index.php?title=Scripting_tutorial&amp;diff=1874&amp;oldid=prev"/>
		<updated>2024-10-12T14:55:05Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Writing Python code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:55, 12 October 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l33&quot;&gt;Line 33:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 33:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;There are two ways to write Python code in LabRPS. In the [[Python console|Python console]] (select {{MenuCommand|View → Panels → Python console}} from the menu) or in the [[Std_DlgMacroExecute|Macro editor]] (select {{MenuCommand|Macro → Macros...}} from the menu). In the console you write Python commands one by one, executing them by pressing {{KEY|Enter}}, while macros can contain more complex code made up of several lines, executed only when the macro is executed.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;There are two ways to write Python code in LabRPS. In the [[Python console|Python console]] (select {{MenuCommand|View → Panels → Python console}} from the menu) or in the [[Std_DlgMacroExecute|Macro editor]] (select {{MenuCommand|Macro → Macros...}} from the menu). In the console you write Python commands one by one, executing them by pressing {{KEY|Enter}}, while macros can contain more complex code made up of several lines, executed only when the macro is executed.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Image:&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Screenshot_pythoninterpreter&lt;/del&gt;.&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;jpg&lt;/del&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Image:&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;LabRPS_Python_console_example&lt;/ins&gt;.&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;png&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Caption|The LabRPS Python console}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Caption|The LabRPS Python console}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>LabRPS</name></author>
	</entry>
	<entry>
		<id>https://wiki.labrps.com/index.php?title=Scripting_tutorial&amp;diff=1873&amp;oldid=prev</id>
		<title>LabRPS: Created page with &quot;{{Docnav |Introduction to Python |LabRPS Scripting Basics }}  {{TOCright}}  ==Introduction==   [https://en.wikipedia.org/wiki/Python_%28programming_language%29 Python] is a programming language that it relatively easy to learn and understand. It is open-source and multi-platform, and can be used for many purposes: from simple shell scripts to very complex programs. But its most widespread use is as a scripting langua...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.labrps.com/index.php?title=Scripting_tutorial&amp;diff=1873&amp;oldid=prev"/>
		<updated>2024-10-12T14:51:22Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Docnav |&lt;a href=&quot;/Introduction_to_Python&quot; title=&quot;Introduction to Python&quot;&gt;Introduction to Python&lt;/a&gt; |&lt;a href=&quot;/LabRPS_Scripting_Basics&quot; title=&quot;LabRPS Scripting Basics&quot;&gt;LabRPS Scripting Basics&lt;/a&gt; }}  {{TOCright}}  ==Introduction==   [https://en.wikipedia.org/wiki/Python_%28programming_language%29 Python] is a programming language that it relatively easy to learn and understand. It is open-source and multi-platform, and can be used for many purposes: from simple shell scripts to very complex programs. But its most widespread use is as a scripting langua...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Docnav&lt;br /&gt;
|[[Introduction_to_Python|Introduction to Python]]&lt;br /&gt;
|[[LabRPS_Scripting_Basics|LabRPS Scripting Basics]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{TOCright}}&lt;br /&gt;
&lt;br /&gt;
==Introduction== &lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Python_%28programming_language%29 Python] is a programming language that it relatively easy to learn and understand. It is open-source and multi-platform, and can be used for many purposes: from simple shell scripts to very complex programs. But its most widespread use is as a scripting language embedded in other applications. That is how it is used inside LabRPS. From the [[Python_console|Python console]], or from custom scripts, you can control LabRPS and make it perform very complex operations.&lt;br /&gt;
&lt;br /&gt;
For example, from a Python script, you can:&lt;br /&gt;
* Create new objects.&lt;br /&gt;
* Modify existing objects.&lt;br /&gt;
* Modify the 3D representation of geometric objects.&lt;br /&gt;
* Modify the LabRPS interface.&lt;br /&gt;
&lt;br /&gt;
There are several ways to use Python in LabRPS:&lt;br /&gt;
* From the [[LabRPS Scripting Basics|LabRPS Python interpreter]], where you can issue commands in a &amp;quot;command line&amp;quot;-style interface.&lt;br /&gt;
* From [[macros|macros]], which are a convenient way to quickly add a missing tool to the LabRPS interface.&lt;br /&gt;
* From external scripts, which can be used to create quite complex solutions, even entire [[Workbenches|Workbenches]].&lt;br /&gt;
&lt;br /&gt;
In this tutorial, we&amp;#039;ll work on a couple of basic examples to get you started, but there is much more [[Power users hub|documentation about Python scripting]] available on this wiki. If you are totally new to Python and want to understand how it works, we also have a basic [[introduction to Python|introduction to Python]].&lt;br /&gt;
&lt;br /&gt;
Before proceeding with Python scripting, go to {{MenuCommand|Edit → Preferences → General → Report view}} and check two boxes:&lt;br /&gt;
* {{MenuCommand|Redirect internal Python output to report view}}.&lt;br /&gt;
* {{MenuCommand|Redirect internal Python errors to report view}}.&lt;br /&gt;
Then go to {{MenuCommand|View → Panels}} and check:&lt;br /&gt;
* {{MenuCommand|Report view}}.&lt;br /&gt;
&lt;br /&gt;
==Writing Python code== &lt;br /&gt;
&lt;br /&gt;
There are two ways to write Python code in LabRPS. In the [[Python console|Python console]] (select {{MenuCommand|View → Panels → Python console}} from the menu) or in the [[Std_DlgMacroExecute|Macro editor]] (select {{MenuCommand|Macro → Macros...}} from the menu). In the console you write Python commands one by one, executing them by pressing {{KEY|Enter}}, while macros can contain more complex code made up of several lines, executed only when the macro is executed.&lt;br /&gt;
&lt;br /&gt;
[[Image:Screenshot_pythoninterpreter.jpg]]&lt;br /&gt;
{{Caption|The LabRPS Python console}}&lt;br /&gt;
&lt;br /&gt;
In this tutorial you can use both methods. You can copy-paste each line in the Python console and then press {{KEY|Enter}}, or copy-paste the entire code in a new Macro window.&lt;br /&gt;
&lt;br /&gt;
{{Top}}&lt;br /&gt;
&lt;br /&gt;
==Exploring LabRPS== &lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s start by creating a new empty document:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
doc = LabRPS.newDocument()&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
If you type this in the LabRPS Python console, you will notice that as soon as you type {{incode|LabRPS.}} a window pops up, allowing to quickly autocomplete the rest of your line. Even better, each entry in the autocomplete list has a tooltip explaining what it does. This makes it easier to explore the available functionality. Before choosing {{incode|newDocument}}, have a look at the other options.&lt;br /&gt;
&lt;br /&gt;
[[Image:Screenshot_classbrowser.jpg]]&lt;br /&gt;
{{Caption|The autocomplete mechanism of the LabRPS Python console}}&lt;br /&gt;
&lt;br /&gt;
Now our new document will be created. This is similar to pressing the {{Button|[[Image:Std_New.svg|16px]] [[Std_New|New]]}} button on the toolbar. In fact most buttons in LabRPS do nothing more than execute one or more lines of Python code. Even better, you can set an option in {{MenuCommand|Edit → Preferences → Python → Macro}} to {{MenuCommand|Show script commands in python console}}. This will print in the console all Python code executed when you press buttons. Very useful for learning how to reproduce actions in Python.&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s get back to our document and see what we can do with it:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
doc.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Explore the available options. Usually names that begin with a capital letter are attributes, they contain a value, while names that begin with a lower case letter are functions (also called methods), they &amp;quot;do something&amp;quot;. Names that begin with an underscore are usually there for the internal working of the module, and you shouldn&amp;#039;t care about them. Let&amp;#039;s use one of the methods to add a new object to our document:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
myPoint = doc.addObject(&amp;quot;Part::Vertex&amp;quot;, &amp;quot;mysimulationPoint&amp;quot;)&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Nothing happens. Why? Because LabRPS is made for the big picture. One day, it will work with hundreds of complex objects, all depending each other. Making a small change somewhere could have a big impact; you may need to recalculate the whole document which could take a long time. For that reason almost no command updates the scene automatically. You must do it manually:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
doc.recompute()&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now our point appeared. Many of the buttons that add objects in LabRPS actually do two things: add the object, and recompute. If you turned on the {{MenuCommand|Show script commands in python console}} option above, try adding a sphere with the GUI button; you&amp;#039;ll see the two lines of Python code being executed one after the other.&lt;br /&gt;
If your point is still not visible, it may due to the fact that your point size is too small. In this case you can use the following code to increase the point size to for example 20.&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
LabRPSGui.getDocument(doc.Name).getObject(&amp;#039;mysimulationPoint&amp;#039;).PointSize = 20&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now let&amp;#039;s explore the contents of our point:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
myPoint.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
You&amp;#039;ll immediately see a couple of very interesting things such as:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
myPoint.X&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This will print the current X coordinate of our point. Now let&amp;#039;s try to change that:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
myPoint.X = 100&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
If you select your point with the mouse, you&amp;#039;ll see that in the [[Property_editor|Property editor]], on the {{MenuCommand|Data}} tab, our {{PropertyData|X}} property appears. All properties of a LabRPS object that appear there (and also on the {{MenuCommand|View}} tab, more about that later), are directly accessible in Python too, by their names, like we did with the {{PropertyData|X}} property. Try changing the other parameters of the point.&lt;br /&gt;
&lt;br /&gt;
{{Top}}&lt;br /&gt;
&lt;br /&gt;
==Vectors and placements==&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/Euclidean_vector Vectors] are a very fundamental concept in any 3D application. A vector is a list of 3 numbers (x, y and z), describing a point or position in 3D space. Many things can be done with vectors, such as additions, subtractions, projections and [https://en.wikipedia.org/wiki/Vector_space much more]. In LabRPS vectors work like this:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
myvec = LabRPS.Vector(2, 0, 0)&lt;br /&gt;
myvec.x&lt;br /&gt;
myvec.y&lt;br /&gt;
othervec = LabRPS.Vector(0, 3, 0)&lt;br /&gt;
sumvec = myvec.add(othervec)&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Another common feature of LabRPS objects is their [[Placement|placement]]. Each object has a {{PropertyData|Placement}} property, which contains the {{PropertyData|Base}} (position) and {{PropertyData|Rotation}} (orientation) of the object. It is easy to manipulate, for example to move our object:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
box.Placement&lt;br /&gt;
box.Placement.Base&lt;br /&gt;
box.Placement.Base = sumvec&lt;br /&gt;
 &lt;br /&gt;
otherpla = LabRPS.Placement()&lt;br /&gt;
box.Placement = otherpla&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now you must understand a couple of important concepts before we get further.&lt;br /&gt;
&lt;br /&gt;
{{Top}}&lt;br /&gt;
&lt;br /&gt;
==App and Gui== &lt;br /&gt;
&lt;br /&gt;
LabRPS has been designed so that it can also be used without its user interface, as a command-line application. Almost every object in LabRPS therefore consists of two parts: an {{incode|Object}}, its &amp;quot;geometry&amp;quot; component, and a {{incode|ViewObject}}, its &amp;quot;visual&amp;quot; component. When you work in command-line mode, the geometry part is present, but the visual part is disabled.&lt;br /&gt;
&lt;br /&gt;
To illustrate the concept let&amp;#039;s look at our cube object. The geometric properties of the cube, such as its dimensions, position, etc. are stored in the {{incode|Object}}. While its visual properties, such as its color, line thickness, etc. are stored in the {{incode|ViewObject}}. This corresponds to the &amp;#039;&amp;#039;&amp;#039;Data&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;View&amp;#039;&amp;#039;&amp;#039; tabs in the [[Property_editor|Property editor]]. The view object of an object is accessed like this:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
vo = box.ViewObject&lt;br /&gt;
}}&lt;br /&gt;
Now you can also change the properties on the &amp;#039;&amp;#039;&amp;#039;View&amp;#039;&amp;#039;&amp;#039; tab:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
vo.Transparency = 80&lt;br /&gt;
vo.hide()&lt;br /&gt;
vo.show()&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
When you start LabRPS, the Python console already loads two base modules: {{incode|LabRPS}} and {{incode|LabRPSGui}} (which can also be accessed by their shortcuts {{incode|App}} and {{incode|Gui}}). They contain all kinds of generic functionality to work with documents and their objects. To illustrate our concept, see that both {{incode|LabRPS}} and {{incode|LabRPSGui}} contain an {{incode|ActiveDocument}} attribute, which is the currently opened document. {{incode|LabRPS.ActiveDocument}} and {{incode|LabRPSGui.ActiveDocument}} are not the same object however. They are the two components of a LabRPS document, and they contain different attributes and methods. For example, {{incode|LabRPSGui.ActiveDocument}} contains {{incode|ActiveView}}, which is the currently opened [[3D_view|3D view]].&lt;br /&gt;
&lt;br /&gt;
{{Top}}&lt;br /&gt;
&lt;br /&gt;
==Modules== &lt;br /&gt;
&lt;br /&gt;
The true power of LabRPS lies in its faithful modules, with their respective workbenches. The LabRPS base application is more or less an empty container. Without its modules it can do little more than create new, empty documents. Each module not only adds new workbenches to the interface, but also new Python commands and new object types. As a result several different, and even totally incompatible, object types can coexist in the same document. The most important modules in LabRPS that we&amp;#039;ll look at in this tutorial are: [[Part_Workbench|Part]] and [[WindLab_Workbench|WindLab]].&lt;br /&gt;
&lt;br /&gt;
[[Part_Workbench|Part]] module is used to create and handle geometry. While [[WindLab_Workbench|WindLab]] is totally independent, and handles its own objects. It is for random wind velocity simulation. More about that below.&lt;br /&gt;
&lt;br /&gt;
You can check all the available base object types for the current document like this:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
doc.supportedTypes()&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The different LabRPS modules are not automatically loaded in the Python console. This is to avoid having a very slow startup. Modules are loaded only when you need them. So, for example, to explore what&amp;#039;s inside the Part module:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
import Part&lt;br /&gt;
Part.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
But we&amp;#039;ll talk more about the Part module below.&lt;br /&gt;
&lt;br /&gt;
{{Top}}&lt;br /&gt;
&lt;br /&gt;
==Part module== &lt;br /&gt;
&lt;br /&gt;
The [[Part_Workbench|Part]] module is the only module in the whole of LabRPS for geometrical objects representation. It allows you to create and manipulate [https://en.wikipedia.org/wiki/Boundary_representation BRep] objects. BREP stands for &amp;quot;Boundary Representation&amp;quot;. A BREP object is defined by surfaces that enclose and define an inner volume. Unlike meshes, BREP objects can have a wide variety of components from planar faces to very complex NURBS surfaces.&lt;br /&gt;
&lt;br /&gt;
The Part module is based on the powerful [https://en.wikipedia.org/wiki/Open_CASCADE_Technology OpenCasCade] library, which allows a wide range of complex operations to be performed on those objects, such as boolean operations, filleting, lofts, etc.&lt;br /&gt;
&lt;br /&gt;
The Part module works the following way: You create a LabRPS object, a Part object, then add the Part object to the LabRPS object:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
import Part&lt;br /&gt;
myshape = Part.makeSphere(10)&lt;br /&gt;
myshape.Volume&lt;br /&gt;
myshape.Area&lt;br /&gt;
&lt;br /&gt;
shapeobj = doc.addObject(&amp;quot;Part::Feature&amp;quot;, &amp;quot;MyShape&amp;quot;)&lt;br /&gt;
shapeobj.Shape = myshape&lt;br /&gt;
doc.recompute()&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The Part module also has a shortcut that automatically creates a LabRPS object and adds a shape to it, so you can shorten the last three lines to:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
Part.show(myshape)&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
By exploring the contents of myshape, you will notice many interesting subcomponents such as {{incode|Faces}}, {{incode|Edges}}, {{incode|Vertexes}}, {{incode|Solids}} and {{incode|Shells}}, and a wide range of geometry operations such as {{incode|cut}} (subtraction), {{incode|common}} (intersection) or {{incode|fuse}} (union). The [[Topological_data_scripting|Topological data scripting]] page explains all that in detail.&lt;br /&gt;
&lt;br /&gt;
[[Topological_data_scripting|Read more about part scripting...]]&lt;br /&gt;
&lt;br /&gt;
{{Top}}&lt;br /&gt;
&lt;br /&gt;
==WindLab module== &lt;br /&gt;
&lt;br /&gt;
LabRPS features many more modules, such as [[WindLab_Workbench_Workbench|WindLab]], that creates RPS(Random Phenomenon Simulation) objects.&lt;br /&gt;
&lt;br /&gt;
The [[WindLab_Workbench_Workbench|WindLab]] module Wind velocity simulation object types (which are all RPS objects) such as wind spectrum and mean wind profile. Note that the way RPS objects are created is different from that of Part objects. The following example create:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
import WindLab&lt;br /&gt;
import WindLabObjects&lt;br /&gt;
sim = WindLabObjects.makeSimulation(doc)&lt;br /&gt;
spectrum = WindLabObjects.makeFeature(&amp;quot;Spectrum&amp;quot;, sim.Name,  &amp;quot;Kaimal Along Wind Spectrum&amp;quot;, &amp;quot;Along Wind Spectrum&amp;quot;)&lt;br /&gt;
spectrum.ShearVelocity = 1.76 m/s&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Top}}&lt;br /&gt;
&lt;br /&gt;
==Interface==&lt;br /&gt;
&lt;br /&gt;
The LabRPS user interface is made with [https://en.wikipedia.org/wiki/Qt_(software) Qt], a powerful graphical interface system, responsible for drawing and handling all the controls, menus, toolbars and buttons around the [[3D_view|3D view]]. Qt provides a module, [[PySide]], which allows Python to access and modify Qt interfaces such as LabRPS&amp;#039;s. Let&amp;#039;s try to fiddle with the Qt interface and produce a simple dialog:&lt;br /&gt;
&lt;br /&gt;
{{Code|code=&lt;br /&gt;
from PySide import QtGui&lt;br /&gt;
QtGui.QMessageBox.information(None, &amp;quot;Apollo program&amp;quot;, &amp;quot;Houston, we have a problem&amp;quot;)&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Notice that the dialog that appears has the LabRPS icon in its toolbar, meaning that Qt knows that the order has been issued from inside the LabRPS application. It is possible to manipulate any part of the LabRPS interface.&lt;br /&gt;
&lt;br /&gt;
Qt is a very powerful interface system that allows you to do very complex things. It also has some easy-to-use tools such as the Qt Designer with which you can design dialogs graphically and then add them to the LabRPS interface with a few lines of Python code.&lt;br /&gt;
&lt;br /&gt;
[[PySide|Read more about PySide here...]]&lt;br /&gt;
&lt;br /&gt;
{{Top}}&lt;br /&gt;
&lt;br /&gt;
==Macros== &lt;br /&gt;
&lt;br /&gt;
Now that you have a good understanding of the basics, where are we going to keep our Python scripts, and how are we going to launch them inside LabRPS? There is an easy mechanism for that, called [[Macros|Macros]]. A macro is a Python script that can be added to a toolbar and launched via a mouse click. LabRPS provides you with a simple text editor ({{MenuCommand|Macro → Macros... → Create}}) where you can write or paste scripts. Once the script is done, use {{MenuCommand|Tools → Customize... → Macros}} to define a button for it that can be added to toolbars.&lt;br /&gt;
&lt;br /&gt;
==External scripts== &lt;br /&gt;
&lt;br /&gt;
An alternative method for creating, saving, and running your own Python scripts is to create them outside LabRPS, using an editor of your choice (for example, Vim). To run your Python script inside LabRPS, be sure to save it with the {{FileName|.py}} extension.&lt;br /&gt;
&lt;br /&gt;
Then use {{MenuCommand|File → Open}} to open your script. It will load into a new tab in the [[Main_view_area|Main view area]]. You can run your script by clicking the {{Button|[[Image:Std_DlgMacroExecuteDirect.svg|16px]] [[Std_DlgMacroExecuteDirect|Execute macro]]}} button. Any errors or script output will be shown in the [[Report_view|Report view]].&lt;br /&gt;
&lt;br /&gt;
When you make and save any modifications to your already-loaded script, a dialog box will appear asking whether you want to reload the modified script into LabRPS.&lt;br /&gt;
&lt;br /&gt;
You can continue to the [[LabRPS_Scripting_Basics|LabRPS Scripting Basics]] page, or you can access that page and other relevant pages at the [[Power_users_hub|Power users hub]].&lt;br /&gt;
&lt;br /&gt;
{{Top}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Docnav&lt;br /&gt;
|[[Introduction_to_Python|Introduction to Python]]&lt;br /&gt;
|[[LabRPS_Scripting_Basics|LabRPS Scripting Basics]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{Powerdocnavi}}&lt;br /&gt;
[[Category:Developer Documentation]]&lt;br /&gt;
[[Category:Python Code]]&lt;/div&gt;</summary>
		<author><name>LabRPS</name></author>
	</entry>
</feed>