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 :
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.
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 :
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 :
0 Comments