icon

Support Forum

[Frage] SimplePythonParts.pyp error

Schlagworte:
  • Allplan
  • 2025-1-8
  • PythonParts
  • Learning

I followed the steps in the video to write the SimplePythonParts.pyp file. Something doesn't seem to be working right; part of the tutorial is for version 2025, but the rest—including the directory setup—is for version 2024. When I create the directories and run SimplePythonParts, I get this error. What could be causing this?

Anhänge (1)

Typ: image/jpeg
10-mal heruntergeladen
Größe: 112,85 KiB

In addition, when I open some scripts installed by default by Allplan I see the same error message, others work fine, for example the one on Standard>AllepPlugins>AllplanGmbH>AllepManagement didn't show up the pop up but the one on Examples > PythonParts > BasisExamples > Objects > BitmapArea.

I added my own custom pyp on different paths at usr/Local/ (on windows there is this new folder), both with a custom level and without and it didn't find the corresponding .py script.
The .py script was added both on the usr/Local/Library/ or on usr directly but I always see the same error.

It would be nice if the pyp would show on hovering the full path of the script that is going to be used instead of the relative path. This way it will make it easier to debug this problem.

The debuger enabled with ctrl+F3 did show a temporary file stdmen.out with the following information that might be related to this problem:

HANDLES                                                         15:31:24   (0d, 0h,40m,15s)   GDI: 1279 [  +0] Msg="Stop handle input", EventID=1981. finished
EVENT_PSO_INSERT_OBJECT                                         15:31:24   (0d, 0h,40m,15s)   GDI: 1279 [  +0] PALETTE
EVENT_LKOMEN_ANS_GRUNDRISS                                      15:31:34   (0d, 0h,40m,25s)   GDI: 1443 [+164] 
EVENT_LKOMEN_ANS_GRUNDRISS                                      15:31:34   (0d, 0h,40m,25s)   GDI: 1443 [  +0] finished
    2 x CHECK_AND_UPDATE                                        15:31:41   (0d, 0h,40m,32s)   GDI: 1426 [ -17]
    1 x END_OF_ARRAY_SHORTED                                    15:31:41   (0d, 0h,40m,32s)   GDI: 1426 [  +0]
Warning: Missing CHECK_AND_UPDATE after shorten Array           15:31:41   (0d, 0h,40m,32s)   GDI: 1427 [  +1]
EVENT_PSO_INSERT_OBJECT                                         15:31:41   (0d, 0h,40m,32s)   GDI: 1427 [  +0] finished
HANDLES                                                         15:31:41   (0d, 0h,40m,32s)   GDI: 1427 [  +0] Msg="Start handle input", EventID=1981.
HANDLES                                                         15:32:03   (0d, 0h,40m,54s)   GDI: 1424 [  -3] Msg="Stop handle input", EventID=1985. finished
EVENT_SAVE_PYTHONPART                                           15:32:03   (0d, 0h,40m,54s)   GDI: 1424 [  +0] PALETTE
EVENT_SAVE_PYTHONPART                                           15:32:18   (0d, 0h,41m, 9s)   GDI: 1426 [  +2] finished
HANDLES                                                         15:32:18   (0d, 0h,41m, 9s)   GDI: 1426 [  +0] Msg="Start handle input", EventID=1985.
HANDLES                                                         15:32:43   (0d, 0h,41m,34s)   GDI: 1461 [ +35] Msg="Stop handle input", EventID=0. finished
EVENT_LKOMEN_ELEMENTINFO_SPEZ                                   15:32:43   (0d, 0h,41m,34s)   GDI: 1464 [  +3] CM_MODI
    6 x CHECK_AND_UPDATE                                        15:32:55   (0d, 0h,41m,46s)   GDI: 1454 [ -10]
EVENT_LKOMEN_ELEMENTINFO_SPEZ                                   15:32:55   (0d, 0h,41m,46s)   GDI: 1454 [  +0] finished
HANDLES                                                         15:32:55   (0d, 0h,41m,46s)   GDI: 1454 [  +0] Msg="Start handle input", EventID=0.
HANDLES                                                         15:33:03   (0d, 0h,41m,54s)   GDI: 1454 [  +0] Msg="Stop handle input", EventID=1073. finished
EVENT_ALLG_LOESCHEN                                             15:33:03   (0d, 0h,41m,54s)   GDI: 1456 [  +2] ACTIONBAR
    1 x CHECK_AND_UPDATE                                        15:33:05   (0d, 0h,41m,56s)   GDI: 1453 [  -3]
EVENT_ALLG_LOESCHEN                                             15:33:05   (0d, 0h,41m,56s)   GDI: 1453 [  +0] finished
HANDLES                                                         15:33:05   (0d, 0h,41m,56s)   GDI: 1455 [  +2] Msg="Start handle input", EventID=1073.
EVENT_LKOMEN_BILD_AUF_SCHIRM                                    15:36:28   (0d, 0h,45m,19s)   GDI: 1455 [  +0] 
EVENT_LKOMEN_BILD_AUF_SCHIRM                                    15:36:28   (0d, 0h,45m,19s)   GDI: 1455 [  +0] finished

I added a new script on Library/PythonPartsLearning3/SimplePythonPart.pyp:

<?xml version="1.0" encoding="UTF-8"?>
<Element>
        <Script>
            <Name> PythonPartsLearningScripts\PythonScriptsLearning.py</Name>
            <Title> Simple PythonPart</Title>
            <version>0.1</version>
        </Script>
</Element>

The script is present on Usr\Local\PythonPartsExampleScripts\PythonPartsTraining\PythonPartsTraining.py:


import NemAll_Python_BaseElements as AllplanBaseElements
import NemAll_Python_BasisElements as AllplanBasisElements
import NemAll_Python_Geometry as AllplanGeometry
import NemAll_Python_IFW_ElementAdapter as AllplanElementAdapter

from BuildingElement import BuildingElement
from CreateElementResult import CreateElementResult

def check_allplan_version(build_ele: BuildingElement,
                          version: float) -> bool:
    """Called when the PythonPart is started to check, if the current
    Allplan version is supported.

    Args:
        build_ele: building element with the parameter properties
        version:   current Allplan version

    Returns:
        True if current Allplan version is supported and PythonPart script can be run, False otherwise
    """

    return True

def create_preview(build_ele: BuildingElement,
                   doc: AllplanElementAdapter.DocumentAdapter) -> CreateElementResult:
    """Function for the creation of the library preview elements.

    Args:
        build_ele: the building element.
        doc:       input document

    Returns:
        Preview elements. Only elements included in the property "elements" will be shown in the library preview
    """
    cuboid_geo = AllplanGeometry.Polyhedron3D.CreateCuboid(
        placement= AllplanGeometry.AxisPlacement3D(),
        length= 3000,
        width= 2000,
        height= 1000)

    common_properties = AllplanBaseElements.CommonProperties()

    cuboid = AllplanBasisElements.ModelElement3D(common_properties, cuboid_geo)

    return CreateElementResult(elements=[cuboid])

Anhänge (1)

Typ: image/jpeg
2-mal heruntergeladen
Größe: 114,49 KiB