def create_controlResizeObj(target=None): _str_func = "create_controlResizeObj" if target is None: _sel = mc.ls(sl=True) if _sel: _res = [] for t in _sel: _res.append(create_controlResizeObj(t)) return _res if not target: raise ValueError, "|{0}| >> Must have a target".format(_str_func) if ATTR.get_message(target, 'cgmControlResizer'): return ATTR.get_message(target, 'cgmControlResizer') handle = create_at(target, 'null') ATTR.set_message(target, 'cgmControlResizer', handle) ATTR.set_message(handle, 'cgmControlResizerSource', target) handle = mc.rename(handle, NAMES.base(target) + '_cgmResizer') shapeParent_in_place(handle, target) ATTR.set(target, 'template', 1) return handle
def group_me(obj=None, parent=False, maintainParent=True, rotateAxis=True, rotatePivot=True, scalePivot=True, zeroScale=False, cleanRotates=True): """ A bridge function utilizing both copy_pivot and copy_orientation in a single call :parameters: obj(str): Object to modify parent(str): Whether to parent the object to the new group maintainParent(bool): Whether to maintain parent of the object rotateAxis(bool): whether to copy the rotateAxis rotatePivot(bool): whether to copy the rotatePivot scalePivot(bool): whether to copy the scalePivot zeroScale(bool): whether to take the childs scale to zero it cleanRotates(bool): whether to zero the rotate data after parent :returns success(bool) """ _str_func = 'group_me' obj = VALID.mNodeString(obj) log.debug("|{0}| >> obj:{1}".format(_str_func, obj)) _oldParent = False if maintainParent: _oldParent = parent_get(obj) group = mc.group(em=True) #objRot = mc.xform (obj, q=True, ws=True, ro=True) #objRotAxis = mc.xform(obj, q=True, ws = True, ra=True) mc.xform(group, roo=mc.xform(obj, q=True, roo=True)) #...match rotateOrder position_set(group, position_get(obj)) orient_set(group, orient_get(obj)) rotateAxis_set(group, rotateAxis_get(obj)) #mc.xform(group, ws=True, ro= objRot,p=False) #mc.xform(group, ws=True, ra= objRotAxis,p=False) if zeroScale: scaleLocal_set(group, scaleLossy_get(obj)) if maintainParent == True and _oldParent: group = parent_set(group, _oldParent) if parent: _wasLocked = [] for attr in ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']: #'rx','ry','rz' attrBuffer = '%s.%s' % (obj, attr) if mc.getAttr(attrBuffer, lock=True): _wasLocked.append(attr) mc.setAttr(attrBuffer, lock=False) #attributes.doSetAttr(obj,attr,0) obj = parent_set(obj, group) if cleanRotates: ATTR.reset(obj, ['rotate', 'rotateAxis']) if _wasLocked: for attr in _wasLocked: attrBuffer = '%s.%s' % (obj, attr) mc.setAttr(attrBuffer, lock=True) if zeroScale: #After all the parenting we'll push the reset scaleLocal_set(obj) return mc.rename(group, "{0}_grp".format(NAME.base(obj)))