NaN
Some operations of floating-point arithmetic are invalid, such as taking the square root of a negative number. The act of reaching an invalid result is called a floating-point exception. An exceptional result is represented by a special code called a NaN, for "Not a Number". All NaNs in IEEE 754-1985 have this format:
I haven't seen this one in quite a while, but just got bit by it.. hard. The issue crops up when Maya has a division by zero issue, or something similar that results in an infinitesimally small or NAN number. It used to happen a lot with uvs .. especially with uvs coming from zBrush, as zBrush, like the honey badger, didn't care. But it would mess up Maya read on open, and often would end up in an open file, with seemingly nothing in it but the transform nodes.
You would think, what do I care. Fubar uvs are not my problem, and I can make new ones anyway.. but Maya, says, wait I don't know what NAN is and basically stops trying, and just errors out the rest of your scene.
This new issue seems to be hard to track down, but easy to accidentally do, and that's when hit f to frame the camera on a selection. For some reason it will put NAN into all the translate channels of the camera, and also in the center of interest (which is the biggest issue) , and using [ and ] to try and go back to previous views. doesn't work.. huh,
To fix this you want to do a couple things.
First is to reset the TRS of the camera, so select it, and run Modify -> reset transforms.
next in the view, go to view -> default View
But really, I'm more interested in how it happens, and how to fix it !
the nice thing is.. it looks like this issue is fixed in 2018.4
but until you get updated.. here is some mel code you can run in your scene to reset you camera.. i added a small part to reset pan/zoom as well
I put this on my hotbox so I can quickly access it:
________________________________________________________________
global proc resetCamera()
{
string $panel=`getPanel -wf`; if ($panel == "StereoPanel"){$panel = "StereoPanelEditor";}
string $camera = `modelEditor -q -cam $panel`;
string $chans[] = {"tx","ty","tz","rx","ry","rz"};
for ($chan in $chans)
{
catchQuiet(`setAttr ($camera + "." + $chan) 0`);
}
string $chans[] = {"sx","sy","sz"};
for ($chan in $chans)
{
catchQuiet(`setAttr ($camera + "." + $chan) 1`);
}
viewSet -animate 0 -home $camera;
string $camShape[] = `listRelatives -c -s $camera`;
setAttr ($camShape[0] + ".horizontalPan" ) 0 ;
setAttr ($camShape[0] + ".verticalPan" ) 0 ;
setAttr ($camShape[0] + ".zoom") 1;
}
Thursday, September 20, 2018
Tuesday, September 18, 2018
xray selected
Just passing thru an old script
// xraySelected.mel
// isolated by steve Mann
global proc xraySelectedObj()
{
// get selected shape nodes
string $sel[] = `ls -sl -dag -s`;
for( $each in $sel )
{
if (`getAttr ($each + ".intermediateObject")` == 0)
{
int $xState[] = `displaySurface -q -xRay $each`;
displaySurface -xRay ( !$xState[0] ) $each;
}
}
}
// xraySelected.mel
// isolated by steve Mann
global proc xraySelectedObj()
{
// get selected shape nodes
string $sel[] = `ls -sl -dag -s`;
for( $each in $sel )
{
if (`getAttr ($each + ".intermediateObject")` == 0)
{
int $xState[] = `displaySurface -q -xRay $each`;
displaySurface -xRay ( !$xState[0] ) $each;
}
}
}
Thursday, September 13, 2018
Handle your instances
Thinking about controlling python classes and instances in Maya . As basically , every 'bit' you create, adds to the amount of memory Maya is taking up.
So in doing a little research , stumbled upon del() globals(), and locals()
del( ' name of instance') will remove the object from memory... NICE!
globals() lists all the instances in memory of your Maya session, notice that it's not just classes and procedures, but also any random variables you( or a script that was run) created. ie: if you've import maya.cmds as mc it will show up , but also if you've run a sel = cmds.ls(sl=True), that will also show up..
locals() scope of local variables... ( as above )
So in looking for your errant variables, it becomes even more important, NOT to have them, but also to name them something that not only doesn't overlap with existing variables.. ( as mel won't let you, python you can redeclare f***All ) , but also to name them with a unique signifier.. I've started using sm for mine.. which makes things fun ,, like, my sm_rigging_tools gets imported as smrt. ahh.. how cute. , but my matrix math is sort of ugly smmm .
in any case I thought I'd try and be more proactive, so I can do things like search for only my instances.. We'll see how it all works out.
glist = globals()
for g in glist:
if g.startswith("sm"):
print g
In mel you can list all gloabl variables using env, but , since variables written into the script editor, unless scoped, are global, you want to be very careful.
And also, just like a mel variable cannot be redefined.. it also appears that it cannot be removed either.
{
string $gList[] = `env`;
$glist = `sort $gList`;
for ($g in $gList)
print ($g + "\n");
}
but realistically, it probably doesn't hurt to scope python in the script editor as well
-=s
So in doing a little research , stumbled upon del() globals(), and locals()
del( ' name of instance') will remove the object from memory... NICE!
globals() lists all the instances in memory of your Maya session, notice that it's not just classes and procedures, but also any random variables you( or a script that was run) created. ie: if you've import maya.cmds as mc it will show up , but also if you've run a sel = cmds.ls(sl=True), that will also show up..
locals() scope of local variables... ( as above )
So in looking for your errant variables, it becomes even more important, NOT to have them, but also to name them something that not only doesn't overlap with existing variables.. ( as mel won't let you, python you can redeclare f***All ) , but also to name them with a unique signifier.. I've started using sm for mine.. which makes things fun ,, like, my sm_rigging_tools gets imported as smrt. ahh.. how cute. , but my matrix math is sort of ugly smmm .
in any case I thought I'd try and be more proactive, so I can do things like search for only my instances.. We'll see how it all works out.
glist = globals()
for g in glist:
if g.startswith("sm"):
print g
In mel you can list all gloabl variables using env, but , since variables written into the script editor, unless scoped, are global, you want to be very careful.
And also, just like a mel variable cannot be redefined.. it also appears that it cannot be removed either.
string $gList[] = `env`;
$glist = `sort $gList`;
for ($g in $gList)
print ($g + "\n");
}
but realistically, it probably doesn't hurt to scope python in the script editor as well
-=s
Subscribe to:
Posts (Atom)