Posts

Showing posts from 2020

Maya Rigging Tips: Using jointOrient and changing shape-node's parent and hierarchical position

I had a nice discussion with my rigger friend and found out neat way of setting up rotation controllers with less offset nodes. ;p Sample code A: def sample():     import maya.cmds as mc;     # Regacy using an offset node     c01= mc.circle(n="RotateA_regacy")[0];     c02= mc.circle(n="RotateB_regacy")[0];     os01= mc.ls(mc.parent(mc.group(em=1,n="offset"),c01),sl=1,l=1)[0];     c02= mc.ls(mc.parent(c02,os01),sl=1,l=1);     mc.setAttr(os01+".rx",90);          # Tips using jointOrient and changing shape's parent     c03= mc.circle(n="RotateA")[0];     c04= mc.ls(mc.joint(n="RotateB"),sl=1,l=1)[0];     nc= mc.circle();     mc.parent(mc.listRelatives(nc,ad=0)[0],c04,s=1,r=1);     mc.reorder((mc.listRelatives(c03,ad=0)[0]),back=1);     mc.setAttr(c04+".jointOrientX",90);     mc.setAttr(c04+".drawStyle",2);     mc.dele...

MayaUI: Do not restore saved layout from file

Image
In preference, go to Interface/UI Elements/Panel Configurations and turn off the checkbox for "Restore saved layouts from file" in When opening.

i3d: Prerequisites

Image
# To find your Maya user script folder. def useScriptFolder(): import os; usd= cmds.internalVar(usd=True); usf= usd.rsplit('/', 3)[0]+"/scripts/"; if not os.path.exists(usf): usf= usd; return( usf ); print useScriptFolder(); # Files and Folders Locations

Maya: Wireframe Color

Image
I created a GUI to set wireframe color of selected nurbs curves. Primary commands, attributes and others used: - setAttr(shapeNode+".overrideEnabled",1); - setAttr( shapeN ode+".overrideColor",colorIndex); Prerequisites: i3d.pyc, i3d_main.pyc, i3d_utility.pyc, i3d_rig.pyc pyc file location(Google Drive): - i3d.pyc https://drive.google.com/drive/u/0/folders/1YcdLQ4s-0sCT_l9rMWBmbefXKSlVAQX8 - the rest https://drive.google.com/drive/u/3/folders/18u9JizS2Fr12XF2ZH6QmKbga59p1c_Xn

lookdevkit Shading Nodes (Maya2018)

Image
lookdevkit Shading Nodes (Maya2018) Dependency Nodes channels floatComposite colorComposite floatCondition colorCondition floatConstant colorConstant floatCorrect colorCorrect floatLogic colorLogic floatMath colorMath unpremultiply premultiply simplexNoise

Maya Python: addAttr

# Adding a new string attribute import maya.cmds as mc; mc.select(cl=1); null= mc.group(em=1); attrName= "testAttr"; attrValue= "This is a test."; mc.addAttr(null,sn=attrName,ln=attrName,dt="string"); mc.setAttr(null+"."+attrName,attrValue,type="string",l=1); mc.select(null);

bpy: Save/Load selection and transform of selected objects

Image
i3d pyc files 1. Download and move i3d.pyc file to Blender’s \scripts\modules\ folder. If you are not sure, print(pby) to print find __int__.py location in modules folder. 2. Save all other i3d_***pyc files to below directory. ~Documents\blender\i3d\scripts\ i3d_GUITools.pyc i3d_selection.pyc i3d_transform.pyc i3d_utility.pyc Commands(in blender) Save&Load current selection[Green] and Save&Load transform(RTXYZ)[Yellow] Commands: import i3d,i3d_GUITools as iGU;

bpy: Getting selected polygon vertices

