melpymel

Best way to get Shape from a Transform


Using ls -sl returns a transform. The only way I can find to get the shape of a transform is to use getRelatives but this seems wonky compared to other workflows. Is there a better more standard way to get a Shape from a Transform?


Solution

  • Very standard way of getting shape from transform in PyMEL:

    transform.getShape()
    

    To get shapes from a list of selection, you can do the following which results in list of shapes.

    sel_shapes = [s.getShape() for s in pm.ls(sl=1)]
    

    A note that certain transforms do not have shapes. Like a group node, which is basically a empty transform.