Message 1 of 5
(MEL) getting hard angled cvs ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
{
string $selected[] = `ls -sl`;
string $shapes[];
float $uParam[];
vector $cvNormal[];
string $hardCV[];
for ($curve in $selected)
{
int $CVs =`getAttr ($curve + ".spans")`;
$shapes = `listRelatives -shapes $curve`;
string $nearestInfo = `createNode nearestPointOnCurve`;
connectAttr -force ($shapes[0] + ".worldSpace") ($nearestInfo +".inputCurve");
for ($x = 0; $x < $CVs; $x++)
{
vector $location = `pointPosition ($curve + ".cv[" + $x + "]")`;
setAttr ($nearestInfo + ".inPositionX") ($location.x);
setAttr ($nearestInfo + ".inPositionY") ($location.y) ;
setAttr ($nearestInfo + ".inPositionZ") ($location.z) ;
$uParam[$x] = `getAttr ($nearestInfo + ".parameter")`; //getAttr nearestPointOnCurve1.parameter;
$cvNormal[$x] = `pointOnCurve -pr $uParam[$x] -nn $curve`; //get cv normal vector
//print ($Parameter + "\n");
//print ($cvNormal[$x] + "\n");
}
delete $nearestInfo;
if (`getAttr ($shapes[0] + ".form")` == 0)
{
for ($y = 0; $y < ($CVs - 1); $y++)
{
vector $vec1 = $cvNormal[$y];
vector $vec2 = $cvNormal[($y + 2)];
float $angle[] = `angleBetween -v1 ($vec1.x) ($vec1.y) ($vec1.z) -v2 ($vec2.x) ($vec2.y) ($vec2.z)`;
print ($angle[$y] + "\n");
if (equivalentTol (90.0, $angle[4], 10) == 1){
$hardCV[size($hardCV)] = ($curve + ".cv[" + ($y + 1)+ "]");
}
//print $hardCV[size($hardCV)];
}
}
}
}
this is the code that i came up with. In theory its should give me the hard angled cvs. Not quite sure what i did wrong. Im not getting any useful angles from the angleBetween command.
https://www.artstation.com/kelvintam