Discussion:
[Maya-Python] makeIdentity Won't Run Before Parent Command
Kevin C. Burke
2016-10-20 03:42:06 UTC
Permalink
Hello,
I'm trying to write a script for combining multiple NURBS curves. If I
scale the curves, then try to combine them, they don't keep their
transformations.

import pymel.core as pm

curves = pm.selected()

for curve in curves:
pm.makeIdentity(curve, apply=True, translate=1, rotate=1, scale=1)

for curve in curves[1:]:
shape = curve.getShape()
pm.parent(shape, curves[0], relative=True, shape=True)
pm.delete(curve)


For some reason, the makeIdentity command (aka Freeze Transformations)
won't run before the parent command. I've tried:

- time.sleep
- flushIdleQueue: froze Maya 2016
- parenting the transforms to the master transform (curves[0], below)
before running makeIdentity

If I take out the parent command, the makeIdentity works as expected.

I'm running out of ideas. Can anyone help please? Thank you!


<Loading Image...>
--
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2d9a378d-8a1f-49a0-b60a-6c8d14ea39a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mahmoodreza Aarabi
2016-10-20 07:55:44 UTC
Permalink
Hey man
For combining curve it is better to put all shapes of them inside one
transform node.

Before:

[image: Inline image 1]

After:

[image: Inline image 2]
Post by Kevin C. Burke
Hello,
I'm trying to write a script for combining multiple NURBS curves. If I
scale the curves, then try to combine them, they don't keep their
transformations.
import pymel.core as pm
curves = pm.selected()
pm.makeIdentity(curve, apply=True, translate=1, rotate=1, scale=1)
shape = curve.getShape()
pm.parent(shape, curves[0], relative=True, shape=True)
pm.delete(curve)
For some reason, the makeIdentity command (aka Freeze Transformations)
- time.sleep
- flushIdleQueue: froze Maya 2016
- parenting the transforms to the master transform (curves[0], below)
before running makeIdentity
If I take out the parent command, the makeIdentity works as expected.
I'm running out of ideas. Can anyone help please? Thank you!
<https://lh3.googleusercontent.com/-OHhLlgUlePI/WAg88lEUfZI/AAAAAAABeGY/gxgDNVlJxJ8pf9ETL77l5ga2fg1dtyDewCLcB/s1600/Capture.PNG>
--
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
To view this discussion on the web visit https://groups.google.com/d/
msgid/python_inside_maya/2d9a378d-8a1f-49a0-b60a-
6c8d14ea39a3%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/2d9a378d-8a1f-49a0-b60a-6c8d14ea39a3%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
Bests,
madoodia
--
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CADvbQw%2BU-2Esk_NmvHo3sKQfX-466E_uMgL_Kvm%2B3apq5pz10Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Neil Roche
2016-10-20 09:47:26 UTC
Permalink
Try assigning your sliced list (curves) to separate variables:

import pymel.core as pm

curves =pm.selected()
masterCurve = curves[0]
slaveCurves = curves[1:]

for crv in curves:
pm.makeIdentity(crv, apply=True, translate=1, rotate=1, scale=1)

for crv in slaveCurves:
pm.parent(crv.getShape(), masterCurve, relative=True, shape=True)
pm.delete(crv)

It works for me.

Neil
Post by Kevin C. Burke
Hello,
I'm trying to write a script for combining multiple NURBS curves. If I
scale the curves, then try to combine them, they don't keep their
transformations.
import pymel.core as pm
curves = pm.selected()
pm.makeIdentity(curve, apply=True, translate=1, rotate=1, scale=1)
shape = curve.getShape()
pm.parent(shape, curves[0], relative=True, shape=True)
pm.delete(curve)
For some reason, the makeIdentity command (aka Freeze Transformations)
- time.sleep
- flushIdleQueue: froze Maya 2016
- parenting the transforms to the master transform (curves[0], below)
before running makeIdentity
If I take out the parent command, the makeIdentity works as expected.
I'm running out of ideas. Can anyone help please? Thank you!
<https://lh3.googleusercontent.com/-OHhLlgUlePI/WAg88lEUfZI/AAAAAAABeGY/gxgDNVlJxJ8pf9ETL77l5ga2fg1dtyDewCLcB/s1600/Capture.PNG>
--
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/9ff2224a-5bdd-49c0-89e2-cb9e4c8e889f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Kevin C. Burke
2016-10-21 01:48:11 UTC
Permalink
Thanks Mahmoodreza & Neil for the help.

