Community
3ds Max Modeling
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max modeling topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I deleting duplicate faces?

11 REPLIES 11
Reply
Message 1 of 12
andrewmcadam1402
21762 Views, 11 Replies

How do I deleting duplicate faces?

Yo. I have a very old model from one of our previous projects. It was previously rendered with max scan line and had standard materials on it. Now we are updating it for a HD render and updated with mental ray and arch&design material. When doing test renders there have been some very strange results, on closer inspection I have realised the models have been duplicated. They have been duplicated in exactally the same spot and are part of the same element. I’m currently trying to go through each polygon(element) and delete the duplicate but its taking an age. It was a model imported from iges format so the model is very broken up.

Does anyone have a good method for deleting duplicate surfaces?
I have tried xview but selecting the results just seems to select the whole model which ever method I choose.
Mac
11 REPLIES 11
Message 2 of 12

ouch, not a fun task...
here is a method i have used in the past which may assist you. in a nutshell its simply splitting up the mesh via the uvw unwrap modifier and using this to easily select the duplicate faces.

as per the attachment:


as you can see i have 2 teapots here sitting ontop of each other


i have attached both objects to be a single object.


i add the uvw unwrap modifier and using the spherical preset use this break up the model. you may find a differe preset may work better with the object your working with.


using the tools > pack uvws in the uvw unwrap window it aligns all the objects so that none are overlapping.


now i can easily identify the duplicate faces and select the ones i wish to delete, note i have ticked select element so i can quickly select the objects as a whole rather than trying to get all the faces separately. also note... you can not delete the selected faces yet


with the faces still selected i collapse the uvw unwrap modifer so its just an editable poly. i switch to element and my selection has been retained, now i can press 'delete' to delete the duplicate faces.


i re-appply the uvw unwrap modifer to confirm that the duplicate faces have now been deleted, successfully.

--------------------------------------------------------------------------------------
Technical 3D Graphic Artist
Autodesk 3dsMax 2015 - Service Pack 4
--------------------------------------------------------------------------------------
Message 3 of 12

Thanks for this blakestone, thats a neat trick, thinking out of the box. I had a go but the model is so badly imported that i have a few hundred polygons splattered around making it difficult to identify what i need to delete 😞 and i have around 20 of these all different. I have attached an image.

Any other ideas?

Message 4 of 12

The only other suggestion which comes to mind is writing a maxscript which checks the xyz co-ordinates of each face and then checks to see if there are any other faces with the same xyz co-ordinates and presto delete one of them.

This is an easy script to write if you know the max language however i don't. It would be something like this:

== this is not a working script ================================================================

global $array = selection

$array = array.sort()

for $a = 0 to array.count($array)
if $array = $array then face.delete($array)
next

================================================================================================

someone with some maxscript experience may be able to write something for you!?
--------------------------------------------------------------------------------------
Technical 3D Graphic Artist
Autodesk 3dsMax 2015 - Service Pack 4
--------------------------------------------------------------------------------------
Message 5 of 12
amarhys
in reply to: andrewmcadam1402

I would suggest :

a) If not already the case, convert your object in Editable Mesh
b) Select all vertices and weld them using a very low threshold value (to weld together only vertices which have the exact same coordinates)
c) Apply an STL checker modifier and configure it to find and select double faces
d) Apply an Edit Mesh modifier, set sub-object selection to faces (it will retrieve face selection from STL modifier) and delete the selected faces
e) Collapse the stack

- amarhys
Message 6 of 12
hathMirx
in reply to: andrewmcadam1402

CONFORM(2x). WELD.

(start over using the original clueless model as a template; maybe after a manditory ATTACH in subobj epoly)
Message 7 of 12
amarhys
in reply to: andrewmcadam1402

My mistake, STL ckecker does not select only duplicated faces .. it returns them by pair .. so not really useful

I wrote a script to do the job for you.

This script assumes the following :
1) Your object is a Editable Mesh (collasped, not an object with an Edit Mesh modifier on the top)
2) Your object is selected
3) You have performed a vertices weld before. The script identifies a duplicate face when it has the same 3 vertices as another existing face.

At the end of the execution, the duplicated faces (only) are selected on your mesh.

I checked it on two teapots merged together (total of 12640 faces) under Max 2012.

