Example #1
0
def zgNewPackGuide_Execute( guideName, guideModel ):

	Application.LogMessage("zgNewGuide_Execute called")
	
	# make sure this is a guide model #
	if not guideModel.Properties( 'zgGuide' ):
		xsi.logmessage( '%s is not a zgGuide model.', c.siError )
		return False
	
	# make sure this guide doesn't all ready exist #
	kids = guideModel.FindChildren('*', c.siModelType)
	for kid in kids:
		prop = kid.Properties('zgPackGuide')
		if prop:
			prop = dispatch( prop )
			if prop.Parameters( 'PackGuideName' ).Value == guideName:
				xsi.logmessage( 'Guide "%s" all ready exists in "%s"' % (guideName, guideModel.FullName), c.siWarning )
				return False
				
	
	# add the guide model #
	guide = dispatch( guideModel.AddModel( '', guideName ) )
	
	# tag it #
	prop = guide.AddProperty('CustomProperty', False, 'zgPackGuide' )
	prop.AddParameter3( 'PackGuideName', c.siString, guideName, None, None, False, True )
	
	# add a tag to the guide #
	prop = guideModel.AddProperty('CustomProperty', False, guideName )
	prop.AddParameter3( 'PackGuideModel', c.siString, guide, None, None, False, True )
	
	# return the guide model #
	return guide
Example #2
0
def zgNewFlat_Execute( flatName, flatModel ):

	# get the guides in the scene #
	if not flatModel:
		flatModel = xsi.zgFlats()(0)
		
	# make sure this is a guides model #
	if not flatModel.Properties( 'zgFlats' ):
		xsi.logmessage( '%s is not a zgFlats model.', c.siError )
		return False
	
	# make sure this guide doesn't all ready exist #
	kids = flatModel.FindChildren('*', c.siModelType)
	for kid in kids:
		prop = kid.Properties('zgFlat')
		if prop:
			prop = dispatch( prop )
			if prop.Parameters( 'FlatName' ).Value == flatName:
				xsi.logmessage( 'Flat "%s" all ready exists in "%s"' % (flatName, flatModel.FullName), c.siError )
				return False
				
	
	# add the flat model #
	flat = dispatch( flatModel.AddModel( '', flatName ) )
	
	# tag it #
	prop = flat.AddProperty('CustomProperty', False, 'zgFlat' )
	prop.AddParameter3( 'FlatName', c.siString, flatName )
	
	# return the guide model #
	return flat
Example #3
0
	def Draw(self):
		"""docstring for Draw"""
		# get the model #
		if not self.model:
			raise Exception('Model attribute for template not specified.')
		
		# dispatch the model #
		self.model = dispatch(self.model)
		
		# make sure we have a point array #
		if not self.point_array:
			raise Exception(
				'No point array provided: \n' + \
				'If you want to make a custom curve, pass in a point array like: \n' + \
				'[[x1, x2, xn], [y1, y2, yn], [z1, z2, zn], [w1, w2, wn]] \n' + \
				' -- example -- \n' + \
				'spine.template.point_array = [[0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3], [1, 1, 1, 1]] \n'
			)
			
		if not self.segments:
			raise Exception(
				'No spine.template.segments provided.'
			)
			
		
		#---------------------------------------------------------------------
		# create a node to hold the template #
		node_parent = self.model.AddNull(xsi.zMapName(self.parent.basename, 'Custom:Container', self.parent.symmetry))
		node_parent.primary_icon.Value = 0
		node_parent.Properties('Visibility').Parameters('viewvis').Value = False
		node_parent.Properties('Visibility').Parameters('rendvis').Value = False
		node_parent.AddProperty('CustomProperty', False, 'zBuilderTemplateItem')
		prop = node_parent.AddProperty('CustomProperty', False, 'zContainer')
		prop = dispatch(prop)
		prop.AddParameter3('ContainerName', c.siString, self.parent.basename)
		prop.AddParameter3('ContainerUID', c.siString, self.parent.uid)
		prop.AddParameter3('ContainerSym', c.siString, self.parent.symmetry)
		
		# draw the curve #
		self.curve 	= node_parent.AddNurbsCurve(
			self.point_array, 
			None, 
			False, 
			3,
			c.siNonUniformParameterization,
			c.siSINurbs
		)
		self.curve.Name = xsi.zMapName(self.parent.basename, 'Custom:Curve', self.parent.symmetry)
		
		# tag the curve with the spine property #
		self.prop_spine = self.curve.AddProperty('zSpineGenericCurve')
		
		# set the default number of segments #
		self.prop_spine.Segments.Value = self.segments
		
		# tag the nodes #
		self.curve.AddProperty('CustomProperty', False, 'zBuilderTemplateManip')
