Created
September 4, 2015 12:16
-
-
Save JokerMartini/f8403c58b01c68877d38 to your computer and use it in GitHub Desktop.
Maxscript: Selects the faces of an editable poly within a given angle threshold from the Z normal. There is a max height parameter which ignores faces lower than the Max Height value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--"Angle Threshold spinner" -- angle beetven face normal and Z-axis | |
--"Max Height" -- select only faces which center position is > Max Height | |
try(DestroyDialog ::bgaRoll)catch() | |
rollout bgaRoll "selectObjTops" | |
( | |
local poGFN = polyop.getFaceNormal, poGFC = polyop.getFaceCenter | |
spinner spn_ang "Angle Threshold:" range:[0,360,5] pos:[5,5] | |
spinner spn_heig "Max Height: " range:[0,360,0] pos:[4,25] | |
button btn "Select T O P S!" width:150 pos:[5,45] | |
fn getDirAngle v1 v2 = (acos(dot (normalize v1) (normalize v2))) | |
fn getTops obj ang: elev: = | |
( | |
local topFaces = #{}, norm = [0,0,1] | |
if isKindOf obj Editable_Mesh do (poGFN = getFaceNormal ; poGFC = meshop.getFaceCenter) | |
for f = 1 to obj.numfaces where getDirAngle norm (poGFN obj f) <= ang do | |
( | |
if abs ((poGFC obj f).z-obj.min.z) >= elev do append topFaces f | |
) ; obj.selectedfaces = topFaces | |
) | |
on btn pressed do | |
( | |
if selection.count > 0 do | |
( | |
for obj in selection where isKindOf obj Editable_Poly or isKindOf obj Editable_Mesh do | |
getTops obj ang:(spn_ang.value) elev:(spn_heig.value) | |
) | |
) | |
) | |
createDialog bgaRoll 160 70 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment