Jump to content
Ultimaker Community of 3D Printing Experts

Cura Plugin - getPickedPosition

Recommended Posts

Posted · Cura Plugin - getPickedPosition

Ok I will investigate this code ...


    def _onSelectedFaceChanged(self):
        if not self._select_face_mode:

        self._handle.setEnabled(not Selection.getFaceSelectMode())

        selected_face = Selection.getSelectedFace()
        if not Selection.getSelectedFace() or not (Selection.hasSelection() and Selection.getFaceSelectMode()):

        original_node, face_id = selected_face
        meshdata = original_node.getMeshDataTransformed()
        if not meshdata or face_id < 0:
        if face_id > (meshdata.getVertexCount() / 3 if not meshdata.hasIndices() else meshdata.getFaceCount()):

        face_mid, face_normal = meshdata.getFacePlane(face_id)
        object_mid = original_node.getBoundingBox().center
        rotation_point_vector = Vector(object_mid.x, object_mid.y, face_mid[2])
        face_normal_vector = Vector(face_normal[0], face_normal[1], face_normal[2])
        rotation_quaternion = Quaternion.rotationTo(face_normal_vector.normalized(), Vector(0.0, -1.0, 0.0))

        operation = GroupedOperation()
        current_node = None  # type: Optional[SceneNode]
        for node in Selection.getAllSelectedObjects():
            current_node = node
            parent_node = current_node.getParent()
            while parent_node and parent_node.callDecoration("isGroup"):
                current_node = parent_node
                parent_node = current_node.getParent()
        if current_node is None:

        rotate_operation = RotateOperation(current_node, rotation_quaternion, rotation_point_vector)


  • Like 1
Link to post
Share on other sites
Posted · Cura Plugin - getPickedPosition

I'm still avaing some problem to implement this code .  I can get the facette center point and the normal with 


face_mid, face_normal = meshdata.getFacePlane(face_id)


But I'm still fighting with the possibility to have in the same time the subroutine _onSelectedFaceChanged and def event(self, event)  . An idea or a suggestion to move forward on this point ?


  • Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Create New...