Is it possible to freeze .ptns (tweaks) on a mesh using python?

813 views
Skip to first unread message

Chad_Fox

unread,
Sep 30, 2015, 6:28:45 PM9/30/15
to Python Programming for Autodesk Maya
Hi all

Does anyone know if it's possible to freeze .pnts (tweaks) on a mesh using python? I've been struggling with this for a while with no results. 

To be clear. I want to remove/freeze/zero these values on meshes that don't have tweak nodes or history. For those who don't know, the tweak nodes are created when a new history operator is added and all tweaks are transferred to this node from the .pnts array on the mesh shape. Fortunately when there's history I can just delete history and all tweaks are gone too.

Any input or suggestions to try would be greatly appreciated!

Thanks

Chad

Marcus Ottosson

unread,
Oct 1, 2015, 3:47:11 AM10/1/15
to python_in...@googlegroups.com
I remember encountering this not long ago and there was a scripted solution for it, a command of sorts. But I can't remember what it was..

Until you find it, you can always plug the outMesh of your mesh into the inMesh of an empty mesh (`cmds.createNode("mesh")`). It will "bake" those values into the new mesh, you can then delete the original.

--
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/4b2aad0c-f8c1-4ef5-9e76-cd6250c45bc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Roy Nieterau

unread,
Oct 2, 2015, 7:48:24 AM10/2/15
to Python Programming for Autodesk Maya
This could be of interest: http://forums.cgsociety.org/showthread.php?t=874851

*typed on phone

Cheers,
Roy

f.michal

unread,
Oct 5, 2015, 2:27:11 PM10/5/15
to python_in...@googlegroups.com
W dniu 2015-10-01 o 00:28, Chad_Fox pisze:
--
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/4b2aad0c-f8c1-4ef5-9e76-cd6250c45bc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi Chad !
Have you found any solution ? I got struck by this again lately, and I even posted to group an hour ago or so !

Chad Fox

unread,
Oct 5, 2015, 5:17:53 PM10/5/15
to python_in...@googlegroups.com
​Thanks for the input, unfortunately the CG talk thread doesn't give me any new info, in fact I recommend people read that one carefully as there's a few people tossing around ideas of .pnts that are not accurate. 

As the thread points out, you can edit pnts with setAttr, but setting the pnts to 0, 0, 0 just moves the verts back to their base location. wish I could just setIdentity on the pnts array hehe.​


-Chad


Ian Jones

unread,
Oct 5, 2015, 5:23:35 PM10/5/15
to python_in...@googlegroups.com

In the past one of the ways we've sanitized meshes like this is make a cube and combine it with the desired mesh then delete the first 6 faces (from the cube). That tends to force Maya to rebuild/reset everything.

Ian


Michał Frątczak

unread,
Oct 5, 2015, 5:24:53 PM10/5/15
to Python Programming for Autodesk Maya
There's a risk however of changing vertex order ?


On Monday, October 5, 2015 at 11:23:35 PM UTC+2, Ian Jones wrote:

In the past one of the ways we've sanitized meshes like this is make a cube and combine it with the desired mesh then delete the first 6 faces (from the cube). That tends to force Maya to rebuild/reset everything.

Ian


On Mon, Oct 5, 2015, 2:17 PM Chad Fox <chadl...@gmail.com> wrote:
​Thanks for the input, unfortunately the CG talk thread doesn't give me any new info, in fact I recommend people read that one carefully as there's a few people tossing around ideas of .pnts that are not accurate. 

As the thread points out, you can edit pnts with setAttr, but setting the pnts to 0, 0, 0 just moves the verts back to their base location. wish I could just setIdentity on the pnts array hehe.​


-Chad

On Mon, Oct 5, 2015 at 11:26 AM, f.michal <f.mi...@gmail.com> wrote:
W dniu 2015-10-01 o 00:28, Chad_Fox pisze:
Hi all

Does anyone know if it's possible to freeze .pnts (tweaks) on a mesh using python? I've been struggling with this for a while with no results. 

