コード例 #1
0
def fk_ik_switch(sender, receiver, killjob):

    fk, ik = get_fk_ik_joints([sender, receiver])

    scriptJob(kill=killjob)
    ik_mode = sender.attr('FkIkMode').get()
    if ik_mode == receiver.attr('FkIkMode').get():
        # Attribute wasn't even changed.
        create_fk_ik_sj([sender, receiver])
        return

    if ik_mode:
        snap(sender, receiver)
        if ik['sj'] == ik['collar']:
            snap(fk['collar'], ik['collar'], translate=False)
        ik['pvc'] = ik['h'].attr('poleVectorX').connections()[0] \
         .attr('target[0].targetTranslate').connections()[0]
        ik['pvc'].setTranslation(calc_pv_loc(hand_joint=sender), space='world')
    else:  # FK mode
        jtypes = fk['sj'] == fk['collar'] and ('collar', ) or ()
        jtypes += ('shoulder', 'elbow', 'hand')
        [snap(ik[jtype], fk[jtype], translate=False) for jtype in jtypes]

    receiver.attr('FkIkMode').set(ik_mode)
    select(receiver)
    create_fk_ik_sj([sender, receiver])
コード例 #2
0
ファイル: general.py プロジェクト: jedmao/maya-scripts
def fk_ik_switch(sender, receiver, killjob):
	
	fk, ik = get_fk_ik_joints([sender, receiver])
	
	scriptJob(kill=killjob)
	ik_mode = sender.attr('FkIkMode').get()
	if ik_mode == receiver.attr('FkIkMode').get():
		# Attribute wasn't even changed.
		create_fk_ik_sj([sender, receiver])
		return
	
	if ik_mode:
		snap(sender, receiver)
		if ik['sj'] == ik['collar']:
			snap(fk['collar'], ik['collar'], translate=False)
		ik['pvc'] = ik['h'].attr('poleVectorX').connections()[0] \
			.attr('target[0].targetTranslate').connections()[0]
		ik['pvc'].setTranslation(calc_pv_loc(hand_joint=sender),
			space='world')
	else: # FK mode
		jtypes = fk['sj'] == fk['collar'] and ('collar',) or ()
		jtypes += ('shoulder', 'elbow', 'hand')
		[snap(ik[jtype], fk[jtype], translate=False) for jtype in jtypes]
	
	receiver.attr('FkIkMode').set(ik_mode)
	select(receiver)
	create_fk_ik_sj([sender, receiver])
コード例 #3
0
ファイル: startup.py プロジェクト: jedmao/maya-scripts
def auto_sign_new_scenes(author):
	"""
	To combat plagiarism, sign the defaultLayer with the author's name every
	time a new scene is created.
	"""
	_sign_the_scene(author)
	scriptJob(event=['NewSceneOpened',
		lambda *args: executeDeferred(lambda *args: _sign_the_scene(author))],
		protected=True)
コード例 #4
0
def auto_sign_new_scenes(author):
    """
	To combat plagiarism, sign the defaultLayer with the author's name every
	time a new scene is created.
	"""
    _sign_the_scene(author)
    scriptJob(event=[
        'NewSceneOpened',
        lambda *args: executeDeferred(lambda *args: _sign_the_scene(author))
    ],
              protected=True)
コード例 #5
0
def create_fk_ik_sj(controls):
    """
	Creates a separate script job for both the fk and ik controls so
	their FKIK Mode is always the same without creating a crashing
	loop.
	"""

    # Find out what the next script job number will be by creating
    # a new script job, only to trash it immediately afterwards.
    killjob = scriptJob(attributeAdded=['defaultLayer.foo', lambda: None])
    scriptJob(kill=killjob)

    killjob += 3
    for i, c in enumerate(controls):
        killjob -= 1
        scriptJob(runOnce=True, killWithScene=True,
         attributeChange=[c + '.FkIkMode',
          lambda c1=c, c2=controls[i-1], killjob=killjob: \
           fk_ik_switch(c1, c2, killjob)])
コード例 #6
0
ファイル: general.py プロジェクト: jedmao/maya-scripts
def create_fk_ik_sj(controls):
	"""
	Creates a separate script job for both the fk and ik controls so
	their FKIK Mode is always the same without creating a crashing
	loop.
	"""
	
	# Find out what the next script job number will be by creating
	# a new script job, only to trash it immediately afterwards.
	killjob = scriptJob(attributeAdded=['defaultLayer.foo',
		lambda:None])
	scriptJob(kill=killjob)
	
	killjob += 3
	for i, c in enumerate(controls):
		killjob -= 1
		scriptJob(runOnce=True, killWithScene=True,
			attributeChange=[c + '.FkIkMode',
				lambda c1=c, c2=controls[i-1], killjob=killjob: \
					fk_ik_switch(c1, c2, killjob)])
