Running process/command without the prompt appearing

59 views
Skip to first unread message

Alan Fregtman

unread,
Jul 28, 2010, 5:03:36 PM7/28/10
to Maya Python List
Hey guys,

I'm doing a tool that's using os.system() a lot to run some
commandline tools. Does anyone know an alternative or trick to have
the prompt not appear every time?

Cheers,

-- Alan

Alan Fregtman

unread,
Jul 28, 2010, 5:19:08 PM7/28/10
to Maya Python List
And shortly after I press "Send", I notice this search result on Google:
http://linux.byexamples.com/archives/366/python-how-to-run-a-command-line-within-python/

I guess that does it.

Ian Jones

unread,
Jul 29, 2010, 12:31:14 AM7/29/10
to python_in...@googlegroups.com

johnvdz

unread,
Aug 2, 2010, 4:05:47 PM8/2/10
to python_in...@googlegroups.com
Hi all,

i have a script that calculates per vertex tangent space and constructs
a matrix. which all works fine but now i'm just looking at trying to get
it to work in a global position.

what is the best way in Api to get the objects Inverse Square matrix or
an object? there seems to be a few options whats the deference


*MPxTransformationMatrix* <cid:part1.01030...@gmail.com> ()

*MPxTransform* <cid:part2.04070...@gmail.com> ()

any guidance would be great

john

Chad Vernon

unread,
Aug 2, 2010, 4:40:22 PM8/2/10
to python_in...@googlegroups.com
You can get matrices with MDagPath::inclusiveMatrix or exclusiveMatrix.  To set a matrix, you can use MFnTransform.  The MPx* classes are proxy classes that you only use when creating a custom object like a node or context.

Chad




Marco D'Ambros

unread,
Aug 2, 2010, 9:07:30 PM8/2/10
to python_in...@googlegroups.com
Yep, I think the better and faster way it's MfnTransform and inclusiveMatrix :)

--------------------------------
Marco D'Ambros
phone : (+61) 0431 830085
mail    : dambro...@gmail.com
wave   : dambro...@googlewave.com




V126

unread,
Mar 3, 2015, 5:30:46 PM3/3/15
to python_in...@googlegroups.com
Hey guys,

I'm a noob, and am trying to understand how to use the inverse matrix better. It's related to this thread so I'm replying here. I've searched through all the documentation and posts and haven't found an answer (that I can fully comprehend) yet.

My previous experience comes from maxscript, so I'll have to use it as pseudocode to illustrate.

I've got three objects with transform nodes: "moon", "earth" and "asteroid1". I want to save the translation and rotation of "moon" relative to "earth" into a variable, so I can snap "asteroid1" to that exact translation and rotation that the moon has, relative to the "earth". I want to save it in a variable so I can use that relative position and rotation in another file that doesn't have the "moon" in it (therefore I can't cheat and just xform "asteroid1" to "moon").

Here's how I did this in maxscript pseudocode:

# Get a transformation matrix of the “moon” to the “earth”.

my_matrix = moon.transform * inverse earth.transform

# Then use that matrix to snap the “asteroid1” to the location I recorded relative to the “earth” in worldspace.

In coordsys world

    (

        asteroid1.transform = my_matrix * earth.transform

    )

In 3DS Max, that would snap "asteroid1" to where "moon" was relative to the "earth". As a bonus, I'd love the option of being able to snap ONLY "asteroid1"'s translation OR ONLY it's rotation if I so choose.

I've tried using maya's xform and getAttr commands. I've also tried some OpenMaya commands suggested by a friend, like .MTransformationMatrix(), and .asMatrixInverse(), but I don't have enough experience to know how to get the result I'm looking for. Usually it comes down to me not knowing how to "multiply" the matrix * the child object's transform node. I'm eager to learn how to use the MfnTransform and inclusiveMatrix, but I don't have a good jumping off point. The simpler solution the better for me.

Any advice would be appreciated!

Thanks



On Monday, August 2, 2010 at 6:07:30 PM UTC-7, kungFu_Teddy wrote:
Yep, I think the better and faster way it's MfnTransform and inclusiveMatrix :)

--------------------------------
Marco D'Ambros
phone : (+61) 0431 830085
mail    : dambro...@gmail.com
wave   : dambro...@googlewave.com



On Tue, Aug 3, 2010 at 6:40 AM, Chad Vernon <chadv...@gmail.com> wrote:
You can get matrices with MDagPath::inclusiveMatrix or exclusiveMatrix.  To set a matrix, you can use MFnTransform.  The MPx* classes are proxy classes that you only use when creating a custom object like a node or context.

Chad
On Mon, Aug 2, 2010 at 1:05 PM, johnvdz <john.va...@gmail.com> wrote:
Hi all,

i have a script that calculates per vertex tangent space and constructs a matrix. which all works fine but now i'm just looking at trying to get it to work in a global position.

what is the best way in Api to get the objects Inverse Square matrix or an object? there seems to be a few options whats the deference


*MPxTransformationMatrix* <cid:part1.010...@gmail.com> ()

*MPxTransform* <cid:part2.040...@gmail.com> ()


any guidance would be great

john

--
http://groups.google.com/group/python_inside_maya

Marcus Ottosson

unread,
Mar 4, 2015, 1:21:35 PM3/4/15
to python_in...@googlegroups.com

Sounds like you’ve got a number of problems here and I’m not sure which ones solves your problem, but I might be able to help you with this.

Usually it comes down to me not knowing how to “multiply” the matrix * the child object’s transform node

In Maya, there’s an output on each transform node that carries it’s matrix; it’s called simply matrix. It’s also got inverseMatrix and worldMatrix which are self-explanatory. You can multiply these with a multMatrix node, that you can create and connect like so:

from maya import cmds

multMatrix = cmds.createNode("multMatrix")

# Connect to multMatrix
cmds.connectAttr("moon.worldMatrix", multMatrix + ".matrixIn[0]")
cmds.connectAttr("earth.worldMatrix", multMatrix + ".matrixIn[1]")

At this point, multMatrix will contain the multiplied matrix.

print cmds.getAttr(multMatrix + ".matrixSum")
# [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]

You can convert the matrix back to translation values using decomposeMatrix, so that you can hook it back up to whichever node you are looking to drive.

As for saving it out, you can export the multMatrix node and import it back in, it will still contain the values, although ideally you’d simply make it procedural and maintain the connections. But I must admit I’m not fully understanding what you’re trying to accomplish. Maybe if you break it down into one question at a time, we could get a little closer to a solution.

Best,
Marcus


--
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/29fe8851-9e8a-49df-afcb-f32cc4b35abf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



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

Reply all
Reply to author
Forward
0 new messages