Example #4
0
	def Draw(self):
		"""docstring for Draw"""
		# get the model #
		if not self.model:
			raise Exception('Model attribute for template not specified.')
		
		# dispatch the model #
		self.model = dispatch(self.model)
		
		#---------------------------------------------------------------------
		# create a node to hold the template #
		node_parent = self.model.AddNull('Pelvis_Container')
		node_parent.primary_icon.Value = 0
		node_parent.Properties('Visibility').Parameters('viewvis').Value = False
		node_parent.Properties('Visibility').Parameters('rendvis').Value = False
		node_parent.AddProperty('CustomProperty', False, 'zBuilderTemplateItem')
		prop = node_parent.AddProperty('CustomProperty', False, 'zContainer')
		prop = dispatch(prop)
		prop.AddParameter3('ContainerName', c.siString, 'Pelvis')
		prop.AddParameter3('ContainerUID', c.siString, self.parent.uid)
			
		# draw the nodes #
		node_root 	= node_parent.AddNull('Pelvis_Root')
		node_eff 	= node_root.AddNull('Pelvis_Target')
		node_upv 	= node_root.AddNull('Pelvis_Upv')
		
		# tag the nodes #
		node_root.AddProperty('CustomProperty', False, 'zBuilderTemplateManip')
		node_root.AddProperty('CustomProperty', False, 'zPelvisRoot')

		node_eff.AddProperty('CustomProperty', False, 'zBuilderTemplateManip')
		node_eff.AddProperty('CustomProperty', False, 'zPelvisTarget')

		node_upv.AddProperty('CustomProperty', False, 'zBuilderTemplateManip')
		node_upv.AddProperty('CustomProperty', False, 'zPelvisUpv')
		
		#---------------------------------------------------------------------
		# set the positions #
		trans = XSIMath.CreateTransform()
		v_result = XSIMath.CreateVector3()
		
		# root #
		v_result.Scale(self.parent.scale, self.v_root)
		trans.Translation = v_result
		node_root.Kinematics.Global.Transform = trans
		
		# eff #
		v_result.Scale(self.parent.scale, self.v_target)
		trans.Translation = v_result
		node_eff.Kinematics.Global.Transform = trans
		
		# upv #
		v_result.Add(self.v_root, self.v_upv)
		v_result.ScaleInPlace(self.parent.scale)
		trans.Translation = v_result
		node_upv.Kinematics.Global.Transform = trans
Example #5
0
	def __init__(self):
		super(zIkFkSnapTool, self).__init__()

		# set the defaults for the input variables #
		for item in self._inputs_:
			setattr(self, item, None)
			
		# set the instance variables #
		self.cons_fk		= dispatch('XSI.Collection')
		self.tagged_nodes	= dispatch('XSI.Collection')
