13.01.2022 - 15:11
Uhr
Hallo!
Ich arbeite gerade an einen PythonPart das ein Paar LabelElements enthalten soll. Bei der ersten erstellung des PythonParts funktioniert alles gut, aber wenn man das PythonPart ändert werden die alten labellen nicht gelöscht.
Minimal reproducable code:
Python:
import NemAll_Python_BaseElements as AllplanBaseElements import NemAll_Python_BasisElements as AllplanBasisElements import NemAll_Python_Geometry as AllplanGeo from PythonPart import View2D3D, PythonPart # Method for checking the supported versions def check_allplan_version(build_ele, version): # Delete unused arguments del build_ele del version # Support all versions return True def create_label(text, pos, com_prop=AllplanBaseElements.CommonProperties(), text_prop=AllplanBasisElements.TextProperties()): text_ele = AllplanBasisElements.TextElement(com_prop, text_prop, text, AllplanGeo.Point2D(*pos)) return AllplanBasisElements.LabelElement(text_ele, AllplanBasisElements.eLabelNormalText) # Method for element creation def create_element(build_ele, doc): model_ele_list = [] handle_list = [] com_prop = AllplanBaseElements.CommonProperties() com_prop.GetGlobalProperties() polyhedron = AllplanGeo.Polyhedron3D.CreateCuboid(build_ele.length.value, build_ele.width.value, build_ele.height.value) model_ele_list.append(AllplanBasisElements.ModelElement3D(com_prop, polyhedron)) views = [View2D3D (model_ele_list)] labels = [create_label("BL", (0, 0)), create_label("TR", (build_ele.width.value, build_ele.length.value))] pythonpart = PythonPart("Test", parameter_list = build_ele.get_params_list(), hash_value = build_ele.get_hash(), python_file = build_ele.pyp_file_name, views = views, label_elements = labels ) return (pythonpart.create(), handle_list)
*.pyp:
<?xml version="1.0" encoding="utf-8"?> <Element> <Script> <Name>Test\Test.py</Name> <Title>Test</Title> <Interactor>False</Interactor> </Script> <Page> <Name>page_0</Name> <Text>Page</Text> <Parameter> <Name>length</Name> <Text>Langth</Text> <ValueType>Double</ValueType> <Value>1000</Value> </Parameter> <Parameter> <Name>width</Name> <Text>Width</Text> <ValueType>Double</ValueType> <Value>1000</Value> </Parameter> <Parameter> <Name>height</Name> <Text>Height</Text> <ValueType>Double</ValueType> <Value>1000</Value> </Parameter> </Page> </Element>