Glad you got it working.

Mirror Cut is also using the polyCut node, have a look in the Hypershade if
you're curious to see how it differs.


On 30 January 2014 02:08, Aren Voorhees <[email protected]> wrote:

> Hey Marcus, I gave this a try too, and it seems to be working - I never
> thought of doing it like this!  I am a bit embarrassed to admit, I also
> found a way this morning of doing this in Maya with no scripting at all
> (Mesh-->Mirror Cut).  BUT the important thing is I learned a lot working on
> the script and hearing other suggestions that people threw out there.
>
> Thanks again to everyone for their input/ideas!
>
>
> On Tuesday, January 28, 2014 3:26:39 PM UTC-6, Marcus Ottosson wrote:
>>
>> If you're comfortable using nodes to achieve your goal, then you might be
>> interested in 
>> polyCut<http://download.autodesk.com/global/docs/maya2013/en_us/Nodes/polyCut.html>
>> .
>>
>> Here's an example as in maya ascii format; either run it as mel, or save
>> it to polycut.ma or such.
>>
>> requires maya "2014";
>>
>>
>> createNode transform -n "mirrorCutPlane1";
>>  setAttr ".r" -type "double3" 0 90 0 ;
>>  setAttr ".smd" 4;
>> createNode sketchPlane -n "mirrorCutPlane1Shape" -p "mirrorCutPlane1";
>>  setAttr -k off ".v";
>> createNode transform -n "polySurface1";
>> createNode mesh -n "polySurfaceShape1" -p "polySurface1";
>>  setAttr -k off ".v";
>>  setAttr -s 2 ".iog[0].og";
>>  setAttr ".vir" yes;
>>  setAttr ".vif" yes;
>>  setAttr ".uvst[0].uvsn" -type "string" "map1";
>>  setAttr ".cuvs" -type "string" "map1";
>>  setAttr ".dcc" -type "string" "Ambient+Diffuse";
>>  setAttr ".covm[0]"  0 1 1;
>>  setAttr ".cdvm[0]"  0 1 1;
>>  setAttr ".vbc" no;
>> createNode polySphere -n "polySphere1";
>> createNode polyCut -n "polyCut1";
>>  setAttr ".uopa" yes;
>>  setAttr ".ics" -type "componentList" 1 "f[*]";
>>  setAttr ".ix" -type "matrix" 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1;
>>  setAttr ".ws" yes;
>>  setAttr ".mp" -type "matrix" 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1;
>>  setAttr ".ps" -type "double2" 2.0000002384185791 2 ;
>>  setAttr ".df" yes;
>> connectAttr "polyCut1.out" "polySurfaceShape1.i";
>> connectAttr "polySphere1.out" "polyCut1.ip";
>> connectAttr "mirrorCutPlane1.t" "polyCut1.pc";
>> connectAttr "mirrorCutPlane1.r" "polyCut1.ro";
>>
>>
>>
>> On Monday, 27 January 2014 18:13:31 UTC, Aren Voorhees wrote:
>>>
>>> Hey all,
>>>
>>> I am trying to create a tool for modeling that will delete all faces
>>> that are located in negative x (as a modeler, I've always wanted something
>>> like this).  I've got most of it working - I create a list of the faces,
>>> then loop through them, determining their position using the positions of
>>> their verts.  It's the last line, or few lines where I'm a bit lost.  I'm
>>> appending all faces that come back negative into a list, then trying to
>>> delete that list.  Clearly, I'm doing something wrong there.
>>>
>>> If you notice anything else that could be done better, feel free to let
>>> me know!
>>>
>>> If anyone can help out a lost beginner, I'd be extremely thankful!
>>>
>>> import maya.cmds as cmds
>>>
>>>
>>> #Define object name
>>>
>>> curSel = (cmds.ls (sl=True)[0])
>>>
>>>
>>> numOfFaces = len(cmds.getAttr(curSel + ".f[:]"))
>>>
>>> for i in xrange (0,numOfFaces):
>>>
>>>     cmds.select(curSel + ".f[%d]" %i, add=1)
>>>
>>>
>>> #Create list (array) of faces in current object
>>>
>>> faceIndexList = cmds.ls(sl=True,fl=True)
>>>
>>>
>>>
>>> #Loop through the list of faces from above
>>>
>>> for i in faceIndexList:
>>>
>>>
>>>
>>>     #Selects the current face
>>>
>>>     cmds.select (i)
>>>
>>>
>>>
>>>     #Converts selection to verts (tv == toVerts)
>>>
>>>     faceToVerts = cmds.polyListComponentConversion (tv=1)
>>>
>>>     cmds.select (faceToVerts)
>>>
>>>
>>>
>>>     #Stores the selected verts into a variable (fl == Flatten, which
>>> lists out things individually)
>>>
>>>     vertIndexList = (cmds.ls (sl=True,fl=True))
>>>
>>>
>>>
>>>     #Creating empty position variables to later store the vectors of
>>> the verts in
>>>
>>>     posX = 0
>>>
>>>     posY = 0
>>>
>>>     posZ = 0
>>>
>>>
>>>
>>>     #Loops through verts in vertIndexList
>>>
>>>     for j in vertIndexList:
>>>
>>>
>>>
>>>         cmds.select (j)
>>>
>>>
>>>
>>>         #Sets the total number of selected verts (would be 4 in most
>>> cases)
>>>
>>>         totalVertNum = len(vertIndexList)
>>>
>>>
>>>
>>>         #Gets the vector location of each vert
>>>
>>>         vertPos = cmds.xform(query=True, translation=True)
>>>
>>>
>>>
>>>         #Supposed add the X value of the selected vert to the value
>>> from the previous itteration (starts at 0)
>>>
>>>         posX += vertPos[0]
>>>
>>>         #Supposed add the Y value of the selected vert to the value
>>> from the previous itteration (starts at 0)
>>>
>>>         posY += vertPos[1]
>>>
>>>         #Supposed add the Z value of the selected vert to the value
>>> from the previous itteration (starts at 0)
>>>
>>>         posZ += vertPos[2]
>>>
>>>
>>>
>>>         #Finds the center of the face by creating a vector
>>>
>>>         faceCenter = (posX/totalVertNum), (posY/totalVertNum), (posZ/
>>> totalVertNum)
>>>
>>>
>>>
>>>     #Creates empty list to store negative faces in
>>>
>>>     negFaces = []
>>>
>>>
>>>
>>>     #If the faceCenterer variable is negative
>>>
>>>     if faceCenter[0] < 0:
>>>
>>>
>>>
>>>         #Appending all the negative x faces into negFaces
>>>
>>>         negFaces.append (i)
>>>
>>>
>>>
>>> #I thought this would delete all faces that had been appended into
>>> negFaces, but clearly I thought wrong!
>>>
>>> for i in negFaces:
>>>
>>>     cmds.delete (i)
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/c3f03679-80e6-4ab1-9dc2-6c1ab871e46a%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
*Marcus Ottosson*
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBhVcK_3UoUrQCppA8Q5T79pa1jE_U4U-CJRrXa3r4yhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to