mirror nurbsCurve in Maya

147 views
Skip to first unread message

Pacifique Nzitonda

unread,
Sep 25, 2022, 3:17:06 PM9/25/22
to Python Programming for Autodesk Maya
Hi every body,
Can someone tell me how to mirror from +X to -X a nurbsCurve inside Maya using cmds or pymel ?
 I do not want to do the manual way of duplicating the curve, grouping it, fliping the group's x scale and freeze transform. I'm looking for a mathematical approach.
 
One way I was thinking doing this is to get nurbsCurve's points and for each point multiply its X value by -1 and then reconstruct  a new nurbsCurve using the new values.
I'm not sure if it's an effective solution.

Thanks

benjamin ghys

unread,
Sep 25, 2022, 5:19:28 PM9/25/22
to Python Programming for Autodesk Maya

Hello,

Your last suggestion should perfectly work to mirror

tomas mikulak

unread,
Sep 26, 2022, 3:27:41 AM9/26/22
to python_in...@googlegroups.com
Hi, you can use mine, 
select good shape curve then not shaped and run script. it will mirror shape to another curve. 

ne 25. 9. 2022 o 23:19 benjamin ghys <benjami...@gmail.com> napísal(a):
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/e4bd8d1b-1646-44a6-bf81-684409003346n%40googlegroups.com.
tm_flipControlShape.mel

Marcus Ottosson

unread,
Sep 26, 2022, 4:49:39 AM9/26/22
to python_in...@googlegroups.com

I think OP specifically asked for a way that did not involve duplicating and scaling.

The Maya API has some options, in a nutshell:

  1. Read points on original curve
  2. Negate their x coordinate
  3. Generate a new curve using the negated points
import cmdx

# Read original points
original = cmdx.selection()[0]
original_points = [p.read() for p in original["controlPoints"]]

# Negate an axis
negated_points = [(p[0], p[1], p[2] * -1) for p in original_points]

# Make new curve
parent = cmdx.createNode("transform", name="negated")
curve = cmdx.curve(parent, points=negated_points)

image.png

Key parts being the curve function, which is here and iterating over the controlPoints array attribute which you can do using cmds too.


Pacifique Nzitonda

unread,
Sep 26, 2022, 5:46:32 AM9/26/22
to python_in...@googlegroups.com
Cool, it works just fine. But if anyone has another way around it, please let me know. 

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/g9HD6aqJ448/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.

Pacifique Nzitonda

unread,
Sep 26, 2022, 5:49:50 AM9/26/22
to python_in...@googlegroups.com
Hi Marcus, I will test this. It looks really clean. Thanks in advance! 

You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/g9HD6aqJ448/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODzRuEs0ZTNYyV760n7As9ADZkBN-_Qj2DaVTdz9HCC1A%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages