How to export segment by LPS coordinate system?

Is there api to export segment by LPS?

          # Get segmentation node (replace 'Segmentation' with the name of your segmentation node in the scene)
            segmentation_node = slicer.util.getNode('Segmentation')


            # get the segmentation
            segmentation = segmentation_node.GetSegmentation()

            # get all segment IDs
            segment_ids = vtk.vtkStringArray()
            segmentation.GetSegmentIDs(segment_ids)

            
            segment_id = segment_ids.GetValue(int(mysegmentid) - 1)

            # get the segment
            segment = segmentation.GetSegment(segment_id)

            # now you can work with the individual segment
            print(f"Segment {segment_id} Name: {segment.GetName()}")


            # Export logic
            model_node = slicer.mrmlScene.AddNode(slicer.vtkMRMLModelNode())
            model_node.SetName(segment_id)
            
            # Create a transform to convert from RAS to LPS
            transform_matrix = vtk.vtkMatrix4x4()
            transform_matrix.Identity()
            transform_matrix.SetElement(0, 0, -1)  # Flip the X axis
            transform_matrix.SetElement(1, 1, -1)  # Flip the Y axis
            
            transform_node = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLLinearTransformNode')
            transform_node.SetMatrixTransformToParent(transform_matrix)
            
            # Apply the LPS transform to the model node
            model_node.SetAndObserveTransformNodeID(transform_node.GetID())
            
            export_success = slicer.modules.segmentations.logic().ExportSegmentToRepresentationNode(segment, model_node)

I use this way but not sure whether it works or not?
Thanks!

RAS to LPS conversion happens when you write the segmentation or model to file. Before that I would recommend to stay in RAS, as the internal representation of all data objects in Slicer is in RAS.