Posts

Showing posts from 2019

UE4: Settings

Image
Installing an older version Click +button and add a new slot in Library tab. Choose an older version from dropdown list for the slot. Switching Languages (Editor Languages) / 言語変更 Editor in Menu > Editor Preferences : 編集 > エディタ環境設定 General/Region & Language : 一般-地域&言語 Internationalization/Editor Language : 国際化/エディタの言語

bpy: Location to save your python script files

Default installation location.     In python console, enter >>>print(bpy);     O utputs should be something like below.     <module 'bpy' from '...\Blender Foundation\\Blender 2.81\\2.81\\scripts\\modules\\bpy\\__init__.py'>     Save your python files in "modules" folder. Reloading your python files.    import importlib as iLib;iLib.reload(your python script file name without extension);    e.g.  iLib.reload(i3d); to reload  i3d.py in modules folder.

Python: Version, Merging dictionaries

# python version import sys; pv= sys.version_info; print pv; print str(pv.major)+"."+str(pv.minor); print '{0[0]}.{0[1]}'.format(pv); # merging dictionaries dictA= {'a':4,'b':-9,'c':-901.5}; dictB= {'b':-125,'d':1024,'c':99}; # 1 if pv < 3.5:     dictC= dict(dictA,**dictB); else:     dictC= {** dictA , ** dictB }; print dictC; # output {'a': 4, 'c': 99, 'b': -125, 'd': 1024} # 2 dictA.update(dictB); print dictA; # output {'a': 4, 'c': 99, 'b': -125, 'd': 1024}

Python: Dealing with small decimal values

# Creating a locator import maya.cmds as mc; sloc= mc.spaceLocator()[0]; # Set small decimal values to ty and sz attributes ty= sloc+".ty"; sz= sloc+".sz"; mc.setAttr(ty, 0.0000000001); mc.setAttr(sz, 1.000000000001); # Translate value tval= mc.getAttr(ty); print tval; # This prints "1e-10" if tval==0: print "test: translate value"; # This won't print # Scale value sval= mc.getAttr(sz); print sval; # This prints "1.0" if sval==1: print "test: scale value"; # This won't print # Using the decimal module from decimal import Decimal; print Decimal(tval); # This prints "1.0000000000000000364321973154977415791655470655996396089904010295867919921875E-10" print Decimal(sval); # This prints "1.0000000000010000889005823410116136074066162109375" # PI from math import pi as PI; print PI; #output: 3.14159265359 from decimal import Decimal; print Decimal(PI); #output: 3.14159265358979311599796...

Python: *args and **kwargs

## *args def testAsteriskArgs(arg1,*args):     num= len(args);     print arg1;     for i in range(0,num):         print str(i)+ ": " + str(args[i]);     print type(args); testAsteriskArgs(1,2,"test",(3,4,5)); # Output 1 0: 2 1: test 2: (3, 4, 5) <type 'tuple'> ## **kwargs def testkwargs(arg1,*args,**kwargs):     print arg1;     num= len(args);     for i in range(0,num): print str(i)+": "+str(args[i]);     print kwargs;     print type(kwargs); testkwargs(11,22,33,44,X=55,Y=66,Z=77); # Output 11 0: 22 1: 33 2: 44 {'Y': 66, 'X': 55, 'Z': 77} <type 'dict'>

i3d: Skin Editor Toolset

Image
A Collection of smoothSkin editing tools 1: "Bones" Updates num of bones, name of selected skin and a list of skin bones of selected skin. 2: List of bones 3: Edit Skin buttons "Bind" : binds skin using smoothSkin. Select non-skinned mesh and joints. "Detach" : Detach smoothSkin from selected skins. "Add B": Add new bones to selected skins. "Rmv B": Removes skin bones from skins. "Bs 2 B": Move skin weights to the last selected bone. "Bs 2 Vs": Select poly vertices skin-weighted to selected bones. "P:ExpImp": Export smoothSkin Infos of selected skins. With shift presssed, it imports exported infos. "V:ExpImp": Export smoothSkin Infos of selected skin mesh verticies. With shift presssed, it imports exported infos. 4: GUI Tools buttons "C Editor": Opens Component Editor window. "MirCopy": Opens Mirror Copy options window. "S E...

Python: Extracting matched items between lists

a= [ 67 , 4, 19.2, 3.4 , 11, "test" ]; b= [ 3.4 , 99, "test" , 67 , "sample"]; c= list(set(a) & set(b)); print c; # ['test', 67, 3.4]