Example #6
0
	def Draw(self):
		"""docstring for Draw"""
		# get the model #
		if not self.model:
			raise Exception('Model attribute for template not specified.')

		# dispatch the model #
		self.model = dispatch(self.model)

		#---------------------------------------------------------------------
		# create a node to hold the template #
		node_parent = self.model.AddNull('Clavicle_%s_Container' % self.parent.symmetry[0].upper())
		node_parent.primary_icon.Value = 0
		node_parent.Properties('Visibility').Parameters('viewvis').Value = False
		node_parent.Properties('Visibility').Parameters('rendvis').Value = False
		node_parent.AddProperty('CustomProperty', False, 'zBuilderTemplateItem')
		prop = node_parent.AddProperty('CustomProperty', False, 'zContainer')
		prop = dispatch(prop)
		prop.AddParameter3('ContainerName', c.siString, 'Clavicle')
		prop.AddParameter3('ContainerSym', c.siString, self.parent.symmetry.lower())
		prop.AddParameter3('ContainerUID', c.siString, self.parent.uid)

		#---------------------------------------------------------------------
		# draw the nodes #
		node_clavicle 	= node_parent.AddNull(xsi.zMapName('Clavicle', 'Custom:Tmp', self.parent.symmetry))
		node_clavicle.AddProperty('CustomProperty', False, 'zBuilderTemplateManip')
		node_clavicle.AddProperty('CustomProperty', False, 'zClavicle')

		node_shoulder	= node_parent.AddNull(xsi.zMapName('ClavShoulder', 'Custom:Tmp', self.parent.symmetry))
		node_shoulder.AddProperty('CustomProperty', False, 'zBuilderTemplateManip')
		node_shoulder.AddProperty('CustomProperty', False, 'zShoulder')

		node_control	= node_parent.AddNull(xsi.zMapName('ClavShoulderControlCenter', 'Custom:Tmp', self.parent.symmetry))
		node_control.AddProperty('CustomProperty', False, 'zBuilderTemplateManip')
		node_control.AddProperty('CustomProperty', False, 'zControl')

		#---------------------------------------------------------------------
		# set the positions #
		trans = XSIMath.CreateTransform()
		v_result = XSIMath.CreateVector3()

		# clavicle #
		v_result.Scale(self.parent.scale, self.v_clav)
		trans.Translation = v_result
		node_clavicle.Kinematics.Global.Transform = trans

		# shoulder #
		v_result.Scale(self.parent.scale, self.v_shoulder)
		trans.Translation = v_result
		node_shoulder.Kinematics.Global.Transform = trans
		
		# control #
		v_result.Scale(self.parent.scale, self.v_control_center)
		trans.Translation = v_result
		node_control.Kinematics.Global.Transform = trans
Example #7
0
def zMultiSelectEvent_OnEvent(ctxt):
	
	# capture Ctrl + B #
	key = ctxt.GetAttribute('KeyCode')
	mask = ctxt.GetAttribute('ShiftMask')
	# log('Key %s  Mask %s' % (key, mask))
	if key != 66 and mask != 2:
		return False
	
	# cache the original selection #
	sel = dispatch('XSI.Collection')
	sel.AddItems(xsi.selection)
	
	# step through the selection #
	for item in sel:
		if item.Families != '3D Objects':
			log('Item "%s" not selectable.' % item.FullName, c.siWarning)
			continue

		# get the zMultiSelect property #
		prop = item.Properties('zMultiSelect')
		
		# skip over items without the property #
		if not prop: continue
		prop = dispatch(prop)
		
		# skip if not enabled #
		if not prop.Enable.Value: continue
		
		# skip if the grid has no objects #
		if not prop.Objects.Value:
			log('No objects in zMultiSelect property.', c.siWarning)
			return False
			
		# get the object list #
		objs = list(prop.Objects.Value.split(','))
		modelName = item.model.Name
		if modelName != 'Scene_Root':
			for o in xrange(len(objs)):
				objs[o] = modelName + '.' + objs[o]
		
		# create a collection of objects #
		col = dispatch('XSI.Collection')
		col.SetAsText(','.join(objs))
		
		# select the objects #
		for i in col:
			i.Selected = True
			
		# deselect the original #
		if prop.Deselect.Value:
			prop.Parent.Selected = False
		
	return True
Example #8
0
	def Format(self):
		# format the chain #
		xsi.zFormatChain(self.chainRoot,
			self.BoneDisplay,
			[ self.BoneR, self.BoneG, self.BoneB ],
			self.BoneSize,
			
			self.RootDisplay,
			[ self.RootR, self.RootG, self.RootB ],
			self.RootSize,
			
			self.EffDisplay,
			[ self.EffR, self.EffG, self.EffB ],
			self.EffSize,
			
			self.EffLastBone,
			
			[ self.BoneWireR, self.BoneWireG, self.BoneWireB ],
			[ self.RootWireR, self.RootWireG, self.RootWireB ],
			[ self.EffWireR, self.EffWireG, self.EffWireB ]
		)
		
		# align the chain roots #
		trans = self.chainRoot.Bones(0).Kinematics.Global.Transform
		self.chainRoot.Kinematics.Global.Transform = trans
		self.chainRoot.Bones(0).Kinematics.Global.Transform = trans
		
		# set root primary_icon #
		if self.RootPrimary:
			self.chainRoot.primary_icon.Value = self.RootPrimary
		# bone primary_icon #
		if self.BonePrimary:
			for bone in self.chainRoot.Bones:
				bone = dispatch(bone)
				bone.primary_icon.Value = self.BonePrimary
		# effector primary_icon #		
		if self.EffPrimary:
			self.chainRoot.Effector.primary_icon.Value = self.EffPrimary

		# set root shadow #
		if self.RootShadow:
			self.chainRoot.shadow_icon.Value = self.RootShadow
		# bone shadow #
		if self.BoneShadow:
			for bone in self.chainRoot.Bones:
				bone = dispatch(bone)
				bone.shadow_icon.Value = self.BoneShadow
		# effector shadow #		
		if self.EffShadow:
			self.chainRoot.Effector.shadow_icon.Value = self.EffShadow
