Button
If some actions need to be triggered manually by the user of the PythonPart, a good idea to make it possible is to place a button in the palette. Because there are two texts needed (one for the button and one for the text on the left side of it) the button must be placed in a row. Here is a short example of how it should be done:
<Parameter>
<Name>ButtonRow</Name>
<Text>Button</Text> <!--(1)!-->
<ValueType>Row</ValueType>
<Parameter>
<Name>Button</Name>
<Text>ButtonText</Text> <!--(2)!-->
<EventId>1000</EventId> <!--(3)!-->
<ValueType>Button</ValueType>
</Parameter>
</Parameter>
- This text will appear on the left side of a button...
- ...this, however, on the button itself. If it is too long, only the end will be displayed directly on the button. The complete text will be displayed as a tooltip.
- This value is passed to the script to determine, which button was clicked. If there are several buttons in the palette that should do the same job, you can assign the same EventId to them.
In order to control, which action should be triggered in the script, use the tag <EventId>
.
When a button is clicked, the function on_control_event
is called and the the value of <EventId>
tag is being given as (one of the) arguments. Here is how the
implementation in a script can look like:
Special button types
Button with hyperlink
To open a web page directly when a button is clicked, provide the address within
the <Value>
tag to the parameter as follows:
<Parameter>
<Name>Button</Name>
<Text>ButtonText</Text>
<EventId>1000</EventId>
<ValueType>Button</ValueType>
<Value>https://www.allplan.com</Value>
</Parameter>
Button with picture
To create a button with an icon from Allplan's internal image resources, set the <ValueType>
to PictureResourceButton
<Parameter>
<Name>PictureResourceButton</Name>
<Text>Button tooltip</Text><!--(1)!-->
<EventId>1000</EventId>
<Value>17027</Value> <!--(2)!-->
<ValueType>PictureResourceButton</ValueType>
</Parameter>
- Tooltip text, which will appear by hovering over the button
-
Provide the ID of the picture resource here. Click on the desired icon below - to copy the ID to your clipboard
To create a button with your own icon from a .png file, set the <ValueType>
to PictureButton
<Parameter>
<Name>PictureButton</Name>
<Text>Tooltip text</Text><!--(1)!-->
<EventId>1000</EventId>
<Value>ButtonImageReset16.png</Value><!--(2)!-->
<ValueType>PictureButton</ValueType>
</Parameter>
- Tooltip text, which will appear by hovering over the button
- Path must be relative to the .pyp file
Multiple buttons
To place several buttons in a row, each with an icon from Allplan's internal
image resources, set the <ValueType>
to PictureResourceButtonList
<Parameter>
<Name>EdgeOffsetType</Name>
<Text>Integer value list</Text><!--(1)!-->
<Value>0</Value><!--(2)!-->
<ValueList>0|1|2|3|4</ValueList><!--(3)!-->
<ValueTextList><!--(4)!-->Zero at start|Major value at start|Start equal end|Major value at end|Zero at end</ValueTextList>
<ValueList2>12151|12147|12149|12153|12145</ValueList2><!--(5)!-->
<ValueType>PictureResourceButtonList</ValueType>
</Parameter>
- This text will appear on the left side of the buttons
- The value defined here will be selected by default
- These integer values correspond with the buttons. They must be separated by
|
. Alternatively, use<EnumList>
to define options of enumeration classes here (see below) - These texts will appear as tooltip, when the user hovers the mouse over the corresponding button. You can localize them (learn more here)
-
Provide the IDs of the picture resources separated by
|
. Click on the desired icon below - to copy the ID to your clipboard
To place several buttons in a row, each with your own icon from a .png file, set
the <ValueType>
to PictureButtonList.
<Parameter>
<Name>IntegerValueList</Name>
<Text>Integer value list</Text><!--(1)!-->
<Value>1</Value><!--(2)!-->
<ValueList>1|2|3</ValueList><!--(3)!-->
<ValueTextList>Value=1|Value=2|Value=3</ValueTextList><!--(4)!-->
<ValueList2>..\param01.png|..\param02.png|..\param03.png</ValueList2><!--(5)!-->
<ValueType>PictureButtonList</ValueType>
</Parameter>
- This text will appear on the left side of the buttons
- The value defined here will be selected by default
- These integer values correspond with the buttons. They must be separated by
|
. Alternatively, use<EnumList>
to define options of enumeration classes here (see below) - These texts will appear as tooltip, when the user hovers the mouse over the corresponding button. You can localize them (learn more here)
- The path for the images must be relative to .pyp file and separated with
|
Alternatively to <ValueList>
tag, where the values are integers, it is also possible to
define the <EnumList>
tag, where the values are options of any enumeration class.
<Parameter>
<Name>ShapeType</Name>
<Text>Rectangle|Round/oval</Text>
<Value>AllplanArchEle.VerticalOpeningShapeType.eRectangle</Value>
<EnumList>AllplanArchEle.VerticalOpeningShapeType.eRectangle|
AllplanArchEle.VerticalOpeningShapeType.eCircle</EnumList>
<ValueList2>AllplanSettings.PictResShapeType.eRectangle|
AllplanSettings.PictResShapeType.eCircle</ValueList2>
<ValueType>PictureResourceButtonList</ValueType>
</Parameter>
Tip
This kind of buttons are not intended to be an event trigger, because they
do not have the value of <EventId>
assigned to them. To use them as triggers,
the implementation must be done within the modify_element_property function:
Button for a reference point
The value type RefPointButton is used to create a button for a selection of a reference point ID. This kind of button gives an integer value that corresponds with the selected point, as defined in the enumeration class RefPointButtonType.
<Parameter>
<Name>RefPointId</Name>
<Text>Reference point index</Text>
<Value><!--(1)!-->AllplanPalette.RefPointPosition.eCenterCenter</Value>
<ValueType>RefPointButton</ValueType>
<EnumList2><!--(2)!-->AllplanPalette.RefPointButtonType.eCornersCenter</EnumList2>
</Parameter>
- The default value can be defined as an option of RefPointButtonType class or as an integer
- Optionally, you can set, what reference points should be available. See possible options in the RefPointButtonType enumeration class.
Material selection
The value type MaterialButton is used to create a button for the selection of a material surface (.surf file) that can the assigned to a PythonPart for visualization purposes. After clicking the button, the dialog for custom surface selection will be opened.
<Parameter>
<Name>MaterialButton</Name>
<Text>MaterialButton</Text>
<Value>Glass</Value><!--(1)!-->
<ValueType>MaterialButton</ValueType>
<DisableButtonIsShown>True</DisableButtonIsShown><!--(2)!-->
</Parameter>
- The
<Value>
stands for the name of the .surf file Optional
By setting this tag to false you can disable the small button on the right, which is used to reset the input value.
Additional tags
Text size
The size of the text appearing on the button can be controlled by an optional tag <FontStyle>
<Parameter>
<Name>Row1</Name>
<Text>Font style = 0</Text>
<ValueType>Row</ValueType>
<Parameter>
<Name>Button1</Name>
<Text>Small text</Text>
<EventId>1000</EventId>
<ValueType>Button</ValueType>
<FontStyle>0</FontStyle><!--(1)!-->
</Parameter>
</Parameter>
-
Possible options for the tag are:
Value Style 0 small 1 extra small 2 large