Skip to content

Include parameter

Within a .pyp file it is possible to include the parameters of another .pyp file using the #include directive. A typical use case for that can be e.g., to include:

  • files with general PythonPart parameter
  • files with parameter blocks for indexing

into the current .pyp file. The use of the #include directive allows to define these parameters only once. This avoids a lot of typing and simplifies the modification of the pyp file. Here is how the general form of the statement look like:

Syntax
<Page>
    <Name>FirstPage</Name>
    <Text>Page text 1</Text>
    <TextId>1001</TextId>

    <!--(1)!-->#include _file_name;index1,text1;index2,text2;…|LanguageFile=IncludeParameter_incpyp

    <Parameter>
        </Parameter>
</Page>
  1. Note, that the #include statement must be added to the <Page> tag of the .pyp file.
Variable Definition
_file_name Path and name of the file to include. The path can be a relative path related to the current .pyp file or with a leading etc\, std\, usr\ or prj\ to make it globally a standard Allplan path.
index... Index of the parameter which will be added to the name value in all existing <Name> tags from the source file. The value can be a string, a single number or an index range like 2-4.
text... Text, which will replace the # character in all existing <Text> tags from the source file. The text can be a text ID like 1002. In case of an index range like 2-4, the index replaces the #.
LanguageFile=... Definition of the language file for the <TextId> tags from the include file. The path can be defined locally to the current pyp file or with a leading etc\, std\, usr\ or prj\ to make it globally a standard Allplan path. If the language file is not defined, the text for the IDs is taken from the resource file of the pyp file.

Warning

Note, that the path defined in _file_name remains untouched, when the PythonPart is moved/copied by the user within the Allplan library. In this case the main .pyp file is moved/copied, but the included files not, causing a relative path pointing to nonexistent file. Providing an absolute path with leading etc\, std\, usr\ or prj\ would be a solution.

Note

If the index value is an index range, the index can also be used to replace the # in a <Visible> or <Enable> tag defined like this:

<Visible>CoordCount .gt. #</Visible>

Example

<Page>
    <Name>FirstPage</Name>
    <Text>Page text 1</Text>
    <TextId>1001</TextId>

    #include IncludeParameter.incpyp<!--(1)!-->;Left,1002;2-4<!--(2)!-->;Right,1003<!--(3)!-->

    <Parameter>
        </Parameter>
</Page>
  1. The file suffix does not have to be .incpyp. Parameter from regular .pyp files can also be included.
  2. Note, that there is no text specified here, as the index is defined as a range!
  3. With this #include statement we will be including the parameter 5 times in total, with following indexes: Left, 2, 3, 4, Right.
<Parameter>
    <Name>Length</Name>
    <Text>Length #<!--(1)!--></Text>
    <TextId>2000</TextId>
    <Value>0</Value>
    <ValueType>Length</ValueType>
</Parameter>
  1. Placeholder for the text from the #include statement
<Item>
    <TextId>1002</TextId>
    <Text>links</Text>
</Item>
<Item>
    <TextId>1003</TextId>
    <Text>rechts</Text>
</Item>
<Item>
    <TextId>2000</TextId>
    <Text>Länge #<!--(1)!--></Text>
</Item>
  1. As the string in the <Text> tag in the source .pyp file contains the # placeholder, it is also needs to be specified in here.
<Page>
    <Name>FirstPage</Name>
    <Text>Page text 1</Text>
    <TextId>1001</TextId>

    <Parameter>
      <Name>LengthLeft</Name>
      <Text>Länge links</Text>
      <Value>0</Value>
      <ValueType>Length</ValueType>
    </Parameter>
    <Parameter>
      <Name>Length2</Name>
      <Text>Länge2</Text>
      <Value>0</Value>
      <ValueType>Length</ValueType>
    </Parameter>
    <Parameter>
      <Name>Length3</Name>
      <Text>Länge 3</Text>
      <Value>0</Value>
      <ValueType>Length</ValueType>
    </Parameter>
    <Parameter>
      <Name>Length4</Name>
      <Text>Länge 4</Text>
      <Value>0</Value>
      <ValueType>Length</ValueType>
    </Parameter>
    <Parameter>
      <Name>LengthRight</Name>
      <Text>Länge rechts</Text>
      <Value>0</Value>
      <ValueType>Length</ValueType>
    </Parameter>
</Page>

The use of the include statement is also shown in the example:

  • …\etc\Examples\PythonParts\PaletteExamples\IncludeParameter.pyp
  • …\etc\PythonPartsExampleScripts\PaletteExamples\IncludeParameter.py