Neither of these worked for me, unfortunately.

First, I want the three shapes to appear within one transform. It is
definitely possible if I do it manually, but through scripting, it's not
working. I think it is better to only have one object to select in the
Outliner, rather than three.

I have attached a Maya file with three curves. All of them have Scale
transformations applied to them.

If I run my code or Neil's code, the Curves don't have makeIdentity applied
to them before the parenting.

Here
is a video demonstrating this and the
Maya file is attached.

Any help on why this happens would be fantastic. Thank you!
Post by Kevin C. Burke
import pymel.core as pm
curves =pm.selected()
masterCurve = curves[0]
slaveCurves = curves[1:]
pm.makeIdentity(crv, apply=True, translate=1, rotate=1, scale=1)
pm.parent(crv.getShape(), masterCurve, relative=True, shape=True)
pm.delete(crv)
It works for me.
Neil
Post by Kevin C. Burke
Hello,
I'm trying to write a script for combining multiple NURBS curves. If I
scale the curves, then try to combine them, they don't keep their
transformations.
import pymel.core as pm
curves = pm.selected()
pm.makeIdentity(curve, apply=True, translate=1, rotate=1, scale=1)
shape = curve.getShape()
pm.parent(shape, curves[0], relative=True, shape=True)
pm.delete(curve)
For some reason, the makeIdentity command (aka Freeze Transformations)
- time.sleep
- flushIdleQueue: froze Maya 2016
- parenting the transforms to the master transform (curves[0], below)
before running makeIdentity
If I take out the parent command, the makeIdentity works as expected.
I'm running out of ideas. Can anyone help please? Thank you!
<https://lh3.googleusercontent.com/-OHhLlgUlePI/WAg88lEUfZI/AAAAAAABeGY/gxgDNVlJxJ8pf9ETL77l5ga2fg1dtyDewCLcB/s1600/Capture.PNG>
--
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/gCuOuAXy4Uc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit https://groups.google.com/d/
msgid/python_inside_maya/9ff2224a-5bdd-49c0-89e2-
cb9e4c8e889f%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/9ff2224a-5bdd-49c0-89e2-cb9e4c8e889f%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAMYDmGxVKPgOO4GMpT0rsz%2BZQNf1JVvBeWFJa19%3DiUwHCWkGqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Neil Roche
2016-10-21 09:47:23 UTC
Permalink
Your code is actually working, if you select a curveShape and switch to
component mode you can see the NurbsCurve cvs are in the correct frozen
position it's just that the curve shape has not been updated. You can use
the NurbsCurve.updateCurve() method to redraw the curve in the right
position.

If you reselect the transform and run:

for shape in selected()[0].getShapes():
shape.updateCurve()

But, strangely this won't work as part of the same script??
--
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/cfc9887e-328a-466e-913b-ae9764186ac8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Neil Roche
2016-10-21 10:27:05 UTC
Permalink
It's actually a Viewport 2.0 error, it's not redrawing the curves correctly.

Your code is fine and that's why it worked yesterday for me as well, I must
have had Legacy Default Viewport set.
--
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d67d7f21-f60f-4391-be1c-874090264156%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Neil Roche
2016-10-21 10:29:16 UTC
Permalink
You also don't need to put the makeIdentity command into a loop, it can
accept a list as an argument too.
Post by Neil Roche
It's actually a Viewport 2.0 error, it's not redrawing the curves correctly.
Your code is fine and that's why it worked yesterday for me as well, I
must have had Legacy Default Viewport set.
--
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/7f125f11-3caf-4ba4-ab93-6d16e05835c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...