Note :
The script also assumes that the function getFace returns a point3 where vertex indexes are sorted. I am not sure it is always the case, but I guess. If it does not work with your mesh, try to uncomment the line -- if ((DuplicateFace ... and to comment if (facesCertices == .... However, the processing time will be longer ..

Hope it will help.

- amarhys


global nbFaces = (getNumFaces $)

global facesVertices = #()
global duplicateFaceArray = #()

----------------------------------------------------------
-- Progress Bar
----------------------------------------------------------
rollout pgbar "Get Duplicate Faces"
(
progressBar pgb value:0 orient:#horizontal color:(color 0 128 128) pos: width:220
)

----------------------------------------------------------
-- Return 1 if faces are duplicated
----------------------------------------------------------
function DuplicateFace fv1 fv2 =
(
local f1a = # (fv1.x, fv1.y, fv1.z)
local f2a = # (fv2.x, fv2.y, fv2.z)
sort f1a
sort f2a

-- compare array
if (f1a == f2a and f1a == f2a and f1a == f2a) then return 1 else return 0
)


-- Store faces vertex indexes
for i = 1 to nbFaces do
facesVertices = getFace $ i

createDialog pgbar width:250 height:50

-- Loop all faces one by one and check if they are duplicated or not
for f1 = 1 to nbFaces do
(
-- If face not already flagged as duplicated
if ((findItem duplicateFaceArray f1) == 0) then
(
for f2 = (f1+1) to nbFaces do
(
--if ((DuplicateFace facesVertices facesVertices)==1) then
if (facesVertices == facesVertices) then
(
append duplicateFaceArray f2
exit
)
)
)

current_percent = 100*f1/nbFaces
pgbar.pgb.value = current_percent

)

setFaceSelection $ duplicateFaceArray

Message 8 of 12

A couple of things there...

Chances are that the objects are Editable Polys rather than Editable Meshes, so forcing the issue (convertToMesh) might be an idea. Same complaint could be levelled at my code below which assumes an Editable Poly 😉

For the vertex position tests to work, the locations must be absolutely identical. You can't rely on the displayed values (spinners at the bottom of the Max window) as they tend to be rounded, so you may think they are coincident when they actually aren't. Even the slightest difference like 0.999997 instead of 1.0 will cause the tests to fail.

With Editable Polys there no guarantee that the vertices (from getFaceVerts) will be returned in the same order (it returns an array of point3 values) - depends entirely on how the model (or its duplicate) was constructed, so I used getFaceCenter, but even that has potential problems as outlined in the help. Welding of remaining vertices could easily be added, if required.

Note. IF we're going to discuss this further (script-wise) it might be better for us to cretae a thread in the Maxscript forum and link to that thread from here (saves cluttering up this thread with code).

(
--change this value if the script is deleting too few or too many faces
local limit = 0.01
local obj = selection

fn p3Equal p3a p3b = --"close enough" for point3 values
(
local pm = limit / 2.0
if (p3b > (p3a - pm)) and (p3b < (p3a + pm)) and
(p3b > (p3a - pm)) and (p3b < (p3a + pm)) and
(p3b > (p3a - pm)) and (p3b < (p3a + pm))
then
true
else
false
)

(
local polyList = #{}
polyCount = polyOp.getNumFaces obj
polyList.count = polyCount
for p = 1 to polyCount - 1 do
(
if not polyList

then
(
polyLoc = polyOp.getFaceCenter obj p
for np = p + 1 to polyCount do
(
npolyLoc = polyOp.getFaceCenter obj np
if p3Equal polyLoc npolyLoc then
polyList = true
)
)
)
--could be replaced with a setFaceSelection if required
polyOp.deleteFaces obj polyList
)
)


Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

Message 9 of 12
amarhys
in reply to: Steve_Curley

Like you Steve, I should have used a bit array instead of a standard array in my script to store the duplicated faces .. faster to be accessed and to be tested (not polyList

test should be really faster than findItem .. test, especially for big amount of faces), then a better runtime at the end.
Message 10 of 12
Steve_Curley
in reply to: Steve_Curley

I actually started out with an integer array, then realised that I was effectively only storing a binary (yes/no) value despite actually storing a face number, so I switched to a bitArray. It wasn't done purely on a "need for speed" basis - that's just a useful side effect 😉

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

Message 11 of 12
RadioRahim
in reply to: amarhys

I am having hte same issue with replciated polygons. I took the steps of:

1) Your object is a Editable Mesh (collasped, not an object with an Edit Mesh modifier on the top)
2) Your object is selected
3) You have performed a vertices weld before. The script identifies a duplicate face when it has the same 3 vertices as another existing face.

and ran the script but got this error:
complie error.JPG






is there something I am doing wrong or perhaps a version compatibility issue? I'm running 2017 max. 

Cheers

Message 12 of 12

check and try this:
http://www.scriptspot.com/3ds-max/scripts/find-coinstances

 


Ronel Katigbak Pabico

3D Generalist / Animator / Renderer/ Graphics Designer

Autodesk Student Ambassador Platinum
YouTube Channel l Linked l Facebook l Blogs

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report