Example #9
0
	def __init__(self, parent):
		super(zSpineGeneric_Rig, self).__init__()
		
		# set the defaults #
		for item in (self._public_attrs_ + self._readonly_attrs_):
			setattr(self, item, None)
			
		# set the instance variables #
		self.parent					= parent
		self.skeleton_parent 		= xsi.ActiveSceneRoot
		self.controls_parent 		= xsi.ActiveSceneRoot
		self.deformer_parent 		= xsi.ActiveSceneRoot
		self.add_pick_walk 			= True
		self.add_chest_con			= False
		self.add_head_con			= False
		self.hide_first_con			= True
		self.do_not_touch			= xsi.ActiveSceneRoot
		
		# create a list to hold all the spine ik controls #
		self.con_iks 				= []
		
		# create a collection to hold all the spine deformers #
		self.deformers				= dispatch('XSI.Collection')
		
		# set the default controller sizes #
		self.size_ik_cons			= 1
		self.size_fk_cons			= 1
		self.size_chest_con			= 6
		self.size_head_con			= 5
Example #10
0
		def fget(self):
			# create a rig class if it doesn't exist #
			if not self._rig:
				# wrap a new class #
				self._rig = dispatch(win32com.server.util.wrap(zSpineGeneric_Rig(self)))
			# return the private var #
			return self._rig
Example #11
0
def zPlot_ToggleAllLclScl_OnClicked():
	ppg = PPG.Inspected(0)
	ppg = dispatch(ppg)

	ppg.SclLclX.Value = 1-ppg.SclLclX.Value
	ppg.SclLclY.Value = 1-ppg.SclLclY.Value
	ppg.SclLclZ.Value = 1-ppg.SclLclZ.Value
def zLocalOrientConstraint_Execute():
		
		# make sure we have something selected #
		if not xsi.selection.Count:
			xsi.logmessage('Please select an item.', c.siError)
			return False
			
		# pick the constraining item #
		picker = xsi.PickElement(None, 'Pick the Constraining Object')
		if not picker[0]:
			return
		objCns = picker[2]
		
		# constrain #
		obj = xsi.selection(0)
		
		log('%s --> %s' % (obj, objCns))

		# cache the transform #
		origTransform = obj.Kinematics.Global.Transform
		
		# determine if comensation is on #
		comp = xsi.GetUserPref("SI3D_CONSTRAINT_COMPENSATION_MODE")
		
		cns = obj.Kinematics.AddConstraint('Pose', objCns, comp)
		cns = dispatch(cns)
		cns.cnspos.Value = False
		cns.cnsscl.Value = False
		
		# apply the original transform #
		obj.Kinematics.Global.Transform = origTransform
		
		return cns
Example #13
0
	def __init__(self, parent):
		super(zArm3BoneA_Rig, self).__init__()
		
		# set the instance variables #
		self.parent					= parent

		# set the defaults for the input variables #
		for item in self._inputs_:
			setattr(self, item, None)
			
		# set specific types #
		self.deformers = dispatch('XSI.Collection')
		
		# set the default controller sizes #
		self.size_elbow_con			= 1
		self.size_wrist_con			= 1
		self.size_hand_con			= 1.25
		self.size_arm_fk_cons		= 2
		self.size_hand_fk_cons		= 2		
		self.size_bend_elbow_con	= 1	
		self.size_bend_upper_con	= 1	
		self.size_bend_lower_con	= 1	
		self.size_anchor_con		= 0.5	

		self.perc_elbow_area		= 10.0
		self.float_elbow_offset		= 0.0
		
		self.shrug_fk_fix			= False
		self.align_hand_to_template = True

		# default parents #
		self.controls_parent		= xsi.ActiveSceneRoot  		
		self.skeleton_parent		= xsi.ActiveSceneRoot  		
		self.deformer_parent  		= xsi.ActiveSceneRoot
		self.node_do_not_touch		= xsi.ActiveSceneRoot
