Invalid linear unit

83 views
Skip to first unread message

mikael persson

unread,
Aug 22, 2017, 4:40:14 AM8/22/17
to maya...@googlegroups.com
Hello group,
I'm normally far away from mel scripting, but I decided to try and create a small tool to help me. My google fu has failed sadly so I hope you can answer what I imagine is something extremely basic.

I want to create some objects at the position of my current selected object. Like this:

$selected = `ls -selection` ;
float $worldPos[] = `xform -q -ws -t $selected[0]` ;
sphere -p ( $worldPos[0]+ " " + $worldPos[1]+ " " + $worldPos[2] ) -ax 0 1 0 -ssw 0 -esw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -name ( $selected[0] + "_goalSphere" ) -ch 1;objectMoveCommand;

But maya gives me, invalid linear unit! Which made me wonder if you weren't allowed to use array floats as coordinates? So I tried this:

float $worldPos[] = `xform -q -ws -t $selected[0]` ;
float $worldX = $worldPos[0] ;
float $worldY = $worldPos[1] ;
float $worldZ = $worldPos[2] ;
sphere -p ( $worldX + " " + $worldY + " " + $worldZ ) -ax 0 1 0 -ssw 0 -esw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -name ( $selected[0] + "_goalSphere" ) -ch 1;objectMoveCommand;

Ugly, but hey I solved it I thought. But no! Still I'm getting "invalid linear unit". Why won't the dear little maya take my numbers?

Mikael


mikael persson

unread,
Aug 22, 2017, 4:54:01 AM8/22/17
to maya...@googlegroups.com
et voila!
it should read: $worldPos[0] $worldPos[1] $worldPos[2]
It's hard getting used to where all these separators should be and shouldn't be...
Reply all
Reply to author
Forward
0 new messages