I've been Maya artist for quite a long time and started to learn how to get infos I need for the i3d tools in Blender. I will try to leave a note for those Maya script artists learning python scripting in Blender 2.8x. ;) def gettingSelectedPolyVertsInMayaFormat(): import bpy; selectedVerts= []; mode = bpy.context.active_object.mode; # Getting current mode bpy.ops.object.mode_set(mode='OBJECT'); # Setting object mode to get selected objects objs= bpy.context.selected_objects # Current selected objects for obj in objs: # Finding selected vertices of the selected  if obj.type=="MESH": # if the object is polygon..   verts= obj.data.vertices; # get all poly verts of the poly object num= len(verts);  for i in range(0,num):   if verts[i].select: # if the vtx is selected..   mayaVTX= obj.name+".vtx["+str(i)+"]"; # Getting selected vtx in Maya format selectedVerts.append(mayaVTX);   bpy.ops.object.mode_set...

Maya: Camera Image Plane

Image
Setting a video file to a new camera import maya.cmds as mc; # Creating a new default camera cam= mc.camera(); # Transform node of the camera cam_transform= cam[0]; # Camera shape node cam_shape= cam[1]; # Camera shape imagePlane attribute image_plane_attr= cam_shape+".imagePlane"; # A video file my_video_file= "my_video_file.avi"; # Applying a video file to camera's image plane attribute image_plane_nodes= mc.imagePlane(image_plane_attr,fn=my_video_file); # Transform node of image plane image_plane_transform= image_plane_nodes[0]; # Image plan shape node image_plane_shape= image_plane_nodes[1]; # Setting image plane type attribute to "movie" mc.setAttr(image_plane_shape+".type",2); To my knowledge, it ends up with  disabled  Image Number. (No expression is generated) So, I studied through echoed all commands and decided to use MEL command. - import maya.cmds as mc; # Create an imagePla...

Maya GUI: Buttons to an image

Image
Placing buttons to an image I am creating some tools for animators and in need of refreshing my old memories of coding "buttons to an image" using python. I created a sample python code file, so that I would not need to dig my old library of scripting tools to get sample codes. :p Download and place these 2 files to your script folder. Python script file: i3d_sample2.py Sample image file: i3d_sample2.png Python command: import i3d_sample2 as sample2;sample2.buttonToImageGUI().main("sample2"); This is how it looks. *Reference commands:  columnLayout,  formLayout, button

Maya: Creating Arnold shading nodes by script

Image
When creating Arnold shading nodes by script, use shadingNode command instead of createNode command. (Maya2018) # shadingNode command cmds.shadingNode('aiStandardSurface',asShader=True,n="arnoldNode1"); # createNode command # This node will not be visible in Hypershade window. cmds.createNode('aiStandardSurface',n="arnoldNode2");

Maya: Expression

Autodesk Knowledge Network: How often an expression executes Runtime expression execution Write runtime expressions

Maya: Node types

Node types (Autodesk Knowledge Network) Shape nodes: import maya.cmds as mc; mc.spaceLocator(); # Creating a locator mc.circle(); # Creating a nurbsCurve circle mc.sphere(); # Creating a nurbsSurface sphere mc.polySphere(); # Creating a polygon sphere shapenodes= mc.ls(type="shape"); for item in shapenodes:     print item + " : " + mc.nodeType(item); #Outputs: frontShape : camera locatorShape1 : locator nurbsCircleShape1 : nurbsCurve nurbsSphereShape1 : nurbsSurface pSphereShape1 : mesh perspShape : camera sideShape : camera topShape : camera

Maya: Legacy Viewport

Maya: Legacy Viewport Viewport 2.0 and Legacy Default Viewport: Maya2016 Legacy High Quality Viewport options: Maya2017 Restoring the Legacy Viewport in Maya2018 No longer supported in Maya2019

MWP: Sample GUI

Image
Motionbuilder with Python # Reflecting to GUI When any object selected and "Get selected" button pressed , "Get selected" button label will be changed to the selected object name. # Reflecting from GUI When "Select" button pressed, it tries to find an object by the above button name. Sample code is here . (Version tested: 2018) Please see this page  to relocate the sample code in i3d script folder. #Prerequisites : i3dmb.pyc #Command: import i3dmb,i3dmb_samples as iSa;iSa.sampleGUI().create();