skin: Skin Ops

Image
Smoothing skin weights of selected poly vertex or vertices.   Average skin weight values of all neighboring vertices will be applied to the selected vertex. Usage: Select skinned vertex or vertices and execute the command. Command: import i3d,i3d_skin as iS;iS.skinWeightOps().smooth(); Prerequisites: Download i3d pyc files. https://ironthreed.blogspot.com/2019/02/i3d-2019-version-i3d-python-script-files.html Primary Maya python commands: polyInfo skinCluster skinPercent

rigging: Stretchy 2BIK Rig

Image
Stretchy 2 bone ik rig sample This rig uses decomposeMatrix, distanceBetween and condition utility nodes. It also uses expression for simple math and attribute link. Connection networks Expressions Maya(mb) file https://drive.google.com/file/d/16NjQckZ5mkExr1lH0F8VH7F9jZLhKtPa

Utility Node

List of utility nodes , Maya2019 https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2019/ENU/Maya-LightingShading/files/GUID-DA9707D2-8A0D-4911-A010-8274C57D3FD3-htm.html Add Double Linear Add Matrix utility node Angle Between utility node Array Mapper Blend Colors Blend Two Attr Bump 2d Bump 3d Choice utility node Chooser utility node Clamp Clear Coat Color Profile Condition node Contrast Curve Info utility node Decompose Matrix Distance Between Double Switch Frame cache Gamma Correct Height Field Hsv to Rgb Light Info LookdevKit shading nodes Luminance Mult Double Linear utility node Multiply Divide 2d Placement 3d Placement Plus Minus Average Projection Particle Sampler Quad Switch Remap Color Remap HSV Remap Value Reverse Rgb to Hsv Sampler Info Set Range Single Switch Smear Stencil Studio Clear Coat Surface Info Surf. Luminance Triple Switch Unit Conversion utility node Uv Chooser Vector Product ...

Texture file path: Search and reconnect texture files

Image
This command will search and fix texture file paths of an active scene. The same as reference file path, you may need to fix texture file paths for the files you receive from your colleagues or even clients. I hope this little scripts will also save your time. ;) Command: import i3d,i3d_utility as iU;iU.changeTextureFilePath().doChange(-1,"sourceimages"); Prerequisites: Download i3d pyc files. https://ironthreed.blogspot.com/2019/02/i3d-2019-version-i3d-python-script-files.html A license file. Download and move it to "/User/maya/scripts/i3d/" folder. i3d_lic.pyc Example: 1. Active scene file path is.. 2. Execute the command(python) import i3d,i3d_utility as iU;iU.changeTextureFilePath().doChange(-1,"sourceimages"); # INPUT ARGUMENTS: int, string #      int: directory level from current active scene. #            e.g. -1 will be C:\Users\i3d\Documents\maya\default\ #      string: folder n...

Reference: Search and reconnect reference files

Image
This command will search and fix reference file paths of an active scene. I experienced that often times I receive those maya files with reference files which have local absolute  file path. I hope this little scripts will save your time as well. :) Command: import i3d,i3d_utility as iU;iU.referenceInfo().reloadReferenceFiles(-1,"refFolder"); # change "refFolder" to your folder name. Prerequisites: Download i3d pyc files. https://ironthreed.blogspot.com/2019/02/i3d-2019-version-i3d-python-script-files.html A license file. Download and move it to "/User/maya/scripts/i3d/" folder. i3d_lic.pyc Example: 1. This is your current active scene. 2. All reference files are stored in "references" folder under current active scene project. 3. When opening a file, check "Remember these settings" and press skip button. 4. Execute the command(python) import i3d,i3d_utility as iU;iU.referenceInfo().reloadRefe...

Maya GUI Tool: Scale animCurve Keys

Image
GUI: Scale animCurve Keys GUI tool to stretch out or shrink specified range of animCurve keys. Start: Enter first frame of the scaling range. End: Enter last frame of the scaling range. New end: Enter a new end frame. Scale button: Enable scaling. If nothing selected, all animCurve keys in the scene will be scaled. Before the stretch(scaling) 22 in Start, 55 in End and 100 in New end. Then press Scale button. After the stretch(scaling) 22-55 is now stretched out to 22-100. Prerequisites: Download i3d pyc files. https://ironthreed.blogspot.com/2019/02/i3d-2019-version-i3d-python-script-files.html Python command: import i3d,i3d_anim as iA;iA.scaleAnimCurveKeys().GUI("iA");

