Created
February 28, 2019 22:22
-
-
Save Onefabis/36e244e59edccee7d43ac4b442b518fa to your computer and use it in GitHub Desktop.
noflip rivet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as mc | |
class randomScatter(): | |
def _init_(self): | |
if mc.window("randSelection", exists=1): | |
mc.deleteUI("randSelection") | |
mc.window("randSelection", t="WithOutFlip_Rivet - Avijit Das", w=405, sizeable=0) | |
mc.rowColumnLayout(nc=3,cal=[(1,"right")], cw=[(1,100),(2,200),(3,105)]) | |
mc.rowColumnLayout(w=405) | |
mc.text("Select two Edge the click Rivet", height=20) | |
mc.separator(height=20, style='in') | |
mc.button("excute", l="Rivet", w=403, al="right", c="rivet()") | |
mc.rowColumnLayout(w=405) | |
mc.showWindow("randSelection") | |
randomScatter() | |
def rivet(): | |
sel=mc.ls(sl=True, fl=True) | |
for N in sel: | |
obj=N | |
mc.select(sel) | |
obj=mc.ls(sl=True,fl=True) | |
lofta=mc.loft(obj,ch=1,u=True,c=False,ar=False,d=3,ss=True,rn=False,po=False,rsn=True) | |
renamE=mc.rename(lofta[1],"Riv_Loft") | |
infoNode=mc.pointOnSurface(lofta[0], ch=True, u=0.55, v=0.33) | |
mc.setAttr(infoNode + ".turnOnPercentage",1) | |
infoNodeRen=mc.rename(infoNode,renamE + "pointOnSurfaceUI") | |
mc.connectAttr(renamE +".outputSurface", infoNodeRen + ".inputSurface",f=True) | |
matrixFourNode=mc.shadingNode("fourByFourMatrix",asUtility=True, n=renamE + "_matrixFourNode") | |
mc.connectAttr(infoNodeRen + ".normalizedNormalX", matrixFourNode + ".in00",f=True) | |
mc.connectAttr(infoNodeRen + ".normalizedNormalY", matrixFourNode + ".in01",f=True) | |
mc.connectAttr(infoNodeRen + ".normalizedNormalZ", matrixFourNode + ".in02",f=True) | |
mc.connectAttr(infoNodeRen + ".normalizedTangentUX", matrixFourNode + ".in10",f=True) | |
mc.connectAttr(infoNodeRen + ".normalizedTangentUY", matrixFourNode + ".in11",f=True) | |
mc.connectAttr(infoNodeRen + ".normalizedTangentUZ", matrixFourNode + ".in12",f=True) | |
mc.connectAttr(infoNodeRen + ".normalizedTangentVX", matrixFourNode + ".in20",f=True) | |
mc.connectAttr(infoNodeRen + ".normalizedTangentVY", matrixFourNode + ".in21",f=True) | |
mc.connectAttr(infoNodeRen + ".normalizedTangentVZ", matrixFourNode + ".in22",f=True) | |
mc.connectAttr(infoNodeRen + ".positionX", matrixFourNode + ".in30",f=True) | |
mc.connectAttr(infoNodeRen + ".positionY", matrixFourNode + ".in31",f=True) | |
mc.connectAttr(infoNodeRen + ".positionZ", matrixFourNode + ".in32",f=True) | |
matrixDecompNode=mc.shadingNode("decomposeMatrix", asUtility=True, n=renamE + "_matrixDecompNode") | |
mc.connectAttr(matrixFourNode + ".output", matrixDecompNode + ".inputMatrix",f=True) | |
matrixGrp=mc.group(em=True, n="matrixRivet") | |
mc.connectAttr(matrixDecompNode + ".outputTranslate", matrixGrp + ".translate",f=True) | |
mc.connectAttr(matrixDecompNode + ".outputRotate", matrixGrp + ".rotate",f=True) | |
for u in matrixGrp: | |
mc.curve(d=1, p=[(0.0, 0.0, 1.03), (-0.52, 0.0, 0.9), (-0.9, 0.0, 0.52), (-1.03, 0.0, 0.0), (-0.9, 0.0, -0.52), (-0.52, 0.0, -0.9), (0.0, 0.0, -1.03), (0.52, 0.0, -0.9), (0.9, 0.0, -0.52), (1.03, 0.0, 0.0), (0.9, 0.0, 0.52), (0.52, 0.0, 0.9), (0.0, 0.0, 1.03), (0.0, 0.73, 0.73), (0.0, 1.03, 0.0), (0.0, 0.73, -0.73), (0.0, 0.0, -1.03), (0.0, -0.73, -0.73), (0.0, -1.03, 0.0), (-0.52, -0.9, 0.0), (-0.9, -0.52, 0.0), (-1.03, 0.0, 0.0), (-0.9, 0.52, 0.0), (-0.52, 0.9, 0.0), (0.0, 1.03, 0.0), (0.52, 0.9, 0.0), (0.9, 0.52, 0.0), (1.03, 0.0, 0.0), (0.9, -0.52, 0.0), (0.52, -0.9, 0.0), (0.0, -1.03, 0.0), (0.0, -0.73, 0.73), (0.0, 0.0, 1.03)]) | |
mc.addAttr(matrixGrp, at='enum', keyable=True, en='Off:On', ln='ShapeVis') | |
mc.addAttr(matrixGrp, at='double', keyable=True, ln='parameterU') | |
mc.addAttr(matrixGrp, at='double', keyable=True, ln='parameterV') | |
mc.setAttr(matrixGrp + ".parameterU", .500) | |
mc.setAttr(matrixGrp + ".parameterV", .500) | |
mc.connectAttr(matrixGrp + ".parameterU", infoNodeRen + ".parameterU", f=True) | |
mc.connectAttr(matrixGrp + ".parameterV", infoNodeRen + ".parameterV", f=True) | |
mycircle = mc.ls(sl=True, fl=True) | |
myshp = mc.listRelatives(mycircle[0], shapes=True) | |
reN = mc.rename(myshp, matrixGrp + "Shape") | |
mc.parent(mycircle[0], matrixGrp) | |
mc.makeIdentity(mycircle[0], apply=False, t=1, r=1, s=1, n=0) | |
mc.parent(reN, matrixGrp, r=1, s=1) | |
mc.delete(mycircle[0]) | |
break | |
randomScatter()._init_() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment