# Printing A Face Normal To A File

**URL:** https://forum.highend3d.com/t/printing-a-face-normal-to-a-file/3085
**Category:** Maya
**Tags:** mel
**Created:** [May 18, 2006, 8:31pm UTC](https://forum.highend3d.com/t/printing-a-face-normal-to-a-file/3085 "2006-05-18T20:31:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kmcall2](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/k/898d66/32.png) [@kmcall2](https://forum.highend3d.com/u/kmcall2)
#### Post date: [May 18, 2006, 8:31pm UTC](https://forum.highend3d.com/t/printing-a-face-normal-to-a-file/3085/1 "2006-05-18T20:31:43Z")

</div>

Hello world,

I am setting a face to have a face normal,

polySetToFaceNormal;

I am trying to query a face to get the face normal from "polyInfo -fn polySurface12.f[0]"

This returns : "// Result: FACE\_NORMAL 0: -0.688109 0.000000 -0.725608 //

so far so good.

but when I try to put this result into something like

$zxc = `polyInfo -fn polySurface12.f[0]`;

then I get this

// Error: Cannot convert data of type string[] to type float. //

I am surely doing something wrong.

can anyone help.

thank you  
ken

---

<div class="post-metadata">

### Author: ![segmoria](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/s/bb73d2/32.png) [@segmoria](https://forum.highend3d.com/u/segmoria)
#### Post date: [May 18, 2006, 10:12pm UTC](https://forum.highend3d.com/t/printing-a-face-normal-to-a-file/3085/2 "2006-05-18T22:12:58Z")

</div>

The error comes up becauce polyInfo returns a string, not a float, so you should instead use:

CODE  
string $zxc[] = `polyInfo -fn polySurface12.f[0]`;

And because polyInfo returns a string and not a vector directly, you will have to tokenize that string to remove all the unwanted characters.   
You can use Bryan Ewert's function to do this:

CODE  
proc vector translatePolyInfoNormal( string $pin )  
{  
&nbsp;&nbsp;vector $normal;  
&nbsp;&nbsp;float $x;  
&nbsp;&nbsp;float $y;  
&nbsp;&nbsp;float $z;

&nbsp;&nbsp;string $tokens[];  
&nbsp;&nbsp;int $numTokens = `tokenize $pin " " $tokens`;

&nbsp;&nbsp;// Make sure we're looking at polyInfo data:  
&nbsp;&nbsp;if ( ( $numTokens \> 3 ) && ( $tokens[0] == "FACE\_NORMAL" ) )  
&nbsp;&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;// Maya performs data-type conversion here.  
&nbsp;&nbsp;&nbsp;&nbsp;$x = ($tokens[$numTokens-3]);  
&nbsp;&nbsp;&nbsp;&nbsp;$y = ($tokens[$numTokens-2]);  
&nbsp;&nbsp;&nbsp;&nbsp;$z = ($tokens[$numTokens-1]);

&nbsp;&nbsp;&nbsp;&nbsp;$normal = \<\>;

&nbsp;&nbsp;&nbsp;&nbsp;// Normalize it.  
&nbsp;&nbsp;&nbsp;&nbsp;$normal = `unit $normal`;  
&nbsp;&nbsp;}

&nbsp;&nbsp;// Return it.  
&nbsp;&nbsp;return $normal;  
}

For more info: [http://www.ewertb.com/maya/mel/mel.php?howto=05](http://www.ewertb.com/maya/mel/mel.php?howto=05)

---

<div class="post-metadata">

### Author: ![kmcall2](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/k/898d66/32.png) [@kmcall2](https://forum.highend3d.com/u/kmcall2)
#### Post date: [May 19, 2006, 12:33am UTC](https://forum.highend3d.com/t/printing-a-face-normal-to-a-file/3085/3 "2006-05-19T00:33:28Z")

</div>

Thank you Thank you Thank you,

This example worked out great so far.

I am working out the fact that every once and a while I will get an errant value.

but that is for another day.

again thank you very much.

-ken
