Posted By

janusoo on 11/18/13


Tagged

maxscript


Versions (?)

check editable_poly edge length and face verts count.


 / Published in: Maxscript
 

for editable poly only

  1. try(destroyDialog polyChecker)catch()
  2. rollout polyChecker "Check Edge Length"
  3. (
  4. label lbl_info
  5. group "Check Edge Length"
  6. (
  7. spinner spn_edgeLength "Length Limit" range:[0,1000,1] align:#left width:130
  8. button btn_checkEdge "Check" align:#right
  9. )
  10. group "Check Face"
  11. (
  12. spinner spn_vertsCount "Verts Limit" range:[1,4,10] type:#integer align:#left width:130
  13. button btn_checkFace "Check" align:#right
  14. )
  15.  
  16.  
  17. local warningNodes = #()
  18.  
  19. fn checkFace obj =
  20. (
  21. modPanel.setCurrentObject obj.baseObject
  22. subObjectLevel = 4
  23. faceCount = polyOp.getNumFaces obj
  24. facelist = for i = 1 to faceCount where (polyOp.getFaceVerts obj i).count > spn_vertsCount.value collect i
  25. polyOp.setFaceSelection obj facelist
  26. --subObjectLevel = 0
  27. if facelist.count > 0 then append warningNodes obj
  28. return facelist.count
  29. )
  30.  
  31. function getEdgeLength theEditablePoly iEdge =
  32. (
  33. -- get vertexes defining the edge into an Array
  34. aiEdgeVerts = polyOp.getEdgeVerts theEditablePoly iEdge
  35.  
  36. -- get vertexes positions into an Array
  37. ap3VertPosition = for iVert in aiEdgeVerts collect
  38. polyOp.getVert theEditablePoly iVert
  39.  
  40. -- return the distance between vertexes
  41. result = distance ap3VertPosition[1] ap3VertPosition[2]
  42. return result
  43. )
  44.  
  45. function checkProcess obj edgeLength =
  46. (
  47. target = obj
  48. if isKindOf target.baseObject Editable_Poly do
  49. (
  50. modPanel.setCurrentObject target.baseObject
  51. subObjectLevel = 1
  52. vertsList = #()
  53. edgeList = #()
  54. edgeCount = polyOp.getNumEdges target
  55. for i = 1 to edgeCount do
  56. (
  57. if (getEdgeLength target i) < edgeLength then
  58. (
  59. append edgeList i
  60. for num in (polyOp.getEdgeVerts target i) do append vertsList num
  61. )
  62. )
  63. polyOp.setEdgeSelection target edgeList
  64. polyOp.setVertSelection target vertsList
  65. redrawViews()
  66. return edgeList.count
  67. )
  68. )
  69.  
  70. fn updateInfo str =
  71. (
  72. lbl_info.text = str
  73. )
  74.  
  75. on btn_checkEdge pressed do
  76. (
  77. updateInfo ((checkProcess $ spn_edgeLength.value) as string + " edges are found.")
  78. )
  79. on btn_checkFace pressed do
  80. (
  81. errorCount = 0
  82. for o in selection where isKindOf o.baseObject Editable_Poly do
  83. (
  84. errorCount += checkFace o
  85. )
  86. subObjectLevel = 0
  87. if errorCount > 0 then
  88. (
  89. select warningNodes
  90. updateInfo (errorCount as string + " faces got error.")
  91. ) else (
  92. updateInfo "No error."
  93. )
  94.  
  95. redrawViews()
  96. )
  97. )
  98. createDialog polyChecker

Report this snippet  

You need to login to post a comment.