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
Replies
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
Awesome stuff so far dude, hope you release it soon
Vick.
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.
http://cganimator.com/csworkplane-1-0/
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.
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") ####Gonna try it in LT 2017 and pray it works
Looks super useful.
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.