Last step for our HelloWorld script, we will see how to customize the rendering of our object.
1) GUI Script
Back in our palette, I first create a chapter to dissociate the geometric controls from those dedicated to rendering :
<Parameter>
<Name>GeometryExpander</Name>
<Text>Géométrie</Text>
<ValueType>Expander</ValueType>
</Parameter>
Inside the latter, I put my previous variable for the line’s length, so I obtain :
<Parameter>
<Name>GeometryExpander</Name>
<Text>Géométrie</Text>
<ValueType>Expander</ValueType>
<Parameter>
<Name>LineLength</Name>
<Text>Longueur</Text>
<Value>1000.0</Value>
<ValueType>Length</ValueType>
</Parameter>
</Parameter>
Here is the rendering in Allplan :
![01.05 geometry expander from allplan](https://api2gether.com/wp-content/uploads/2023/02/01.05-geometry-expander-from-allplan.png)
I can now create a new Expander for rendering :
<Parameter>
<Name>FormatExpander</Name>
<Text>Format</Text>
<ValueType>Expander</ValueType></Parameter>
Before integrating my render settings, I’ll make the following assumptions :
- the user uses the current settings in Allplan ;
- or he personalizes them.
Current settings
Default choice, I will simply create a checkbox :
<Parameter>
<Name>UseGlobalProperties</Name>
<Text>Utiliser les paramètres courants</Text>
<Value>True</Value>
<ValueType>CheckBox</ValueType>
</Parameter>
Please note : set Value to True indicates that the box is checked when the PythonPart is launched.
![01.05 format expander from allplan](https://api2gether.com/wp-content/uploads/2023/09/01.05-format-expander-from-allplan.png)
Custom settings
In this case, the user will be able to choose :
- the pen ;
- the stroke ;
- the color ;
- the layer ;
- …
Allplan allows us to load all these parameters at once with the code below :
<Parameter>
<Name>CommonProperties</Name>
<Text></Text>
<Value></Value>
<ValueType>CommonProperties</ValueType>
</Parameter>
Back on Allplan, we see this :
![01.05 custom properties from allplan](https://api2gether.com/wp-content/uploads/2023/09/01.05-custom-properties-from-allplan.png)
The different fields work but we have a display problem.
Indeed, I want to hide the customization options if the current values’box is checked.
So, I will add for each of the parameters the following visibility option :
<Visible>UseGlobalProperties == False</Visible>
Please note : UseGlobalProperties is the Name value of the parameter to test.
Here is the complete source code :
2) Main Script
For the Python script, I’ll go directly to the create_element function.
I complete the rendering properties by replacing :
com_prop = AllplanBaseElements.CommonProperties()
com_prop.GetGlobalProperties()
with :
if build_ele.UseGlobalProperties.value:
com_prop = BaseElements.CommonProperties()
com_prop.GetGlobalProperties()
else:
com_prop = build_ele.CommonProperties.value
If the condition of the check box is verified, the global settings are used, otherwise the values defined via the palette are taken over.
Here is the complete source code :
Here is our PythonPart :
![01.05 helloworld with global properties from allplan](https://api2gether.com/wp-content/uploads/2023/09/01.05-helloworld-with-global-properties-from-allplan.png)
![01.05 helloworld with custom properties from allplan](https://api2gether.com/wp-content/uploads/2023/09/01.05-helloworld-with-custom-properties-from-allplan.png)
0 Comments