(MEL)Find the Correct Offset amount for polyExtrudeFacet?

(MEL)Find the Correct Offset amount for polyExtrudeFacet?

absoluteKelvin
Collaborator Collaborator
1,259 Views
6 Replies
Message 1 of 7

(MEL)Find the Correct Offset amount for polyExtrudeFacet?

absoluteKelvin
Collaborator
Collaborator

Im currently trying find a way to obtain the correct amount of Offset value for poly Extrude base on percentage. If I wanted the polyExtrudeFacet to always extrude at 80% offset. How would I achieve that? Since setting it at 0.2 offset varies for each mesh depending on the size of the object. I having difficulty determining the correlation of the bounding box size to the offset value.

https://www.artstation.com/kelvintam
0 Likes
1,260 Views
6 Replies
Replies (6)
Message 2 of 7

mcw0
Advisor
Advisor

What does 80% mean?  80% of what?

0 Likes
Message 3 of 7

absoluteKelvin
Collaborator
Collaborator

imagine 100% is the extrude towards the center where it collapse into itself. I actually meant 20% when I said 80%, sorry.

 

Anyhow I think I came up with a method, not the most accurate but it kinda gets the work done.

 

global proc float findOffsetAmt()
{
    string $faces[]= `ls -sl -fl`;
    string $initBorderVtx[] = `polyListComponentConversion -fromFace -toVertex -border $faces`;
    string $flattenVtxList[] = `ls -fl $initBorderVtx`;
    vector $cPiv = `manipMoveContext -q  -position "Move"`;
    vector $pntPos[];
    vector $result[];
    float $sortedList[];
    float $distTmp[];
    int $counter = 0;
    for ($vtx in $flattenVtxList){
        $pntPos[$counter] = `pointPosition $vtx`;
        $distTmp[$counter] = `mag($pntPos[$counter] - $cPiv)`;
        $counter++;
    }
    $sortedList = `sort($distTmp)`; //sort the list from smallest to largest
    //print $sortedList;
    float $smlDist = $sortedList[0];
    float $offsetAmt = $smlDist * 0.2;
    return $offsetAmt;
    //print $smlDist;
}

What I did was compare the distance between the closest border vertex to the component pivot. Then use that as a guide for 100% extrude offset, and Multiply by 0.2 to get the offset amount.

 

I would be happy to hear if there's a more elegant and accurate method.

https://www.artstation.com/kelvintam
0 Likes
Message 4 of 7

mcw0
Advisor
Advisor

Just curious how different your result is compared to just scaling the geo by 1.2.  On a very organic shape,  I would venture it would be quite different.

0 Likes
Message 5 of 7

absoluteKelvin
Collaborator
Collaborator

probably would be different. This a partial code for this tool im writing that require auto PolyExtrude offset

 

https://www.artstation.com/kelvintam
0 Likes
Message 6 of 7

mcw0
Advisor
Advisor

That's very cool.  Have you thought of subdividing your original face selection and randomizing the faces along the edge to get an organic shape?  But very cool.  I hope you don't mind my stealing this approach in the future. 🙂

0 Likes
Message 7 of 7

absoluteKelvin
Collaborator
Collaborator

Thanks. I plan to improve the Surrounding part more irregular. I don't mind you borrowing from this idea😉.

https://www.artstation.com/kelvintam
0 Likes