Python: Refreshing window function

# Refresh window function. class initWindow:     def create(self,winObj):         import maya.cmds as mc;         if mc.window(winObj,ex=1):mc.deleteUI(winObj);         WIN= mc.window(winObj);         return( WIN );     def main(self,winObj,title,wd,hg,vis):         import maya.cmds as mc;         WIN= self.create(winObj);         mc.window(WIN,e=1,w=wd,h=hg,t=title);         if vis:mc.showWindow(WIN);         return( WIN ); # Sample code. windowObject= "testWindow"; windowTitle= "Empty Window"; width= 400; height= 100; windowVisibility= True; WIN= initWindow().main(windowObject,windowTitle,width,height,windowVisibility);

OpenMaya api2.0

OpenMaya api2.0 # Object alignment def alignObjects():     import maya.cmds as mc;     sel= mc.ls(sl=1,l=1);     num= len(sel);     if num>1:         import maya.api.OpenMaya as om2;         mat= om2.MMatrix(mc.getAttr(sel[num-1]+".matrix"));         for i in range(0,num-1):mc.xform(sel[i],matrix=tuple(mat)); # Selection, node name import maya.api.OpenMaya as om2; sel= om2.MGlobal.getActiveSelectionList(); num= sel.length(); for i in range(0,num):     dNode= sel.getDependNode(i);     MFnDNode= om2.MFnDependencyNode( dNode );     print MFnDNode.name();

Maya GUI Tool: Change manipulator's Move/Rotate context window

Image
Command: import i3d,i3d_GUI as iG;iG.manip().GUI("iG"); Prerequisites: Download i3d pyc files. https://ironthreed.blogspot.com/2019/02/i3d-2019-version-i3d-python-script-files.html

i3d: list of classes and functions

19.05.24 #i3d_anim.pyc i3d_anim.py # getAttrValsAsText(attrs,nodes): # deleteAnim(attrs,mod): #posing: # savePose(self,attrs,fldrName, fileName, key, mod): # loadPose(self,fldrName, fileName, key, mod): #keyBake: # doBake(self,bakes): #animImpExp: # loadPlugin(self,pluginName): # imp(self): # rebuildHierarchyFromAnimFile(self,animFile): # getChilds(self,nodes,top): # main(self): #FBX: # findItem(self,topFldr,fldr): # getMayaFiles(self,fldr): # getContext(self,textfile): # bakeAndExport(self,context,mayafiles,fldr,fbxfldrname): # logmessege(self,st,et,elt,results): # batchExport(self,topFldrName): #scaleAnimCurveKeys(): # filterDoScale(self,F1,F2,F3): # updateGUI(self,uiObj): # initWin(self,winObj): # doScale(self,sf,f1,f2): # GUI(self,cmdStr): #i3d_GUI.pyc #printout: # context(self): #common: # initWindow(self,winObjName): # initWinColumn(self,winObjName): #spaceLoc: # _exec(self,method,locSizeUI,cbUI): # updatei3dPref(self,iF1): # changeLocSize(self,iF1,v): # GUI...

i3d: FBX Batch Exporter

Batch command to export FBX(.fbx) files from Maya(.ma,.mb) files in a folder. Specified nodes and attributes will be baked. Top node(s) of hierarchy of those baked nodes will be selected when exporting. Usage: In a folder, place all Maya files(.ma or .mb). Also place bake.txt in this folder. This folder need to be in your Documents folder. (Windows only) It should look like this(Windows only): \Users\Documents\foldername\ Sample: bake.txt   (this case, HIK bones and attributes) needs to be in  \Users\Documents\foldername\ FBX files: All FBX files will be exported to foldername\fbx\ folder. Command: import i3d,i3d_anim as iA;iA.FBX().batchExport("foldername"); Prerequisites: Download i3d pyc files. https://ironthreed.blogspot.com/2019/02/i3d-2019-version-i3d-python-script-files.html

i3d: Rebuildng a hierarchy from .anim file