コード例 #7
0
        def create(self):
            """
            Generates a new maya window object and binds it to the singleton 
            instance.
            """
            SCENE = Scene()
            self._win = window(title=self.window_title, 
                               resizeToFitChildren=True)
            with self._win:
                template = uiTemplate('LocalSubmitTemplate', force=True )
                template.define(frameLayout, bs='etchedIn', mw=6, mh=6, 
                                labelVisible=False)
                template.define(columnLayout, adj=True, rs=4)
                template.define(formLayout, nd=100)
                # padding adjustment for pre-qt maya versions
                if versions.current() <= versions.v2010:
                    template.define(text, align='right', h=22)
                else:
                    template.define(text, align='right', h=20)
                with template:
                    with formLayout() as mainForm:
                        with frameLayout() as setFrame:
                            with formLayout() as setForm:
                                with columnLayout() as setCol1:
                                    text(label="Title:")
                                    text(label="Start Frame:")
                                    text(label="End Frame:")
                                    text(label="Frame Step:")
                                    text(label="Emulation:", annotation='If selected, the local render will behave in the same environtment as the Cluster, otherwise it will act as a normal local batch render')
                                with columnLayout() as setCol2:
                                    self._controls['title'] = textField(text=get_scene_name())
                                    self._controls['start'] = intField(value=get_frame_range()[0])
                                    self._controls['end'] = intField(value=get_frame_range()[1])
                                    self._controls['step'] = intField(value=int(SCENE.defaultRenderGlobals.byFrameStep.get()))
                                    self._controls['emulate'] = checkBox(label="Cluster Emulation", annotation='If selected, the local render will behave in the same environtment as the Cluster, otherwise it will act as a normal local batch render')
                                    self._controls['pause'] = checkBox(label="Pause before exit")
#                                    self._controls['debug'] = checkBox(label="Show debug messages")
                            
                            setForm.attachForm(setCol1, 'left', 4)
                            setForm.attachControl(setCol1, 'right', 2, setCol2)
                            setForm.attachForm(setCol2, 'right', 4)
                            setForm.attachPosition(setCol2, 'left', 40, 20)
                            
                        with frameLayout() as subFrame:
                            submit_btn = button(label="Submit", width=200, height=40, align='center')
                            submit_btn.setCommand(self.submit_job)
                    
                    mainForm.attachForm(setFrame, 'top', 4)
                    mainForm.attachForm(setFrame, 'left', 4)
                    mainForm.attachForm(setFrame, 'right', 4)
                    mainForm.attachControl(setFrame, 'bottom', 4, subFrame)
                    mainForm.attachForm(subFrame, 'bottom', 4)
                    mainForm.attachForm(subFrame, 'left', 4)
                    mainForm.attachForm(subFrame, 'right', 4)
                    
                    """
                    We force the closure of an open submit window on scene open 
                    to ensure the new scene's settings are reflected.
                    """
                    scriptJob(parent=self._win, runOnce=True, 
                              event=('SceneOpened', SubmitGui.destroy))
コード例 #8
0
ファイル: gui.py プロジェクト: RCAD/ringling-render-tools
        def create(self):
            """
            Generates a new maya window object and binds it to the singleton 
            instance.
            """
            SCENE = Scene()
            self._win = window(title=self.window_title, 
                               resizeToFitChildren=True)
            with self._win:
                template = uiTemplate('HpcSubmitTemplate', force=True )
                template.define(frameLayout, bs='etchedIn', mw=6, mh=6, 
                                labelVisible=False)
                template.define(columnLayout, adj=True, rs=4)
                template.define(formLayout, nd=100)
                # padding adjustment for pre-qt maya versions
                if versions.current() <= versions.v2010:
                    template.define(text, align='right', h=22)
                else:
                    template.define(text, align='right', h=20)
                with template:
                    with formLayout() as mainForm:
                        with frameLayout() as setFrame:
                            with formLayout() as setForm:
                                with columnLayout() as setCol1:
                                    text(label="Head Node:")
                                    text(label="Title:")
                                    text(label="Start Frame:")
                                    text(label="End Frame:")
                                    text(label="Frame Step:")
#                                    text(label="Cores:")
                                with columnLayout() as setCol2:
                                    self._controls['head_node'] = optionMenu()
                                    with self._controls['head_node']:
                                        for host in HEAD_NODES: 
                                            menuItem(label=host)
                                        self._controls['head_node'].setSelect(randint(1,len(HEAD_NODES)))
                                    self._controls['title'] = textField(text=get_scene_name())
                                    self._controls['start'] = intField(value=get_frame_range()[0])
                                    self._controls['end'] = intField(value=get_frame_range()[1])
                                    self._controls['step'] = intField(value=int(SCENE.defaultRenderGlobals.byFrameStep.get()))
                                    
#                                    with columnLayout(adj=False):
#                                        self._controls['threads'] = optionMenu(w=40)
#                                        with self._controls['threads']:
#                                            menuItem(label=2)
#                                            menuItem(label=4)
#                                        self._controls['threads'].setSelect(1)
                                    self._controls['pause'] = checkBox(label="Pause before exit")
                                    self._controls['debug'] = checkBox(label="Show debug messages")
                            
                            setForm.attachForm(setCol1, 'left', 4)
                            setForm.attachControl(setCol1, 'right', 2, setCol2)
                            setForm.attachForm(setCol2, 'right', 4)
                            setForm.attachPosition(setCol2, 'left', 40, 20)
                            
                        with frameLayout() as subFrame:
                            submit_btn = button(label="Submit", width=200, height=40, align='center')
                            submit_btn.setCommand(self.submit_job)
                    
                    mainForm.attachForm(setFrame, 'top', 4)
                    mainForm.attachForm(setFrame, 'left', 4)
                    mainForm.attachForm(setFrame, 'right', 4)
                    mainForm.attachControl(setFrame, 'bottom', 4, subFrame)
                    mainForm.attachForm(subFrame, 'bottom', 4)
                    mainForm.attachForm(subFrame, 'left', 4)
                    mainForm.attachForm(subFrame, 'right', 4)
                    
                    """
                    We force the closure of an open submit window on scene open 
                    to ensure the new scene's settings are reflected.
                    """
                    scriptJob(parent=self._win, runOnce=True, 
                              event=('SceneOpened', SubmitGui.destroy))