SCRIPT: Locator driven projection setup

Forums: SCRIPT: Locator driven projection setup
Sub forum for help and tutorials.

Moderator: JimStar

SCRIPT: Locator driven projection setup

Postby Renart » Tue Jan 17, 2017 2:42 pm

Renart Tue Jan 17, 2017 2:42 pm
Hi,

I don't really know how to call this but this script basically create and connect a box projection node, driven by a locator, to a the selected texture.
It gives a more visual and easy representation of the projection. Box in that case but you can change the type.

For instanced I copied the script few times and created shelf icon for the other types.

Just select the texture node and run this script ( Python)

Code: Select all
    import maya.cmds as cmds
    #Octane_Projection_Setup
    #Select the texture node to project and run the script. It will create a locator linked to the projection to make the transform more easy to manipulate.
    #You can change the projection type by changing the octaneBoxProjection with what you need

    #Nodes creations
    TextureNode = cmds.ls(sl=1)
    NameSuffix = TextureNode[0]
    ProjectionNode = cmds.createNode('octaneBoxProjection', n='octaneBoxProjection_'+NameSuffix)
    TransformNode = cmds.createNode('octaneTransform3D', n='octaneTransform3D_'+NameSuffix)
    ConversionNode = cmds.createNode('unitConversion', n='unitConversion_'+NameSuffix)
    LocatorNode = cmds.spaceLocator(n='Locator_'+NameSuffix)


    #Connections
    cmds.connectAttr('Locator_'+NameSuffix+'.rotate','unitConversion_'+NameSuffix+'.input')
    cmds.connectAttr('unitConversion_'+NameSuffix+'.output','octaneTransform3D_'+NameSuffix+'.Rotation')
    cmds.connectAttr('Locator_'+NameSuffix+'.scale','octaneTransform3D_'+NameSuffix+'.Scale')
    cmds.connectAttr('Locator_'+NameSuffix+'.translate','octaneTransform3D_'+NameSuffix+'.Translation')
    cmds.connectAttr('octaneTransform3D_'+NameSuffix+'.outTransform','octaneBoxProjection_'+NameSuffix+'.Transform')
    cmds.connectAttr('octaneBoxProjection_'+NameSuffix+'.outProj',NameSuffix+'.Projection')

    #SetAttributes
    cmds.setAttr('unitConversion_'+NameSuffix+'.conversionFactor',57.296)


Don't hesitate to improve it if you want! This is quick and bad scripting, I don't have the skill for that :)

Cheers!
Renart
Licensed Customer
Licensed Customer
 
Posts: 70
Joined: Mon Jul 04, 2016 8:21 pm

Re: SCRIPT: Locator driven projection setup

Postby Jolbertoquini » Wed Jan 18, 2017 4:28 pm

Jolbertoquini Wed Jan 18, 2017 4:28 pm
Renart wrote:Hi,

I don't really know how to call this but this script basically create and connect a box projection node, driven by a locator, to a the selected texture.
It gives a more visual and easy representation of the projection. Box in that case but you can change the type.

For instanced I copied the script few times and created shelf icon for the other types.

Just select the texture node and run this script ( Python)

Code: Select all
    import maya.cmds as cmds
    #Octane_Projection_Setup
    #Select the texture node to project and run the script. It will create a locator linked to the projection to make the transform more easy to manipulate.
    #You can change the projection type by changing the octaneBoxProjection with what you need

    #Nodes creations
    TextureNode = cmds.ls(sl=1)
    NameSuffix = TextureNode[0]
    ProjectionNode = cmds.createNode('octaneBoxProjection', n='octaneBoxProjection_'+NameSuffix)
    TransformNode = cmds.createNode('octaneTransform3D', n='octaneTransform3D_'+NameSuffix)
    ConversionNode = cmds.createNode('unitConversion', n='unitConversion_'+NameSuffix)
    LocatorNode = cmds.spaceLocator(n='Locator_'+NameSuffix)


    #Connections
    cmds.connectAttr('Locator_'+NameSuffix+'.rotate','unitConversion_'+NameSuffix+'.input')
    cmds.connectAttr('unitConversion_'+NameSuffix+'.output','octaneTransform3D_'+NameSuffix+'.Rotation')
    cmds.connectAttr('Locator_'+NameSuffix+'.scale','octaneTransform3D_'+NameSuffix+'.Scale')
    cmds.connectAttr('Locator_'+NameSuffix+'.translate','octaneTransform3D_'+NameSuffix+'.Translation')
    cmds.connectAttr('octaneTransform3D_'+NameSuffix+'.outTransform','octaneBoxProjection_'+NameSuffix+'.Transform')
    cmds.connectAttr('octaneBoxProjection_'+NameSuffix+'.outProj',NameSuffix+'.Projection')

    #SetAttributes
    cmds.setAttr('unitConversion_'+NameSuffix+'.conversionFactor',57.296)


Don't hesitate to improve it if you want! This is quick and bad scripting, I don't have the skill for that :)

Cheers!


Hi Renart,

I was looking at you script and doesn't work on Maya 2017 and is plenty errors I think Calus script with the camera was much better and was the same thing, also the script has a support the about world scale, I think if we need a script to save time should be just a extra option as Locator or Camera...
But at same time is a bug on maya should be done the transform automatic and we could connect straight to maya without problems..

Best,
JO
Octane Render for Maya.
https://vimeo.com/jocg/videos
https://www.linkedin.com/in/jocgtd
http://www.hmxmedia.com/
--------------------
Join MAYA OCTANE USERS Skype discussion here :
https://join.skype.com/LXEQaqqfN15w
User avatar
Jolbertoquini
Licensed Customer
Licensed Customer
 
Posts: 1067
Joined: Sun Aug 31, 2014 7:08 am
Location: London

Return to Help / Tutorials


Who is online

Users browsing this forum: No registered users and 1 guest

Thu May 09, 2024 4:46 am [ UTC ]