Home Technical Talk

Maxivz's Workplane for Maya

interpolator
Offline / Send Message
maxivz interpolator
Hi guys, here's a new tool I have started working on the last weekend. Its basiclly an implementation of the workplane from Modo into maya, it has some limitations vs the actual Modo one and it still needs more features to be implemented, but Id like to start a thread so people can see it evolving and post suggestions so we can end up with a better product for everybody. No release for now, as its still pretty early in dev, but hopefully in the next weeks I should have the first version out. 
Heres whatI have so far:

Select a Face and run the create command to create a workplane, Only works with single face selections for now

If you have something selected the tools axis will lock to the workplane direction.

If nothing selected the workplane grid will become Live, meaning you can create objects over the grid.

Heres another example of the script doing its work:

Stuff I want to implement:

-Add support to create the workplane from other selections, more than one face, object pivots, edges and vert selections.
-Add a menu, so you can store workplanes and load them and use the commands from there.

-Ability to edit the workplane you are using.

- Fix some issues

Looking forward to see what you think! And please post suggestions :)

Replies

  • dive
    Offline / Send Message
    dive polycounter lvl 6
    cool! 

    If you set the pivot to pin and to component mode for a group of faces, maybe you can simply snap the work plane to that pivot orientation.. (thereby snapping the workplace to a group of faces average). 


    storing the workplane orientations would be pretty cool. just like the pivot make sure the work plane can be changed in both orientation and actually pivot location though? that would be ideal.


    Just my 2 cents. Pretty cool, I look forward to giving this a try!
  • onionhead_o
    Offline / Send Message
    onionhead_o polycounter lvl 16
    i think it ll be cool if you can just set the workplane from camera view.
  • maxivz
    Offline / Send Message
    maxivz interpolator
    dive said:
    cool! 

    If you set the pivot to pin and to component mode for a group of faces, maybe you can simply snap the work plane to that pivot orientation.. (thereby snapping the workplace to a group of faces average). 


    storing the workplane orientations would be pretty cool. just like the pivot make sure the work plane can be changed in both orientation and actually pivot location though? that would be ideal.


    Just my 2 cents. Pretty cool, I look forward to giving this a try!
    Hey dive, I am actually using the pivot orientation tool to snap the workplane internally. I will make sure the plane location can be changed as well!.

    i think it ll be cool if you can just set the workplane from camera view.
    Sure! Sounds like a cool suggestion, will see if I can implement it this weekend.

    Thanks for the comment guys! I should have an update after this weekend :)

  • vickgaza
    Offline / Send Message
    vickgaza polycounter lvl 6
    Would be cool if the orthographic cameras could be based on / adapt to the workplane previously set. 
    Awesome stuff so far dude, hope you release it soon :dizzy:

    Vick.
  • Norron
    Offline / Send Message
    Norron polycounter lvl 13
    This looks super useful! Can't wait to try it out.
  • MercurialForge
    Offline / Send Message
    MercurialForge polycounter lvl 11
    Back in my modo days I loved the work plane. I've returned to Maya since, but having this feature in maya would be fantastic, great work, can't wait to see how this develops.
  • pasha_sevez
    Offline / Send Message
    pasha_sevez polycounter lvl 13
    @maxivz
    Looks very promising! I have 3 ideas on this script:
    1) Rotate plane to make specific edge horizontal (say, X-axis) or point axis to some vertex or so.
    2) Aling camera to workplane and make it orthogonal
    3) The primitives are created with local axes matching the axes of the plane. One of your gifs show the cub created with subtle rotation.
  • SergioSantos
    Offline / Send Message
    SergioSantos polycounter lvl 13
    If anyone is interested in having something similar in Max:

    http://cganimator.com/csworkplane-1-0/

  • < ASH >
    Offline / Send Message
    < ASH > polycounter lvl 13
    Hey Maxivz the plugin looks really great ! I can't wait to see it released. :)
    I agree with Vickgaza though: would be really handy to have the orthographic views conforming (= adapting) to the workplane positioning, as it happens in Modo. ;)

    Btw nicely done so far: keep up the good work.
  • IxenonI
    Offline / Send Message
    IxenonI interpolator
    that looks cool. Is this available to download anywhere yet?
  • maxivz
    Offline / Send Message
    maxivz interpolator
    Hey guys, I am no longer actively developing this, but as there's a lot of interest in it I decided to release the source files for the last version I worked on some months ago.  Feel free to pick it up and continue dev and add features.
    The script has 2 functions, the workplaneon and workplane off commands. Basically select a face, run the create workplane command and use it. When you no longer need it you need to run the workplane off command, which destroys it. So make sure to assign WorkplaneOff() and WorkplaneOn() to some hotkeys or something.
    This was developed in maya 2016.5, it should work on older versions but it has not been tested
    #######################################################################
    #Script by Maximiliano Vazquez - artbymaxi.com	- Maxivz     	      #
    #Workplane implementation for Maya V0.1                               #
    #Please, do not redistribute or sell this script.                     #
    #If you have any suggestions feel free to send me a pm on polycount   #
    #######################################################################
    
    import maya.cmds as cmds
    import maya.mel as mel
    import math as math
    from pymel.core import *	
    if not 'jobList' in globals(): jobList = []
    if not 'workplaneGrid' in globals(): workplaneGrid = []
    
    def GetFaceDirection(face):
        context = manipMoveContext()
        manipMoveContext(context, e=True, oo=face)
        orientation = manipMoveContext(context, q=True, oa=True)
        direction = [util.degrees(x) for x in orientation]
        deleteUI(context)
        select(face)
        return direction
    
    def AlignToolsToDirection(direction):
    	manipPivot(o=direction)
    
    def SetModeToCustomAxis():
    	manipMoveContext("Move", e = 1,m = 6)
    	manipRotateContext("Rotate",e = 1, m = 6)
    	manipScaleContext("Scale",e = 1,  m = 6)
    	print "Aligned"
    
    def GetWorldPosRotation(faceSelection):
    	cameraName = "tempWorkplaneCamera1"
    	cameraObject = camera(n = cameraName)[0]
    	#Align Camera to Selection
    	originalCamera = cmds.lookThru( q=True )
    	cmds.lookThru(cameraName)
    	select(faceSelection,r=1)
    	mel.eval("AlignCameraToPolygon;")
    	cmds.lookThru(originalCamera)
    	#Get Camera rotation
    	worldRotation = xform(cameraName,q=1,ro=1)
    	select(cameraName,r=1)
    	delete(cameraObject)
    	select(faceSelection)
    	return worldRotation
    	
    def StartAligningTools():
    	try:
    		jobID1
    	except NameError:
    		jobID1 = []
    	try:
    		jobID2
    	except NameError:
    		jobID2 = []
    	if jobID1:
    		scriptJob(k = jobID1)
    	jobID1 = scriptJob(e = ["ToolChanged",SetModeToCustomAxis])
    	if jobID2:
    		scriptJob(k = jobID2)
    	jobID2 = scriptJob(e = ["SelectionChanged",SetModeToCustomAxis])
    	return list((jobID1,jobID2))
    
    def StopAligningTools(jobList):
    	for job in jobList:
    		scriptJob(k = job)
    
    def GetFacePosition(face):
    	pos = [0,0,0]
    	vertList = filterExpand(polyListComponentConversion(ff = True, tv = True),sm=31)
    	for axis in range (0,3):
    		for vert in vertList:
    			pos[axis] += xform(vert,q=True, t= True,ws=True)[axis]
    		pos[axis] =pos[axis] / float(len(vertList))
    	return pos	
    
    def StartWorkplane(jobList):
    	if not jobList:
    		jobList = StartAligningTools()
    		return jobList
    	else:
    		StopAligningTools(jobList)
    		jobList = StartAligningTools()
    		return jobList
    
    def StopWorkplane(jobList):
    	if jobList:	StopAligningTools(jobList)
    	return []
    
    def CreateWorkplane(selectionWorldDir,selectionPos):
    	global workplaneGrid
    	if not objExists("workplaneGrid"):
    		workplaneGrid = plane(r = selectionWorldDir,p = selectionPos, w = 40, l = 40, n = "workplaneGrid")
    	else:
    		select("workplaneGrid",r=1)
    		delete()
    		workplaneGrid = plane(r = selectionWorldDir,p = selectionPos, w = 40, l = 40, n = "workplaneGrid")
    	return workplaneGrid
    
    def WorkplaneGridSwitch():
    	if not ls(sl=True):
    		makeLive(workplaneGrid)
    	else:
    		makeLive(n=True)
    		
    def LiveWorkplaneToggl(action):
    	if action == "Activate":
    		gridActivationJob = scriptJob(e = ["SelectionChanged",WorkplaneGridSwitch])	
    	if action == "Kill":
    		scriptJob(k = gridActivationJob)	
    
    def WorkplaneOn():
    	###Workplane Creation###
    	faceSelection = filterExpand(sm=34)[0]
    	selectionDir = GetFaceDirection(faceSelection)
    	selectionPos = GetFacePosition(faceSelection)
    	selectionWorldDir = GetWorldPosRotation(faceSelection)
    	workplaneGrid = CreateWorkplane(selectionWorldDir,selectionPos)
    	global jobList
    	jobList = StartWorkplane(jobList)
    	LiveWorkplaneToggl("Activate")
    	
    def WorkplaneOff():
    	###Workplane Deactivation###
    	global jobList
    	jobList = StopWorkplane(jobList)
    	select(workplaneGrid,r = True)
    	delete()
    	LiveWorkplaneToggl("Kill")
    	
    ####

  • Visum
    Offline / Send Message
    Visum polycounter lvl 7
    Thank you for sharing.
    Gonna try it in LT 2017 and pray it works :)
    Looks super useful.
  • maksoon
    Offline / Send Message
    maksoon polycounter lvl 6
    In Maya 2017 work perfect.
    In Maya 2016 error:
    # Error: TypeError: file C:\Program Files\Autodesk\Maya2016\Python\lib\site-packages\pymel\internal\pmcmds.py line 133: Invalid flag 'oo' #

    Thx for the script. Im use 2016.

  • maxivz
    Offline / Send Message
    maxivz interpolator
    I have made it in 2016.5, so it might not work in 2016 or earlier versions
Sign In or Register to comment.