本文整理汇总了Python中win32com.client.dynamic.dispatch函数的典型用法代码示例。如果您正苦于以下问题:Python dispatch函数的具体用法?Python dispatch怎么用?Python dispatch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dispatch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: zgNewPackGuide_Execute
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
示例2: zgNewFlat_Execute
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
示例3: Draw
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')
示例4: Draw
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
示例5: __init__
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')
示例6: Draw
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
示例7: zMultiSelectEvent_OnEvent
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
示例8: Format
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
示例9: __init__
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
示例10: fget
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
示例11: zPlot_ToggleAllLclScl_OnClicked
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
示例12: zLocalOrientConstraint_Execute
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
示例13: __init__
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
示例14: __init__
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
示例15: zgInitRigBuilder_Execute
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