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

Submit a Comment

Objects3D V2.0

Next step for the modeling of our PythonPart “Reinforced Concrete Column”, today let's see how to configure the anchors of our 3D object. By anchoring I am particularly thinking of 2 types :...

Objects3D V1.0

New series in the PythonParts learning journey, let's delve into the modeling of a 3D object : a reinforced concrete column.1) GUI ScriptIn this example, we will set up the initial fields required...

Objects2D V3.0

Last step for this PythonParts example, I'll show you how to set up a legend for our object. This should include the following information : my object's name ; the name of a characteristic geometric...

Objects2D V2.0

In the previous article, we saw how to prepare our code in OOP, today let's see how to exploit its potential with this new example. Indeed, we are going to complete our PythonPart in order to...

Objects2D V1.0

We will build more complex objects on Allplan software, but first at all a word about Object Oriented Programming (OOP)...1) Object Oriented ProgrammingObject Oriented Programming (called OOP) is a...

HelloWorld V2.0

Previously, we learned how to create an object (a line with fixed length) via the PythonParts API. Today I'm going to show you how to set up handles for our HelloWorld script...1) GUI ScriptThe...

HelloWorld V1.0

HelloWorld is traditionally written to provide an example of a programming language. We will be no exception here with our first script's writing. The goal is simple, create a line with fixed...

Structure of PythonParts

Allplan is installed, your IDE is ready... perfect, let's see in detail how PythonParts work.1) Files' DescriptionTo work, a PythonPart needs at least 2 files : GUI File The interface file...

Introduction

In this series of articles, we'll study the editing of scripts in the Python programming language for the Allplan software.To allow you to follow these tutorials properly, I'm going to make a few...