[Pregunta] [PythonParts] Interactor and On Preview Draw [Guardado]

Etiquetas:
  • Pythonpart
  • Interactor
  • Preview

Hi,

On my Interactor PythonPart, I can create well my object but the preview doesn't work

Here my code :

...

    def on_preview_draw(self):
        """
        Handles the preview draw event
        """
        self.create_geometry(True)

...

    def process_mouse_msg(self, mouse_msg, pnt, msg_info):
        """
        Process the mouse message event

        Args:
            mouse_msg : the mouse message
            pnt       : the input point in view coordinates
            msg_info  : additional message info.

        Returns:
            True/False for success.
        """
        input_pnt = self.coord_input.GetInputPoint(mouse_msg, pnt, msg_info).GetPoint()

        if self.coord_input.IsMouseMove(mouse_msg):
            return True

        self.selected_pnts.append(input_pnt)

        if len(self.selected_pnts) == 1:
            self.create_geometry(False)
            self.reset_pnts()

        return True


    def create_geometry(self, is_preview):
        """
        Draw the preview

        Args:
            is_preview : True/False if preview mode.
        """
        self.axis = Geometry.AxisPlacement3D(Geometry.Point3D(),
                                             Geometry.Vector3D(1, 0, 0),
                                             Geometry.Vector3D(0, 0, 1)
                                             )
        self.placement_mat.SetTranslation(Geometry.Vector3D(self.selected_pnts[0]))

        self.geo = Geometry.BRep3D.CreateCuboid(self.axis, 1000, 1000, 1000)
        self.model_ele_list.append(BasisElements.ModelElement3D(self.com_prop, self.geo))

        if is_preview:
            BaseElements.DrawElementPreview(self.coord_input.GetInputViewDocument(),
                                            self.placement_mat,
                                            self.model_ele_list,
                                            False,
                                            None
                                            )

        else:
            self.create_pythonpart()

Where am I wrong ?

Best regards

Adjuntos (2)

Type: image/jpeg
Descargado 5 veces
Size: 72,26 KiB
Type: image/jpeg
Descargado 7 veces
Size: 119,94 KiB

Show solution Hide solution

Hi,

to get the preview during the mouse move, you need to add

self.create_geometry(True)

before the

if self.coord_input.IsMouseMove(mouse_msg):

line.

The "on_preview_draw" is called outside from the mouse move, e.g. if you do some input in coordinate input toolbar.

Best regards
Horst

Hi,

to get the preview during the mouse move, you need to add

self.create_geometry(True)

before the

if self.coord_input.IsMouseMove(mouse_msg):

line.

The "on_preview_draw" is called outside from the mouse move, e.g. if you do some input in coordinate input toolbar.

Best regards
Horst