Adverti horiz upsell

V-Ray for Maya NURBs control 1.0.0 for Maya (maya script)

very simple script to hook up editable, visible (in the spreadsheet & channel box) attributes to the v-ray attributes created on NURBs surfaces.

License
Button download
322 Downloads

Compatibility

  • 2011, 2010, 9.x, 2009, 2008, 8.x, 7.x, 6.x, 5.x, 4.x, 3.x, 2.x, 1.x

Operating Systems

  • Irix
  • Linux
  • Mac
  • Solaris
  • Windows

History

Created:09/17/2010
Last Modified:09/17/2010
File Size: 1.74 KB

Keywords

vray, rendering, maya, vr

I suck at scripting, but I thought I'd upload this for people who are lazy as me.

When you are rendering NURBs surfaces in V-Ray for Maya, you can create custom NURBs controls on the shape nodes of your objects (attributes->v-ray->NURBs attributes).  These attributes are similar to the Approximation Editor in Mental Ray, insofar as they let you change the quality / tesselation of your surface at render time on a per-surface basis.

Unfortunately, while these custom attributes are queryable, keyable, and behave as normal in the AE and with MEL, and appear to be normal Maya attributes, there is a catch:  They are not visible in the channel box or attribute spread sheet, and I haven't found a way to make them so (I think this might be because they are created via a C++ command from the V-ray plug-in, but it's all Greek to me).  For the record, if anyone finds a way to make them visible in any part of the UI besides the AE, please let me know so I can delete this post and do things the right way.

In the meantime, I wrote this script to assign and control these custom V-Ray NURBs attributes on multiple objects at once.  It's a time saver for working with V-Ray on multiple NURBs objects (ie imported CAD files, industrial design stuff, cell phones, etc).

What this little piece o' magic does:

1-Creates the custom V-Ray attributes on any selected nodes if you haven't already created them via the plugin (attributes->v-ray->NURBs attributes)
2-Creates visible (in channel box, attribute spreadsheet, etc) attributes of the same type, and hooks them up to the V-Ray attributes.
3-Sets the visible attributes to V-Ray's default values (only if there were no connections to begin with, so as to prevent overwriting whatever adjustments you might have made in a previous usage of the script.  If you disconnect these attributes on any of the nodes and run the script again, it will reconnect and re-set them to the default values.  Comment out the "setAttr" part of the script to avoid this).

//
//V-Ray for Maya NURBs control 1.0
//Matthew Foglia
//m.foglia@gmail.com
//www.dontmindifidoodle.com
//
//To use:
//Select your objects from the viewport, press down to select the

//shape nodes (or add it into the string declaration in the script), and run:

//or source "MFVRayNurbs1.0.mel"

//

//The author is not liable for blowing up your computer or any incidental catasrophies from using this script.

//

string $surfaces[]=`ls -sl`;

string $surface;

for ($surface in $surfaces)

{
if( !attributeExists( "vrayAsStaticGeom", $surface ) )
vrayAddAttr $surface vrayAsStaticGeom;

if( !attributeExists( "vrayFlatnessCoef", $surface ) )
vrayAddAttr $surface vrayFlatnessCoef;

if( !attributeExists( "vrayMaxSubdivDepth", $surface ) )
vrayAddAttr $surface vrayMaxSubdivDepth;

if( !attributeExists( "MFVR_STATIC", $surface ) )
addAttr -at long -k 1 -h 0 -r 1 -w 1 -longName MFVR_STATIC $surface;

if( !attributeExists( "MFVR_CRVPRECISION", $surface ) )
addAttr -at "float" -k 1 -h 0 -r 1 -w 1 -longName MFVR_CRVPRECISION $surface;

if( !attributeExists( "MFVR_SUBDIVDEPTH", $surface ) )
addAttr -at long -k 1 -h 0 -r 1 -w 1 -longName MFVR_SUBDIVDEPTH $surface;

if( !`isConnected ($surface+".MFVR_STATIC") ($surface+".vrayAsStaticGeom")`)
{
connectAttr ($surface+".MFVR_STATIC") ($surface+".vrayAsStaticGeom");
setAttr ($surface+".MFVR_STATIC") 1; //V-Ray's default value for this is 1
}
if( !`isConnected ($surface+".MFVR_CRVPRECISION") ($surface+".vrayFlatnessCoef")`)
{
connectAttr ($surface+".MFVR_CRVPRECISION") ($surface+".vrayFlatnessCoef");
setAttr ($surface+".MFVR_CRVPRECISION") 0.2; //V-Ray's default value for this is .2
}
if( !`isConnected ($surface+".MFVR_SUBDIVDEPTH") ($surface+".vrayMaxSubdivDepth")`)
{
connectAttr ($surface+".MFVR_SUBDIVDEPTH") ($surface+".vrayMaxSubdivDepth");
setAttr ($surface+".MFVR_SUBDIVDEPTH") 22; //V-Ray's default value for this is 22
}
};



Please use the Bug System to report any bugs.
Please use the Feature Requests to give me ideas.
Please use the Support Forum if you have any questions or problems.
Please rate and review in the Review section.

People who favorited this item:

  • xtvjxk
    xtvjxk
  • DangerWeenie
    DangerWeenie
  • zitro3d
    zitro3d
  • manuel arias
    manuel arias
  • vivek
    vivek
  • Changbae Kang
    Changbae Kang