Hi,
I'm looking at the new ScriptObject PythonPart and for my first example I want to select a Polyline2D to create a volume.
I have a error when I want to get the polyline geometry
Can you help me to have the correct syntaxt ?
import NemAll_Python_Geometry as Geometry import NemAll_Python_BaseElements as BaseElements import NemAll_Python_IFW_ElementAdapter as ElementAdapter from BaseScriptObject import BaseScriptObject from BaseScriptObject import BaseScriptObjectData from ScriptObjectInteractors.SingleElementSelectInteractor import SingleElementSelectInteractor from ScriptObjectInteractors.SingleElementSelectInteractor import SingleElementSelectResult from BuildingElement import BuildingElement from CreateElementResult import CreateElementResult from TypeCollections.ModelEleList import ModelEleList from PythonPartUtil import PythonPartUtil 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_script_object(build_ele: BuildingElement, script_object_data: BaseScriptObjectData) -> BaseScriptObject: """ Creation of the script object Args: build_ele: building element with the parameter properties script_object_data: script object data Returns: created script object """ return ScriptObject(build_ele, script_object_data) class ScriptObject(BaseScriptObject): """ Implementation of the script object class """ def __init__(self, build_ele: BuildingElement, script_object_data: BaseScriptObjectData): """ Initialization Args: build_ele: building element with the parameter properties script_object_data: script object data """ super().__init__(script_object_data) self.build_ele = build_ele self.selection_result = SingleElementSelectResult() def start_input(self): """ Selection of the polyline """ self.script_object_interactor = SingleElementSelectInteractor(self.selection_result, [ElementAdapter.Polyline2D_TypeUUID], "Sélectionner une polyligne") def start_next_input(self): self.script_object_interactor = None def execute(self) -> CreateElementResult: """ Execute the script Returns: created element result """ com_props = BaseElements.CommonProperties() polygon = self.selection_result.sel_element.GetGeometry() area = Geometry.PolygonalArea2D() area += polygon top_plane = Geometry.Plane3D(Geometry.Point3D(0, 0, 1000), Geometry.Vector3D(0, 0, 1)) bottom_plane = Geometry.Plane3D(Geometry.Point3D(0, 0, -1000), Geometry.Vector3D(0, 0, 1)) swept_solid = Geometry.ClippedSweptSolid3D(area, bottom_plane, top_plane) err, polyhedron = Geometry.CreatePolyhedron(swept_solid) model_ele_list = ModelEleList() pyp_util = PythonPartUtil() model_ele_list.append_geometry_3d(polyhedron, com_props) pyp_util.add_pythonpart_view_2d3d(model_ele_list) pythonpart = pyp_util.create_pythonpart(self.build_ele) return CreateElementResult(pythonpart)
Best
Christophe