# Assigne Texture To Polyplane

**URL:** https://forum.highend3d.com/t/assigne-texture-to-polyplane/48794
**Category:** Maya
**Tags:** python
**Created:** [January 3, 2009, 4:24pm UTC](https://forum.highend3d.com/t/assigne-texture-to-polyplane/48794 "2009-01-03T16:24:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![seppl123456789](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@seppl123456789](https://forum.highend3d.com/u/seppl123456789)
#### Post date: [January 3, 2009, 4:24pm UTC](https://forum.highend3d.com/t/assigne-texture-to-polyplane/48794/1 "2009-01-03T16:24:38Z")

</div>

hello everyone,

i have a small problem ![]()  
i need to assign a texture on a polyplane in python.

here is the code of the functions:

def createMaterial( name, color, type ):  
 cmds.sets( renderable=True, noSurfaceShader=True, empty=True, name=name + 'SG' )  
 cmds.shadingNode( type, asShader=True, name=name )  
 cmds.setAttr( name+".color", color[0], color[1], color[2], type='double3')  
 cmds.connectAttr(name+".outColor", name+"SG.surfaceShader")

def assignMaterial (name, object):  
 cmds.sets(object, edit=True, forceElement=name+'SG')

def assignNewMaterial( name, color, type, object):  
 createMaterial (name, color, type)  
 assignMaterial (name, object)

assignNewMaterial( 'sphereShader' + str(n+1), (array\_Structure\_cloud[n][3] \* 0.00392, array\_Structure\_cloud[n][4] \* 0.00392, array\_Structure\_cloud[n][5] \* 0.00392), 'blinn', 'sphere' + str(n+1) )

this part of the script creates a cuple of new materials for some spheres and change the color of them.  
that works fine.  
but i dont know how to assigne a new texture.

i tried this:

cmds.createNode('file',n='file1')  
cmds.setAttr( 'file1.ftn', 'C:\Users\sepp\Desktop/test.JPG',type='string' )  
s = cmds.getAttr('file1.ftn')  
# Result: $TMPDIR/smile.gif #  
s = cmds.getAttr('file1.ftn',x=True)  
# Result: /var/tmp/smile.gif #  
cmds.connectAttr('file1')

the result is the texture in the attribute editor but with no assignment to the material of the plane.

any ideas?

merci and sunny greetings, sepp