Example #14
0
	def __init__(self, parent):
		super(zLeg_Rig, self).__init__()
		# set the instance variables #
		self.parent				= parent
		self.skeleton_parent 	= None
		self.controls_parent 	= None
		self.deformer_parent 	= None
		self.root_pelvis		= None
		self.character_set		= None
		self.group_deformers	= None

		# outputs #
		self.con_knee	   		= None
		self.con_foot	   		= None
		self.con_ankle	   		= None
		self.ik_switch	   		= None
		self.prop_anim	   		= None
		self.prop_anim_di  		= None
		self.character_subset	= None
		self.root_leg			= None
		self.root_leg_con		= None
		self.deformers			= dispatch('XSI.Collection')
		
		self.size_foot_con		= 3
		self.size_knee_con		= 1
		self.size_ankle_con		= 1
		self.size_fk_cons		= 2.5
Example #15
0
def zgInitRigBuilder_Execute( rigName, create ):
	
	rigModel = None
	
	#  no name given #
	if not rigName:
		
		xsi.logmessage( 'No Rig specified.', c.siError )
		return False
	
	# create a new rig #
	if create:
		
		# create the model #
		rigModel = xsi.ActiveSceneRoot.AddModel( None, rigName )
		
		# tag the model #
		prop = dispatch( rigModel.AddProperty( 'CustomProperty', False, 'zgRigBuilder' ) )
		
		# cache the name #
		prop.AddParameter3( 'RigName', c.siString, rigName )
		
		# install the preferences #
		rigModel.AddProperty( 'zgRigBuilderPrefs', False )
	
	else:
		
		# find and return the rigbuilder model #
		rigModel = xsi.ActiveSceneRoot.FindChild( rigName, c.siModelType )
		if not rigModel or not rigModel.Properties( 'zgRigBuilder' ):
			xsi.logmessage( 'RigBuilder "%s" not found.' % rigName, c.siError )
			return False

	# return the rig model #
	return rigModel
Example #16
0
def zPlot_Translation_OnChanged():
	ppg = PPG.Inspected(0)
	ppg = dispatch(ppg)
	
	# if not ppg.Translation.Value:
	# 	ppg.PosLclX.ReadOnly = True
	# 	ppg.PosLclY.ReadOnly = True
	# 	ppg.PosLclZ.ReadOnly = True
	# 	
	# 	ppg.PosGlbX.ReadOnly = True
	# 	ppg.PosGlbY.ReadOnly = True
	# 	ppg.PosGlbZ.ReadOnly = True
	# else:
	# 	ppg.PosLclX.ReadOnly = False
	# 	ppg.PosLclY.ReadOnly = False
	# 	ppg.PosLclZ.ReadOnly = False
	# 	
	# 	ppg.PosGlbX.ReadOnly = False
	# 	ppg.PosGlbY.ReadOnly = False
	# 	ppg.PosGlbZ.ReadOnly = False

	# draw the layout #
	zPlot_DrawLayout(
		ppg.PPGLayout, 
		showPos=ppg.Translation.Value, 
		showRot=ppg.Rotation.Value, 
		showScl=ppg.Scale.Value
	)
	PPG.Refresh()	
Example #17
0
def zPlot_ToggleAllGlbScl_OnClicked():
	ppg = PPG.Inspected(0)
	ppg = dispatch(ppg)

	ppg.SclGlbX.Value = 1-ppg.SclGlbX.Value
	ppg.SclGlbY.Value = 1-ppg.SclGlbY.Value
	ppg.SclGlbZ.Value = 1-ppg.SclGlbZ.Value
