# Normal Placement Wo/constraints

**URL:** https://forum.highend3d.com/t/normal-placement-wo-constraints/3598
**Category:** Maya
**Tags:** mel
**Created:** [September 27, 2005, 5:21pm UTC](https://forum.highend3d.com/t/normal-placement-wo-constraints/3598 "2005-09-27T17:21:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![j-christopher](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/j/6a8cbe/32.png) [@j-christopher](https://forum.highend3d.com/u/j-christopher)
#### Post date: [September 27, 2005, 5:21pm UTC](https://forum.highend3d.com/t/normal-placement-wo-constraints/3598/1 "2005-09-27T17:21:52Z")

</div>

Hey guys,   
here's a procedure that I was writing to place one object on to a target object without using constraints because I'd like to write a similar code for Rhino. I'd really appreciate if someone could take a look.

//to excute, select the target obj first and the aggregate last  
// you can use a locater as an aggregate to test.

proc J\_plot2normals(){  
 $startFrame = `curretTime -q`;  
 $surfaces = `ls -sl -dag -s`;  
 $selection = `ls -sl`;  
 $Objtarget = $selection[0];  
 $type = `objectType $surfaces[0]`;  
 $Objaggregate = $selection[1];  
 float $p[3]; float $t[3]; float $bt[3];  
 vector $tan; vector $bitan; vector $norm; vector $v2;

```
	if($type == "nurbsSurface"){
	
int $Uspans = eval("getAttr " + $surfaces[0] + ".spansU");
int $Udegree = eval("getAttr " + $surfaces[0] + ".degreeU");
int $numCVonU = $Uspans + $Udegree;
		
int $Vspans = eval("getAttr " + $surfaces[0] + ".spansV");
int $Vdegree = eval("getAttr " + $surfaces[0] + ".degreeV");
int $numCVonV = $Vspans + $Vdegree;

		for($u=0;$u< $numCVonU;$u++){
			for($v=0;$v< $numCVonV;$v++){
			
				//watch plot
		int $endFrame = $startFrame++;
		currentTime $endFrame;

				//do calculation of cross product based on U and V tangents
		$UtanObjD = `pointOnSurface -ch on -u $u -v $v -tu $Objtarget`;
		$VtanObjD = `pointOnSurface -ch on -u $u -v $v -tv $Objtarget`;
		vector $tan = `getAttr($UtanObjD + ".position")`;
		vector $bitan = `getAttr($VtanObjD + ".position")`;
		$tan = `unit $v1`;
		$bitan = `unit $v2`;
		$crossObjD = cross ($tan, $bitan);
		$normObjD = `unit $crossObjD`; //normalized vector (result of cross produce tanU & tanV)
		print ($UtanObjD +"\n"+ $tan +"\n"+ $VtanObjD +"\n"+ $bitan +"\n"+ $crossObjD +"\n"+ $normObjD +"\n");
				//do placement
		select -r $Objaggregate; // need put pivot at the cv[0][0] position of the object
		xform -ws -t ($normObjD.x) ($normObjD.x) ($normObjD.x);
		}
	}
}
```

}  
//J\_plot2normals();

> > The problem I think is that the placement does not properly align or place the objects correctly, I think the math is okay although I'd rather do this as a matrix in the future when I learn how. I was thinking the point queries are returned in object space an not world??\<\<  
> > J.christopher@xephaya.com
