<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Calling an image in MEL scripting in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/calling-an-image-in-mel-scripting/m-p/7087219#M11912</link>
    <description>&lt;P&gt;Interesting... I'm also on a Mac and when I substitute my own file location for yours the script runs with no message and correctly shows the texture on the plane. A couple of things to check:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Do you have the correct capitalization for the file path and file name? Some Mac configurations can be finicky about that.&lt;/LI&gt;
&lt;LI&gt;When you get the error message, does the name of the file it cannot find match the name you set in $path?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 May 2017 15:49:40 GMT</pubDate>
    <dc:creator>kevin.picott</dc:creator>
    <dc:date>2017-05-16T15:49:40Z</dc:date>
    <item>
      <title>Calling an image in MEL scripting</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/calling-an-image-in-mel-scripting/m-p/7086979#M11909</link>
      <description>&lt;P&gt;I've recently started playing around with the MEL script capabilities in Maya, and have come across a small issue. The tutorial I have been following is out a book — Parametric Building Design With Maya.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;He is importing an image, which he then maps the placement of the "Buildings" on a plane. That being said, I cannot link the image I have because I cannot locate the file itself.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;string $filenode = `createNode file`;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;string $shader = `createNode lambert`;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;string $path = "C:/TM/topo-house16.TIF";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the first three lines of code. However the $path variable is using the "C" drive, for a Windows Machine. I own a Mac.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So essentially, it should link in a similar manner (or I think so).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On a mac it should look something like so: &lt;FONT face="courier new,courier"&gt;string $path ="/Users/username/Desktop/topo-house16.TIF";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script runs fine, but in the console, it is logged that the file could not be found. Just to make sure, I executed the same file route on my mac with the "Goto folder" window. (Command + Shift + G). Typed in the same&amp;nbsp;&lt;/P&gt;&lt;P&gt;Typed in the same file route, and located the image I was looking for. So it verified&amp;nbsp;that the route was working, but from Maya, I could not load the image.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to MEL and Python but have been modeling/animating with Maya for 4 years now. This is not my first time using a scripting language, however, unless I have to grab assets from specific folders within the MEL, I'm not sure where to go from here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 14:45:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/calling-an-image-in-mel-scripting/m-p/7086979#M11909</guid>
      <dc:creator>lucascarci17</dc:creator>
      <dc:date>2017-05-16T14:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calling an image in MEL scripting</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/calling-an-image-in-mel-scripting/m-p/7087064#M11910</link>
      <description>&lt;P&gt;What you are doing seems perfectly reasonable. What is the line of MEL that is actually trying to access the file?&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 15:06:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/calling-an-image-in-mel-scripting/m-p/7087064#M11910</guid>
      <dc:creator>kevin.picott</dc:creator>
      <dc:date>2017-05-16T15:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calling an image in MEL scripting</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/calling-an-image-in-mel-scripting/m-p/7087094#M11911</link>
      <description>&lt;P&gt;This is the block of script that has anything the do with the actual&amp;nbsp;image itself:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;// __________ IMAGE MAPPING _________________________________&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;string $filenode = `createNode file`;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;string $shader = `createNode lambert`;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;string $path = "C:/TM/topo-house16.TIF";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;// connect the nodes&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;connectAttr ($filenode + ".outColor") ($shader + ".color");&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;// insert the image path in the file node&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;string $map = $path;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;setAttr -type "string" ($filenode + ".fileTextureName") $map;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;// assign the shader to an object&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;string $object[] = `nurbsPlane -ax 0 1 0 -w 100 -lr 1 -name "nurbsPlane1"`;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;//string $object[] = `sphere -name "nurbsPlane1"`;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;// __________________________________________________________&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="andale mono,times"&gt;And then the rest of the script determines where My "buildings" are being placed:&lt;/FONT&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;select -r $object[0];&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;hyperShade -assign $shader;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;int $u, $v, &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;$nu = 50, $nv = 50; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;float $minU = 0, $minV = 0, &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;$maxU = 1, $maxV = 1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;float $rgb[] = `colorAtPoint -o RGBA -su $nu -sv $nv -mu $minU -mv $minV &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;-xu $maxU -xv $maxV $filenode`;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;float $deltaU = ($maxU - $minU)/($nu - 1); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;float $deltaV = ($maxV - $minV)/($nv - 1); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;float $currU, $currV;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;int $index = 0;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;$currU = $minU;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;for($n = 0; $n &amp;lt; $nu; $n++)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;$currU += $deltaU;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;$currV = $minV;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;for($i = 0; $i &amp;lt; $nv; $i++)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;float $r = $rgb[$index];&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;float $g = $rgb[$index + 1];&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;float $b = $rgb[$index + 2];&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;float $a = $rgb[$index + 3];&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;print($r + " " + $g + " " + $b + " " + $a + "\n");&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;if( ($r + $g + $b) &amp;lt; 2)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;float $p[] = `pointOnSurface &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;-u $currU&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;-v $currV&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;$object[0]`;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;string $listA[]={"building01", "building02", "building03"};&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;string $listB[]={"building04", "building05", "building06"};&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;string $listC[]={"building01", "building02", "building03", "building04", "building05", "building06"};&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;//-----------Red value. commercial&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;if( $r &amp;gt; 0.8 )&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;int $number = rand(0,3);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;string $building = $listA[$number];&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;select $building;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;instance $building;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;scale -r (rand(1, 2)) (rand(2, 4)) 1;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;move $p[0] $p[1] $p[2];&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;rotate -r 0 ((-360)*$a) 0;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;int $rottime = rand(0,4);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;rotate -r 0 (90*$rottime) 0;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;//-----------Green value. residential&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;if($g &amp;gt; 0.8)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;int $number = rand(0,3);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;string $building = $listB[$number];&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;select $building;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;instance $building;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;scale -r (rand(1, 3)) (rand(1, 2)) (rand(1, 2));&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;move $p[0] $p[1] $p[2];&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;rotate -r 0 ((-360)*$a) 0;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;int $rottime = rand(0,4);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;rotate -r 0 (90*$rottime) 0;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;} &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;$index += 4;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;$currV += $deltaV;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 15:14:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/calling-an-image-in-mel-scripting/m-p/7087094#M11911</guid>
      <dc:creator>lucascarci17</dc:creator>
      <dc:date>2017-05-16T15:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calling an image in MEL scripting</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/calling-an-image-in-mel-scripting/m-p/7087219#M11912</link>
      <description>&lt;P&gt;Interesting... I'm also on a Mac and when I substitute my own file location for yours the script runs with no message and correctly shows the texture on the plane. A couple of things to check:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Do you have the correct capitalization for the file path and file name? Some Mac configurations can be finicky about that.&lt;/LI&gt;
&lt;LI&gt;When you get the error message, does the name of the file it cannot find match the name you set in $path?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 15:49:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/calling-an-image-in-mel-scripting/m-p/7087219#M11912</guid>
      <dc:creator>kevin.picott</dc:creator>
      <dc:date>2017-05-16T15:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calling an image in MEL scripting</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/calling-an-image-in-mel-scripting/m-p/7087245#M11913</link>
      <description>&lt;P&gt;Ah! This is something I overlooked which I never thought of.&amp;nbsp;I thought the capitalization in my file was correct, as it was a simple mistake and I had been looking at it for too long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you! the script Has worked!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 15:56:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/calling-an-image-in-mel-scripting/m-p/7087245#M11913</guid>
      <dc:creator>lucascarci17</dc:creator>
      <dc:date>2017-05-16T15:56:26Z</dc:date>
    </item>
  </channel>
</rss>