To be clear. I want to remove/freeze/zero these values on meshes that don't have tweak nodes or history. For those who don't know, the tweak nodes are created when a new history operator is added and all tweaks are transferred to this node from the .pnts array on the mesh shape. Fortunately when there's history I can just delete history and all tweaks are gone too.

Any input or suggestions to try would be greatly appreciated!

Thanks

Chad
--
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+unsub...@googlegroups.com.
Hi Chad !
Have you found any solution ? I got struck by this again lately, and I even posted to group an hour ago or so !

--
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+unsub...@googlegroups.com.

--
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+unsub...@googlegroups.com.

Ian Jones

unread,
Oct 5, 2015, 5:28:50 PM10/5/15
to Python Programming for Autodesk Maya

Only if it has too (verts with no edges etc) but its almost always desirable in our experience. Of the mesh is generally clean Maya will preserve the vertex order with operations like that. We've been doing it with blendshapes for years.


On Mon, Oct 5, 2015, 2:25 PM Michał Frątczak <f.mi...@gmail.com> wrote:
There's a risk however of changing vertex order ?


On Monday, October 5, 2015 at 11:23:35 PM UTC+2, Ian Jones wrote:

In the past one of the ways we've sanitized meshes like this is make a cube and combine it with the desired mesh then delete the first 6 faces (from the cube). That tends to force Maya to rebuild/reset everything.

Ian


On Mon, Oct 5, 2015, 2:17 PM Chad Fox <chadl...@gmail.com> wrote:
​Thanks for the input, unfortunately the CG talk thread doesn't give me any new info, in fact I recommend people read that one carefully as there's a few people tossing around ideas of .pnts that are not accurate. 

As the thread points out, you can edit pnts with setAttr, but setting the pnts to 0, 0, 0 just moves the verts back to their base location. wish I could just setIdentity on the pnts array hehe.​


-Chad

On Mon, Oct 5, 2015 at 11:26 AM, f.michal <f.mi...@gmail.com> wrote:
W dniu 2015-10-01 o 00:28, Chad_Fox pisze:
Hi all

Does anyone know if it's possible to freeze .pnts (tweaks) on a mesh using python? I've been struggling with this for a while with no results. 

To be clear. I want to remove/freeze/zero these values on meshes that don't have tweak nodes or history. For those who don't know, the tweak nodes are created when a new history operator is added and all tweaks are transferred to this node from the .pnts array on the mesh shape. Fortunately when there's history I can just delete history and all tweaks are gone too.

Any input or suggestions to try would be greatly appreciated!

Thanks

Chad
--
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.
Hi Chad !
Have you found any solution ? I got struck by this again lately, and I even posted to group an hour ago or so !

--
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.

--
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.

--
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/745a4f68-7691-4c57-9ea1-558eb7ab9cd7%40googlegroups.com.

Chad Fox

unread,
Oct 5, 2015, 5:45:06 PM10/5/15
to python_in...@googlegroups.com
Yeah, worked great with blendshapes. Problem with this merging of meshes is that it creates a new mesh and we lose any custom attrs and connections on the mesh. I've been freezing tweaks by Applying a lattice to the entire model then deleting history. This transfers all pnts to tweak nodes then deletes them. In anycase, I'm still hoping there's a way to freeze the tweaks without this workaround. :P

Cheers


-Chad


Marcus Ottosson

unread,
Oct 6, 2015, 3:45:34 AM10/6/15
to python_in...@googlegroups.com
Try this.

cmds.polyMoveVertex("pCubeShape1", constructionHistory=False)


Alternatively, connect the outMesh to a new mesh, as in my first post. And then, disconnect, and connect the outMesh of the new mesh into the inMesh of the original. This will give you double transformations. Then you can simply the vertex values.


For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Michał Frątczak

unread,
Oct 6, 2015, 5:44:50 AM10/6/15
to Python Programming for Autodesk Maya
That seems to do it. Thanks to all.