Example #18
0
def zMultiSelect_AddObjects_OnClicked():
	prop = PPG.Inspected(0)
	
	# convert the objects string to a list #
	objStr = prop.Objects.Value
	objList = []
	if len(objStr):
		objList = objStr.split(',')
	
	# step through the xsi selection #
	for item in xsi.selection:
		item = dispatch(item)
		
		# catch unselectable items #
		if item.Families != '3D Objects':
			log('Item "%s" not selectable.' % item.FullName, c.siWarning)
			continue
			
		# skip over items all ready in the list #
		if item.FullName in objList:
			log('Item "%s" all ready in selection list.' % item.FullName,
				c.siWarning)
			continue
			
		# add the item to the list #
		objList.append(item.Name)
		
	# convert the object list back to a string #
	if len(objList):
		prop.Objects.Value = ','.join(objList)
	
	# redraw the ppg #
	zMultiSelect_RebuildLayout(prop)
Example #19
0
	def GetFromScene(self):
		"""Gets the template values from the template model"""
		
		#---------------------------------------------------------------------
		# make sure the model exists 
		log(self.model)
		if not self.model:
			raise Exception('Model attribute for template not specified.')
		
		#---------------------------------------------------------------------
		# find the container #
		node_parent = None
		for node in dispatch(self.model).FindChildren('*'):
			if node.Properties('zContainer'):
				if node.Properties('zContainer').Parameters('ContainerUID').Value == self.parent.uid:
					node_parent = node
					break
		# make sure we have the container #
		if not node_parent:
			raise Exception('Unable to find pelvis template container by id: %s' % self.parent.uid)
		
		#---------------------------------------------------------------------
		# get all the nodes under the container #
		child_nodes = node_parent.FindChildren('*')

		#---------------------------------------------------------------------
		# get the vectors #
		for node in child_nodes:
			if node.Properties('zPelvisRoot'):
				self.v_root = node.Kinematics.Global.Transform.Translation
			elif node.Properties('zPelvisTarget'):
				self.v_target = node.Kinematics.Global.Transform.Translation
			elif node.Properties('zPelvisUpv'):
				self.v_upv = node.Kinematics.Global.Transform.Translation
Example #20
0
	def GetFromScene(self):
		"""Gets the template values from the template model"""
		
		#---------------------------------------------------------------------
		# make sure the model exists 
		if not self.model:
			raise Exception('Model attribute for template not specified.')
		
		#---------------------------------------------------------------------
		# find the container #
		node_parent = None
		for node in dispatch(self.model).FindChildren('*'):
			if node.Properties('zContainer'):
				if node.Properties('zContainer').Parameters('ContainerUID').Value == self.parent.uid \
				and	node.Properties('zContainer').Parameters('ContainerName').Value == self.parent.basename:
					node_parent = node
					break
		# make sure we have the container #
		if not node_parent:
			raise Exception('Unable to find pelvis template container by id: %s and name: %s' % (self.parent.uid, self.parent.basename))
		
		#---------------------------------------------------------------------
		# get all the nodes under the container #
		child_nodes = node_parent.FindChildren('*')

		#---------------------------------------------------------------------
		# get the vectors #
		for node in child_nodes:
			prop = node.Properties('zSpineCurve')
			if prop:
				self.curve 	= node
				self.prop 	= prop
Example #21
0
def zMiddlerOp_Update(ctxt):

    # get the parameters #
    source = dispatch(ctxt.Source)
    mid_quat = ctxt.UserData[0]
    out_rot = ctxt.UserData[1]

    # get the inputs #
    node_global = ctxt.GetInputValue(0)
    t1_global = ctxt.GetInputValue(1)
    t2_global = ctxt.GetInputValue(2)
    weight = ctxt.GetParameterValue("BlendWeight")

    # get the quaternions for both global transforms #
    t1_quat = t1_global.Transform.Rotation.Quaternion
    t2_quat = t2_global.Transform.Rotation.Quaternion

    # get teh mid point #
    mid_quat.Slerp(t1_quat, t2_quat, 0.5)

    # build the new transform #
    tfrm = node_global.Transform
    out_rot.Quaternion = mid_quat
    tfrm.Rotation = out_rot
    tfrm.Translation = t1_global.Transform.Translation

    # set the output value #
    ctxt.OutputPort.Value.Transform = tfrm