I experieced that .anim files are no longer usable if the controller rigs used to do animExport has been hierarchically changed. So, I wrote codes to read .anim file context and extract all node names and hierarchy info to rebuild using transform nodes in Maya. The second command includes copy/paste functionality. Select a top node of hierarchy you want to import animations to and execute the command. Usage: A dialog window will show up when excuting below command. Specify a .anim file you saved using animImportExport. It will rebuild an entire hierarchy with transform nodes from the anim file. Command: import i3d,i3d_anim; i3d_anim .animImpExp().imp(); import i3d,i3d_anim;i3d_anim.animImpExp().main(); # The second Prerequisites: Download i3d pyc files. https://ironthreed.blogspot.com/2019/02/i3d-2019-version-i3d-python-script-files.html

Python: Show by type in active modelPanel

# Show by type in active modelPanel def _modelEditor():     import maya.cmds as mc;     mod = mc.getModifiers();     val = 1;     if mod: val = 0;     aPnl = mc.getPanel(wf=1);     mPnl = "modelPanel";     num = len(mPnl);     if len(aPnl)>=num and aPnl[0:num]==mPnl:         attrs = [             "controllers",             "nurbsCurves",             "nurbsSurfaces",             "cv",             "hulls",             "polymeshes",             "subdivSurfaces",             "planes",             "lights",             "cameras",             "ima...

i3d: Open current folder in explorer

i3d: Open current folder in explorer Open a current folder in windows explorer. Command: import i3d;from i3d_utility import windowsOps as iWO;iWO().openExplorer("currentDir"); Prerequisites: Download i3d pyc files.

i3d: Quick Save

i3d: Quick Save Handy quick saving scene command Command: import i3d;from i3d_utility import quickSave as qS;qS().sequantial(1,3,""); Input Arguments: int1, int2, string int1: This number will be added when current scene does not have a number at the end of its name. int2: Digit when adding a number. string: string can be added before a new number Example1: Your current scene file is "test_maya_file.mb". Execute  import i3d;from i3d_utility import quickSave as qS;qS().sequantial(4,3,"_"); in python script editor. This will save current scene as " test_maya_file _004 .mb". Example2: Your current scene file is now "test_maya_file_004.mb". Execute  import i3d;from i3d_utility import quickSave as qS;qS().sequantial(4,3,"_");  in python script editor. This time, it will save current scene as  " test_maya_file _005 .mb". When the current scene has number at the end of its name, it ignores all input ...

Math: Distance by python and MEL

Math: Distance by python and MEL # python: cmds def py_distance1():    import maya.cmds as mc;    dest = False;    sel = mc.ls(sl=1,l=1);    if len(sel)==2:        a = mc.xform(sel[0],q=1,ws=1,t=1);        b = mc.xform(sel[1],q=1,ws=1,t=1);        import math;        dist = math.sqrt(math.pow(a[0]-b[0],2)+math.pow(a[1]-b[1],2)+math.pow(a[2]-b[2],2));    return(dist); print py_distance1(); # python: pymel def py_distance2():    import pymel.core as pm;    dist = False;    sel = pm.selected();    if len(sel)==2:        a = sel[0].translate.get();        b = sel[1].translate.get();        dist = (a-b).length();    return(dist); print py_distance2(); # python: api.OpenMaya def py_distance3():    import maya.cmds as m...

Maya GUI Tool: Renamer (Old version)

Image
GUI: Renamer (Old version) Prefix:     Adds prefix string in left text field to selected nodes. Postfix:     Appends postfix string in right text field to selected nodes. Replace:     Replace name string of selected nodes. From string in left text field to the one in right. Serial No:     Rename selected nodes with serial number in order of selection. Upper right integer:     Digit number for Serial No renaming. Prerequisites: Download i3d pyc files. https://ironthreed.blogspot.com/2019/02/i3d-2019-version-i3d-python-script-files.html Python command: import i3d,i3d_GUI as i3d_G;i3d_G.renamer().GUI("i3d_G"); Prefix "Head_" is added at the beginning. Postfix "_Tail" is appended at the end. Replace "_T" is replaced with "_mid_T" Serial No Below, 2 digits starting number is 8. Selection order is Serial_08, Serial_09, Serial_10 then Serial_11

Maya GUI Tool: Following Camera

Image
GUI: Following Camera Create:     Create(Duplicate) a camera follows the selected object along selected axis in the active panel. Change:     Change following axis of active camera in the active panel. Delete:     Delete all following camera generated by this tool. Prerequisites: Download i3d pyc files. https://ironthreed.blogspot.com/2019/02/i3d-2019-version-i3d-python-script-files.html Python command: import i3d,i3d_GUI;i3d_GUI.followCam().GUI("i3d_GUI");