-Chad


To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
Hi Chad !
Have you found any solution ? I got struck by this again lately, and I even posted to group an hour ago or so !

--
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+unsub...@googlegroups.com.

--
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+unsub...@googlegroups.com.

--
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+unsub...@googlegroups.com.

--
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+unsub...@googlegroups.com.

--
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+unsub...@googlegroups.com.



--
Marcus Ottosson
konstr...@gmail.com

Chad Fox

unread,
Oct 7, 2015, 4:52:27 PM10/7/15
to python_in...@googlegroups.com
Marcus, you are the man. Thanks for this solution!


-Chad




-Chad


To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
Hi Chad !
Have you found any solution ? I got struck by this again lately, and I even posted to group an hour ago or so !

--
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.

--
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.

--
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.

--
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.

--
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.



--
Marcus Ottosson
konstr...@gmail.com

--
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/a31add83-2c55-4b2b-a193-b028954cd149%40googlegroups.com.

Paul Molodowitch

unread,
Oct 7, 2015, 8:56:49 PM10/7/15
to python_in...@googlegroups.com
Awesome, I didn't know about that! In the past I had to do the connect-to-a-mesh hack... this is way better.  Thanks Marcus!

Marcus Ottosson

unread,
Oct 8, 2015, 3:39:31 AM10/8/15
to python_in...@googlegroups.com
No problem guys, but I can't take all the credit. I got suggested this solution only a few weeks ago by Roy Nieterau.


For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Nicolas Combecave

unread,
Oct 9, 2015, 1:27:50 PM10/9/15
to python_in...@googlegroups.com
The pnts attribute is a multi attribute, that is empty when no tweaks are made on a geometry.
So we basically do a removeMultiInstance on every index found for the attribute.
Special care needs to be taken if this object is deformed, because the index 0 is connected to a tweak node, via a tweakLocation attribute.
So you have to disconnect tweakLocation attribute, do the removeMultiInstance, and reconnect the tweakLocation attribute...
Go figure...
A little bit convoluted, but it's the cleanest way we found so far.

Nicolas



Nicolas Combecave

unread,
Oct 10, 2015, 1:22:34 AM10/10/15
to python_in...@googlegroups.com
Ah Sorry guys,
I read "remove tweaks" instead of freeze!

Nicolas

Chad Fox

unread,
Oct 13, 2015, 7:18:32 PM10/13/15
to python_in...@googlegroups.com
Thats okay! Removal is good too since freezing them with the moveVertices command does leave the pnts array intact even though they are all zero'd.

Thanks for your input

Cheers

Chad


-Chad


Roy Nieterau

unread,
Dec 6, 2019, 5:33:53 AM12/6/19
to Python Programming for Autodesk Maya
I know this is an ancient topic - but just to make sure other people might find this when they google or search. This seems like it's the exact Maya function to just "collapse" the .pnts data into the vertex positions: https://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/CommandsPython/polyCollapseTweaks.html

This Maya function will "bake in" or "collapse" the Vertex tweaks of a Mesh into the vertex positions. It basically clears the .pnts attribute whilst preserving your output. It's super fast too.

Be aware that it seems to error out when there's no tweaks on the mesh yet. However, that's not an issue since you can also query it instantly with this method:
for mesh in meshes:
   
if cmds.polyCollapseTweaks(mesh, query=True, hasVertexTweaks=True):
        cmds
.polyCollapseTweaks(mesh)

Chad Fox

unread,
Dec 6, 2019, 3:36:41 PM12/6/19
to Python Programming for Autodesk Maya
Thanks for the follow up. I will take a look at this today!

-Chad



--
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.

Chad Fox

unread,
Dec 6, 2019, 3:38:56 PM12/6/19
to Python Programming for Autodesk Maya
Ha, according to the docs this was added in Maya 2016, just after I was trying to solve the problem.

-Chad


Reply all
Reply to author
Forward
0 new messages