original_docstring: Modify the transform to apply the pivot at the bottom of the shape for easier placement.
docstring: Modify the transform to apply the pivot at the bottom of the shape for easier placement.
docstring_tokens: Modify the transform to apply the pivot at the bottom of the shape for easier placement .
code: def _set_pivot(vox_model, xformable):
          """Modify the transform to apply the pivot at the bottom of the shape for easier placement."""
          # TODO: This doesn't actually work for rotated models. The pivot doesn't end up at the bottom
          # MV pivot is at the center. I prefer to have it at the bottom.
          # I'm tweaking the translation here to counteract that.
          xform_attr = xformable.GetPrim().GetAttribute("xformOp:transform")
          curr_xform = xform_attr.Get()
          # Need to figure out the local
          up_vector = curr_xform * Gf.Vec4d(0, 0, 1, 1)
          up_vector = Gf.Vec3d(up_vector[0:3]).GetNormalized()
          # copy bottom row of matrix since index operator is read only on Matrix4d
          trans_row = curr_xform[3]
          for index in range(3):
              if up_vector[index] != 0:
                  trans_row[index] = trans_row[index] - int(vox_model.size[2] / 2.0)
                  break
  
          curr_xform.SetRow(3, Gf.Vec4d(*trans_row))
          xform_attr.Set(curr_xform)
code_tokens: def _set_pivot ( vox_model , xformable ) : xform_attr = xformable . GetPrim ( ) . GetAttribute ( "xformOp:transform" ) curr_xform = xform_attr . Get ( ) up_vector = curr_xform * Gf . Vec4d ( 0 , 0 , 1 , 1 ) up_vector = Gf . Vec3d ( up_vector [ 0 : 3 ] ) . GetNormalized ( ) trans_row = curr_xform [ 3 ] for index in range ( 3 ) : if up_vector [ index ] != 0 : trans_row [ index ] = trans_row [ index ] - int ( vox_model . size [ 2 ] / 2.0 ) break curr_xform . SetRow ( 3 , Gf . Vec4d ( * trans_row ) ) xform_attr . Set ( curr_xform )
short_docstring: Modify the transform to apply the pivot at the bottom of the shape for easier placement.
short_docstring_tokens: Modify the transform to apply the pivot at the bottom of the shape for easier placement .
comment: """Modify the transform to apply the pivot at the bottom of the shape for easier placement."""$SEP$# TODO: This doesn't actually work for rotated models. The pivot doesn't end up at the bottom
  $SEP$# MV pivot is at the center. I prefer to have it at the bottom.
  $SEP$# I'm tweaking the translation here to counteract that.
  $SEP$# Need to figure out the local
  $SEP$# copy bottom row of matrix since index operator is read only on Matrix4d
  