Example #22
0
	def __init__(self, parent):
		super(zFoot_Rig, self).__init__()

		# set the instance variables #
		self.parent					= parent
		self.skeleton_parent 		= None
		self.controls_parent 		= None
		self.deformer_parent 		= None
		self.character_set			= None
		self.con_foot           	= None
		self.con_ankle	   			= None
		self.ik_switch          	= None
		self.prop_anim          	= None
		self.prop_anim_di       	= None
		self.root_leg_con       	= None
		self.root_skel_leg      	= None
		self.group_deformers		= None
		self.group_controls			= None
		self.realign_foot_con		= True
		self.add_middlers			= False
		
		self.size_ball_con			= 1
		self.size_toe_con			= 1
		self.size_toe_pivot_con		= 1
		self.size_ball_pivot_con	= 1
		self.size_fk_cons			= 1.75
		
		# outputs #
		self.character_subset		= None
		self.root_foot_rev			= None
		self.root_foot				= None
		self.deformers				= dispatch('XSI.Collection')
Example #23
0
	def GetFromScene(self):
		"""Gets the template values from the template model"""
		
		#---------------------------------------------------------------------
		# make sure the model exists 
		if not self.model:
			raise Exception('Model attribute for template not specified.')
		
		#---------------------------------------------------------------------
		# find the container #
		node_parent = None
		for node in dispatch(self.model).FindChildren('*'):
			if node.Properties('zContainer'):
				# get the container by the id #
				if node.Properties('zContainer').Parameters('ContainerUID').Value == self.parent.uid \
				and node.Properties('zContainer').Parameters('ContainerSym').Value == self.parent.symmetry.lower():
					node_parent = node
					break
		# make sure we have the container #
		if not node_parent:
			raise Exception('Unable to find template container by id: %s and name: %s' % (self.parent.uid, type_name))
		
		#---------------------------------------------------------------------
		# get all the nodes under the container #
		child_nodes = node_parent.FindChildren('*')

		#---------------------------------------------------------------------
		# get the vectors or transform #
		for node in child_nodes:
			if node.Properties('zClavicle'):
				self.v_clav				= node.Kinematics.Global.Transform.Translation
			elif node.Properties('zShoulder'):
				self.v_shoulder			= node.Kinematics.Global.Transform.Translation
			elif node.Properties('zControl'):
				self.v_control_center	= node.Kinematics.Global.Transform.Translation
Example #24
0
def zgAddRestNode_Execute( node, restName, display ):

	# precondidtions #
	if not node:
		xsi.logmessage( 'No node provided', c.siError )
		return False
	
	# build the new name #
	newName = restName
	if not newName:
		splits = node.Name.split('_')
		if len(splits) <= 1:
			newName = node.Name
		else:
			splits = splits[:-1]
			newName = '%s_Rest' % '_'.join( splits )
		
	# add the rest node #
	restNode = node.parent.AddNull( newName )
	restNode = dispatch( restNode )
	
	# align the rest node #
	restNode.kinematics.Global.transform = node.kinematics.Global.transform
	
	# reparent the node #
	restNode.AddChild( node )
	
	# set the display #
	if not display:
		restNode.Parameters( 'primary_icon' ).Value = 0
	
	# return the rest node #
	return restNode
Example #25
0
def zInfo_OnInit():

	# get the property #
	info = PPG.Inspected(0)
	info = dispatch(info)

	# get the layout #
	lo = info.PPGLayout
	lo.Clear()

	# build the ppg layout #
	lo.AddGroup('Zoogloo Information')
	lo.AddGroup('Rig: %s.%s.%s' % (info.Prefix.Value, info.Version.Value, info.Itteration.Value))
	lo.AddRow()
	lo.AddStaticText('Author: %s' % (info.Author.Value))
	lo.AddSpacer()
	lo.AddStaticText('Revision: %d' % (info.Revision.Value))
	lo.EndRow()
	lo.AddRow()
	lo.AddStaticText('Date: %d/%d/%d' % (info.Month.Value, info.Day.Value, info.Year.Value))
	lo.AddSpacer()
	lo.AddStaticText('Time: %d:%02d' % (info.Hour.Value, info.Min.Value))
	lo.EndRow()
	it = lo.AddItem('Itteration')
	lo.EndGroup()
	lo.EndGroup()
	it.SetAttribute(c.siUITreadmill, True)
