1

I want to mirror an object in maya "object1" and delete it's original version after the mirroring

cmds.polyMirrorFace("object1",name="object1Mirror",cutMesh=0,axis=0,axisDirection=1, mergeMode=0, mergeThresholdType=0, mergeThreshold=0.001, mirrorAxis=2, mirrorPosition=0, smoothingAngle=30, flipUVs=1, ch=0);
cmds.delete("object1")

But the polyMirrorFace gives me one merged object besides the fact that I thought I've deactivated merging with mergeMode=0.

When I mirror in maya via UI, it works fine.

I hope, somebody can help.

goetzmoritz
  • 453
  • 1
  • 5
  • 23
  • When you mirror in maya via the UI, check the script editor and see what command Maya used to successfully perform the mirroring. I tried the same command you used and (probably due to my different maya version) I got several errors for some of those flags you used were not available for me, and some I couldn't find in the documentation, like `smoothingAngle`, `flipUVs`.. – chickity china chinese chicken Jul 11 '17 at 21:39
  • When you mirror in maya via the UI, check the script editor and see what command Maya used to successfully perform the mirroring. I tried the same command you used and (probably due to my different maya version) I got several errors for some of those flags you used were not available for me, and some I couldn't find in the documentation, like `smoothingAngle`, `flipUVs` https://help.autodesk.com/cloudhelp/2016/CHS/Maya-Tech-Docs/CommandsPython/polyMirrorFace.html – chickity china chinese chicken Jul 11 '17 at 21:45

1 Answers1

1

Try this logic:

# mirror about +Y direction by merging the border vertices
import maya.cmds as mc

mc.polyCube( name='polyCube5' )

# deliberately deleting face `1`
mc.delete( 'polyCube5.f[1]' )

# mirror about +Y direction
mc.polyMirrorFace( 'polyCube5', direction=0, mergeMode=2 )

# deleting all faces but a target
mc.delete( 'polyCube5.f[0:9]' )

or this logic to delete source object and leave a duplicate:

import maya.cmds as cmds

cmds.polyCube( name='poly1' )
cmds.move( -1, y=True )
cmds.duplicate( st=True )
cmds.move( 2, y=True )
cmds.delete( 'poly1' )

ADDITION:

import maya.cmds as mc

mc.polyHelix(c=3, h=2, w=2, r=0.4, sa=8, sco=50, sc=0, d=1, rcp=0, cuv=3, ch=1) 
mc.scale(1,1,-1, 'pHelix1', pivot=(0,0,0), absolute=True)
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
  • That works for most of the cases, I guess. It gets funnier when you do that with imported objects. Lets say, you import an object from a .mb including several groups, mirror it one by one and than export as obj e.g. But yes, your version works. Thanks for that! – goetzmoritz Jul 12 '17 at 08:27
  • Thanks, stil I have the issue if I iterate through multiple objects that they are merged. Somehow this seems to be bugged. – goetzmoritz Jul 12 '17 at 13:37
  • cmds.polyHelix(c=3, h=2, w=2 ,r=0.4 ,sa=8 , sco=50 ,sc=0, d=1 , rcp=0 ,cuv=3 ,ch= 1) sel = cmds.ls(geometry=True) for obj in sel: cmds.polyMirrorFace(obj, mm=0, cm=True) – goetzmoritz Jul 13 '17 at 07:07
  • It does not format my code correctly, I hope it is understandable. It creates a helix, mirrors it (and any other object) but I always get a merged helix regardless of the options I use for mirroring. – goetzmoritz Jul 13 '17 at 07:09
  • In this case you can use 'scale' = -1 along Z axis. I updated the answer. – Andy Jazz Jul 13 '17 at 20:21
  • Thank you, but there is a difference between scaling by -1 and the mirroring as UVs and normals are not mirrored. But I get your point basically, thank you. – goetzmoritz Jul 17 '17 at 06:58