max 关于面数的脚本,这个在帮助里面还有很多的茶壶什么的 还有面数显示颜色什么的, 有需要时 学习下。

(


global
FaceAreaChecker


struct
FaceAreaCheckerStruct


(


FaceAreaThresholdMin = 1,


FaceAreaThresholdMax = 10,


FaceAreaMode = 1,


faceAreaDialog = undefined,


InteractiveUpdates = true,


iniFileName = (getDir #plugcfg +"\\FaceAreaXViewChecker.ini"),


resultColors = #(green, blue+green*0.5, red+yellow*0.5, blue,
yellow, red),


 


fn
geomCheck theTime theNode theResults =


(


local
theCount =
case
classof theNode
of


(


Editable_Poly: getNumFaces theNode


Editable_Mesh: theNode.numfaces


)


local
theAreaMethod =
case
classof theNode
of


(


Editable_Poly: polyOp.getFaceArea


Editable_Mesh: meshOp.getFaceArea


)


 


for f = 1
to theCount do


(


local
theArea = theAreaMethod theNode f


case
FaceAreaChecker.FaceAreaMode
of


(


default:
if theArea >=
FaceAreaChecker.FaceAreaThresholdMin
and
theArea <= FaceAreaChecker.FaceAreaThresholdMax
do append theResults f


2:
if theArea <=
FaceAreaChecker.FaceAreaThresholdMin
do
append theResults f


3:
if theArea >=
FaceAreaChecker.FaceAreaThresholdMin
do
append theResults f


4:
if theArea <=
FaceAreaChecker.FaceAreaThresholdMax
do
append theResults f


5:
if theArea >=
FaceAreaChecker.FaceAreaThresholdMax
do
append theResults f


6:
if theArea <=
FaceAreaChecker.FaceAreaThresholdMin
or
theArea >= FaceAreaChecker.FaceAreaThresholdMax
do append theResults f


)


)


3


),


 


fn
supportedCheck theNode =


(


classof
theNode == Editable_Mesh or classof theNode == Editable_Poly


),


 


fn
configDlg =


(


try
(destroyDialog FaceAreaChecker.faceAreaDialog)
catch()


rollout
faceAreaDialog "Face Area Checker"


(


dropdownlist ddl_FaceAreaMode width:150 align:#left
offset:[-10,-3] items:#(
"Between Min. and Max","Less Than Min.",
"Greater Than
Min."
,"Less Than Max.", "Greater Than Max.","Not Between Min. and Max") selection:FaceAreaChecker.FaceAreaMode across:2


colorpicker clr_resultsColor fieldwidth:10 align:#right
offset:[7,-3]
color:FaceAreaChecker.resultColors[FaceAreaChecker.FaceAreaMode]


spinner
spn_FaceAreaThresholdMin
"Min. Threshold:" range:[0,1000000,FaceAreaChecker.FaceAreaThresholdMin]
offset:[7,-3] type:#worldUnits


spinner
spn_FaceAreaThresholdMax
"Max. Threshold:" range:[0,1000000,FaceAreaChecker.FaceAreaThresholdMax]
offset:[7,-3] type:#worldUnits


checkbox
chk_InteractiveUpdates
"Interactive" checked:FaceAreaChecker.InteractiveUpdates offset:[0,-3]
across:2


button
btn_selectResults
"Selection" align:#right width:72 height:18 offset:[7,-3]


  


fn
updateDisplay =


(


if
FaceAreaChecker.InteractiveUpdates
do


(


XViewChecker.runCheck CurrentTime


max views
redraw


)


)


on
ddl_FaceAreaMode selected itm
do


(


FaceAreaChecker.FaceAreaMode = itm


updateDisplay()


clr_resultsColor.color = FaceAreaChecker.resultColors[itm]


)


on
clr_resultsColor changed val
do


(


FaceAreaChecker.resultColors[ddl_FaceAreaMode.selection] =
val


updateDisplay()


)


on
chk_InteractiveUpdates changed state
do


(


FaceAreaChecker.InteractiveUpdates = state


updateDisplay()


)


on
spn_FaceAreaThresholdMin changed val
do


(


FaceAreaChecker.FaceAreaThresholdMin = val


updateDisplay()


)


on
spn_FaceAreaThresholdMax changed val
do


(


FaceAreaChecker.FaceAreaThresholdMax = val


updateDisplay()


)  


on
btn_selectResults pressed
do


(


XViewChecker.selectResults CurrentTime


max views
redraw


)


on
faceAreaDialog moved pos
do
setIniSetting FaceAreaChecker.iniFileName
"Dialog" "Position" (pos as
string)


)--end rollout


 


local
thePos = execute (getIniSetting FaceAreaChecker.iniFileName
"Dialog"
"Position"
)


if classof
thePos != Point2
do thePos
= mouse.screenpos


createDialog faceAreaDialog 170 82 thePos.x thePos.y


FaceAreaChecker.faceAreaDialog = faceAreaDialog


),


 


fn
textOverride =


(


case
FaceAreaChecker.FaceAreaMode
of


(


1:
"Between
"
+FaceAreaChecker.FaceAreaThresholdMin as string +" and "
+FaceAreaChecker.FaceAreaThresholdMax
as
string


2:
"Less Than
"
+FaceAreaChecker.FaceAreaThresholdMin as string


3:
"Greater Than
"
+FaceAreaChecker.FaceAreaThresholdMin as string


4:
"Less Than
"
+FaceAreaChecker.FaceAreaThresholdMax as string


5:
"Greater Than
"+
FaceAreaChecker.FaceAreaThresholdMax as string


6:
"Not Between
"
+FaceAreaChecker.FaceAreaThresholdMin as string +" and " +FaceAreaChecker.FaceAreaThresholdMax as string


)


),


 


fn
dispOverride theTime theNode theHwnd theResults=


(


local
theColor = FaceAreaChecker.resultColors[FaceAreaChecker.FaceAreaMode]


XViewChecker.displayResults theColor theTime theNode theHwnd 3
(
for o
in theResults collect o+1)


)


)--end struct


 


try
(destroyDialog FaceAreaChecker.faceAreaDialog)
catch()


FaceAreaChecker = FaceAreaCheckerStruct()


 


XViewChecker.unRegisterChecker "Face Area Checker"


XViewChecker.registerChecker FaceAreaChecker.geomCheck
FaceAreaChecker.supportedCheck #Faces
"Face Area Checker" FaceAreaChecker.configDlg FaceAreaChecker.textOverride
FaceAreaChecker.dispOverride


)--end script

posted on 2011-04-15 11:38  盖天00  阅读(521)  评论(0编辑  收藏  举报

导航