Allplan Fórum

Assign hatch to PythonPart with PythonPartUtil [Vyřešeno]

Tagy:
  • Pythonpart
  • Hatch
  • FaceStyle

Hello,

do you know how to assign FaceStyle/Hatch... to BRep3D in PythonPart created with PythonPartUtil?

With older PP definition it could be done like:

brep = AllplanBasisElements.ModelElement3D(self.com_prop, self.texturedef, shell)

SectionFill.add_section_filling(brep, sectfill)

model_elem_list = [brep]

pythonpart_shell = PythonPart("Shell",
                    parameter_list      = build_ele.get_params_list(),
                    hash_value          = build_ele.get_hash() + "Shell" ,
                    python_file         = build_ele.pyp_file_name,
                    views               = hc_views,
                    common_props        = self.com_prop,
                    attribute_list      = self.create_attribute_list_shell()
                    )

now, using PythonPartUtil:

    model_ele_list = ModelEleList()
    model_ele_list.set_common_properties(com_prop)
    model_ele_list.append_geometry_3d(brep)


    pyp_util = PythonPartUtil()
    pyp_util.add_pythonpart_view_2d3d(model_ele_list)

    return pyp_util.get_pythonpart(build_ele)

Cannot figure out how to do this :/
Bests

Show solution Hide solution

Hi Karol,

ModelEleList class inherits from regular python list. So, you can do with it whatever you can do with a list, also iterate over its items. Knowing, that there are only ModelElement3D and/or ModelElement2D inside (in your case there is only one ModelElement3D inside) you can assign the desired filling to them in a loop. >our code would look like:

model_ele_list = ModelEleList()
model_ele_list.set_common_properties(com_prop)
model_ele_list.append_geometry_3d(brep)

# assigning the filling to each model element
for element in model_ele_list:
    sect_fill = SectionFill(...)
    SectionFill.add_section_filling(element, sect_fill)

pyp_util = PythonPartUtil()
pyp_util.add_pythonpart_view_2d3d(model_ele_list)

return pyp_util.get_pythonpart(build_ele)

I think that will do the job.

Best,
Bart

Hi Karol,

ModelEleList class inherits from regular python list. So, you can do with it whatever you can do with a list, also iterate over its items. Knowing, that there are only ModelElement3D and/or ModelElement2D inside (in your case there is only one ModelElement3D inside) you can assign the desired filling to them in a loop. >our code would look like:

model_ele_list = ModelEleList()
model_ele_list.set_common_properties(com_prop)
model_ele_list.append_geometry_3d(brep)

# assigning the filling to each model element
for element in model_ele_list:
    sect_fill = SectionFill(...)
    SectionFill.add_section_filling(element, sect_fill)

pyp_util = PythonPartUtil()
pyp_util.add_pythonpart_view_2d3d(model_ele_list)

return pyp_util.get_pythonpart(build_ele)

I think that will do the job.

Best,
Bart

I actually had a “General 3D surface” object instead of 3D Solid (incorrect geometry in PythonPart, and didn't notice it...) - and that's why I didn't see the hatching. But without your answer I would still be looking for the problem in the hatching assignment.

Thanks a lot! You saved me a lot of time and nerves