Example #26
0
def zRibbon_PickPath_OnClicked():

	prop = PPG.Inspected(0)
	prop = dispatch(prop)
	
	# get the default path #
	path = ''
	if not prop.Path.Value or not os.path.exists(os.path.dirname(prop.Path.Value)):
		path = xsi.ActiveProject.Path
	else:
		path = os.path.dirname(prop.Path.Value)
	
	# navigate to the models directory if it exists #
	if os.path.exists(path + os.sep + 'Models'):
		path = path + os.sep + 'Models'
		 
	# build a file browser #
	fb = XSIUIToolkit.FileBrowser
	fb.DialogTitle 		= "Pick the XSI zRibbon Model..."
	fb.InitialDirectory = path
	fb.FileBaseName 	= "ribbon"
	fb.Filter 			= "XSI Model (*.emdl)|*.emdl|All Files (*.*)|*.*||"
	fb.ShowOpen()

	# get the filename #
	if fb.FilePathName:
		prop.Path.Value = fb.FilePathName
Example #27
0
	def GetFromScene(self):
		"""
		Gets the template values from the template model specified in zRoot.template.model
		"""
		
		#---------------------------------------------------------------------
		# make sure the model exists 
		if not self.model:
			raise Exception('Model attribute for template not specified.')
		
		#---------------------------------------------------------------------
		# find the container #
		node_parent = None
		for node in dispatch(self.model).FindChildren('*'):
			if node.Properties('zContainer'):
				# get the container by the id #
				if node.Properties('zContainer').Parameters('ContainerUID').Value == self.parent.uid:
					node_parent = node
					break
		# make sure we have the container #
		if not node_parent:
			raise Exception('Unable to find template container by id: %s' % (self.parent.uid))
		
		#---------------------------------------------------------------------
		# get all the nodes under the container #
		child_nodes = node_parent.FindChildren('*')

		#---------------------------------------------------------------------
		# get the vectors or transform #
		for node in child_nodes:
			if node.Properties('zCenter'):
				self.v_center = node.Kinematics.Global.Transform.Translation
			if node.Properties('zFlight'):
				self.v_flight = node.Kinematics.Global.Transform.Translation
Example #28
0
	def __init__(self, parent):
		super(zAnimalLeg_Rig, self).__init__()
		
		# set the instance variables #
		self.parent					= parent

		# set the defaults for the input variables #
		for item in self._inputs_:
			setattr(self, item, None)
			
		# set specific types #
		self.deformers = dispatch('XSI.Collection')
		
		# set the default sizes #
		self.size_knee_con 		= 1
		self.size_foot_con 		= 1
		self.size_ankle_con		= 1
		self.size_leg_fk_con	= 1
		self.size_toe_pivot_con	= 1
		self.perc_knee_area	 	= 10
		self.perc_hawk_area 	= 10
		
		self.skeleton_parent	= xsi.ActiveSceneRoot
		self.controls_parent	= xsi.ActiveSceneRoot
		self.deformer_parent	= xsi.ActiveSceneRoot
Example #29
0
		def fget(self):
			# create a rig class if it doesn't exist #
			if not self._rig:
				# wrap a new class #
				self._rig = win32com.server.util.wrap(zRoot_Rig(self))
			# return the private var #
			return dispatch(self._rig)
def zgRemoveDynamicSkeleton_Execute(object):

	if not object: object = xsi.selection(0)
	
	root = object
	
	if object.type == 'bone':
		root = object.root
		
	if object.type == 'eff':
		root = object.root

	# make sure we have a chain root #
	if not root or root.type != 'root':
		xsi.logmessage('No chain root specified.', c.siError)
		return False

	root = dispatch(root)
	
	#
	cacheProp = root.Properties('zgDynamicSkeleton')
	if not cacheProp:
		xsi.logmessage('No "zgDynamicSkeleton" property found.', c.siError)
		return False
	
	# delete all the marks #
	delCol = win32com.client.dynamic.Dispatch('XSI.Collection')
	delCol.SetAsText(cacheProp.Parameters('markers').Value)
	
	# restore the properties #
	root.Parameters('primary_icon').Value = cacheProp.Parameters('rootDisplay').Value
	root.effector.Parameters('primary_icon').Value = cacheProp.Parameters('effDisplay').Value
	root.bones(0).Properties('Kinematic Chain').Parameters('blendik').Value = cacheProp.Parameters('blendik').Value
	
	# make the skeletons selectable #
	for bone in root.bones:
		bone = dispatch(bone)
		bone.Properties('Visibility').selectability.Value = True
	
	
	# delete the cache properties #
	delCol.Add(cacheProp)
	
	xsi.DeleteObj(delCol)

	return true