@mikeZ7BJ8 wrote:
It worked! I went to accept your solution, denisT.MaxDoctor, and now it says it's been deleted!
Oh!
I didn't want to steal the better solution from Swordslayer.
here is the UI'ed Swordslayer's solution:
try(destroydialog rol) catch ()
rollout rol "RO:16AB3B8B" width:191
(
checkbox delete_ch "Delete Poly Dups" offset:[0,4]
checkbox weld_ch "Weld Open Edges"
button optimize_bt "Optimize" width:172 offset:[0,8]
label info_lb "" enabled:off
local _builtin = python.import #__builtin__
local _round = _builtin.round
fn round_pos pos ndigits:2 = [_round pos.x ndigits, _round pos.y ndigits, _round pos.z ndigits]
on optimize_bt pressed do undo "Optimize" on
(
if iskindof (node = selection[1]) editable_poly do
(
local threshold = sqrt (polyop.getFaceArea node 1) / 2
n0 = node.numfaces
info_lb.text = [0, n0] as string
local dict = Dictionary #string
count = polyop.getnumfaces node
dups = #{}
for k=1 to count do
(
c = polyop.getfacecenter node k
hash = (round_pos c) as string
if (i = dict[hash]) != undefined then
(
append dups k
append dups i
--removedictvalue dict hash -- ??? maybe not
)
else dict[hash] = k
)
free dict
node.selectedfaces = dups
if delete_ch.state do
(
polyop.deletefaces node #selection
)
if weld_ch.state do
(
node.weldThreshold = threshold
polyop.weldEdgesByThreshold node (polyop.getOpenEdges node)
)
n1 = node.numfaces
info_lb.text = [dups.numberset, n0] as string
)
)
on rol open do
(
info_lb.text = "select poly object"
)
)
createdialog rol