[Otázka] [PythonParts] Set Origin using PythonPartTransaction [Vyřešeno]

Tagy:
  • Pythonpart
  • Interactor
  • Origin

Hi,

I'm working on Interactor PythonPart scripts who need to keep PythonPart Object.

So, I'm looking on PythonPartTransaction with the following code :

    def create_pythonpart(self):
        """
        Create the PythonPart
        """
        pyp_util = PythonPartUtil()
        pyp_util.add_pythonpart_view_2d3d(self.model_ele_list)
        pyp_transaction = PythonPartTransaction(self.coord_input.GetInputViewDocument())

        pyp_transaction.execute(Geometry.Matrix3D(),
                                self.coord_input.GetViewWorldProjection(),
                                pyp_util.create_pythonpart(self.build_ele),
                                self.modify_uuid_list
                                )

It's working great but the PythonPart's origin is still at (0, 0, 0).

How can I fix it ?

Best

Přílohy (1)

Type: image/jpeg
Staženo 13
Size: 29,29 KiB

Show solution Hide solution

Hi,

you need to set the correct placement matrix (first parameter). The placement matrix includes the placement point and rotation if your PythonPart is created locally to the placement point.

Best regards
Horst

Hi,

you need to set the correct placement matrix (first parameter). The placement matrix includes the placement point and rotation if your PythonPart is created locally to the placement point.

Best regards
Horst

Thanks for your quick answer

Here the updated code :

    def create_pythonpart(self):
        """
        Create the PythonPart
        """
        build_ele = self.build_ele_list[0]
        pyp_matrix = Geometry.Matrix3D()
        pyp_matrix.SetTranslation(Geometry.Vector3D(self.selected_pnts[0]))
        pyp_util  = PythonPartUtil()
        pyp_util.add_pythonpart_view_2d3d(self.model_ele_list)
        pyp_transaction = PythonPartTransaction(self.coord_input.GetInputViewDocument())

        pyp_transaction.execute(pyp_matrix,
                                self.coord_input.GetViewWorldProjection(),
                                pyp_util.create_pythonpart(build_ele),
                                []
                                )

Best