[Question] [PythonParts] 3D Rotate elements [Solved]


Hi,

I'm developping a script for ceiling (sandwich panel).

It works fine, I've got an 3D model and a different 2D view as I want (all are in a PythonPart element in Allplan).

Now, I'd like to propose a rotation for the slopes but I don’t know the most effective way.

I want my 2D view keeps different from model and only 3D objects will be affected by the rotation.

...

# Create views
views = []

...

views.append(View2D([rect])) 

...

views.append(View3D([polyh]))

...

# Create pythonpart
pythonpart = PythonPart("Elements",
                                build_ele.get_params_list(),
                                self._hash_value,
                                self._python_file,
                                views,
                                AllplanGeo.Matrix3D(),
                                com_prop,
                                self.create_reinforcement(build_ele),
                                self.create_attribute_list()
                                )

self.model_ele_list = pythonpart.create()

Best

Attachments (1)

Type: image/png
Downloaded 54 times
Size: 123,83 KiB

Show solution Hide solution

Hi,

This is the solution :

...                                                      
import NemAll_Python_Geometry as AllplanGeo
...

#initialize an angle object
angle = AllplanGeo.Angle()                                      

#setting the angle value in degrees
angle.Deg = 45  

#definition of the rotation axis                                             
rotation_axis = AllplanGeo.Line3D(AllplanGeo.Point3D(0, 0, 0),
                                      AllplanGeo.Point3D(0, 0, 1)
                                      )                             


#init a transformation matrix describing scaling, shrinking, rotation and translation
transformation_matrix = AllplanGeo.Matrix3D()                  

#set the transformation matrix to do only the rotation
transformation_matrix.SetRotation(rotation_axis, angle)         

#apply the rotation on the geometry object
geo = AllplanGeo.Transform(geo, transformation_matrix)         

Hope this helps the community

Hi,

This is the solution :

...                                                      
import NemAll_Python_Geometry as AllplanGeo
...

#initialize an angle object
angle = AllplanGeo.Angle()                                      

#setting the angle value in degrees
angle.Deg = 45  

#definition of the rotation axis                                             
rotation_axis = AllplanGeo.Line3D(AllplanGeo.Point3D(0, 0, 0),
                                      AllplanGeo.Point3D(0, 0, 1)
                                      )                             


#init a transformation matrix describing scaling, shrinking, rotation and translation
transformation_matrix = AllplanGeo.Matrix3D()                  

#set the transformation matrix to do only the rotation
transformation_matrix.SetRotation(rotation_axis, angle)         

#apply the rotation on the geometry object
geo = AllplanGeo.Transform(geo, transformation_matrix)         

Hope this helps the community


https://campus.allplan.com/ uses cookies  -  More information

Accept