ScriptSpot

Forum topic · Scripts Wanted

Delete Polygons facing and touching eachother

By tuxmask75 · 2012-12-23

Description

If you place 100s of cubes that are snapped side by side,and top and bottom, than attach them to eachother via edit poly mode.

I'd like to be able to delete all the faces that are facing eachother and touching.

Illustration with 2 cubes here. the red area would be cleand out, so the mesh could later be welded.

Attachments
Comments (5)

tuxmask75 · 2012-12-26

Ok, so with a little further experimentation. it seems that overlapping normals need to be 100% overlapping without a margin of error. when using the snap tool to snap cubes or other meshes next to each-other, there is a .00001 or something margin of error. causing facing objects not to delete faces.

To help speed work-flow even further.
I think that we need another script that should run before this one that acts sort of like a weld selected vertex in edit poly mode,
However having it just move near vertex together from 2 separate models without the weld.

Graph · 2012-12-24

yeah the objects need to be editable poly base-objects
and not attached

then just execute it (may have to switch to modify panel but shoundt have to theoretically)

Wow ! !

tuxmask75 · 2012-12-25

One kick ass script indeed! Thanks man !
( not sure what the issue was ... but it works now)

Graph · 2012-12-24

doing that after the attaching would've been easier to code.. so i wrote one that would do it before you attached any


(
	struct faceData
	(
		public owner, public center, public area, public normal, public i;
	)
	
	-- collect all data for comparison
	local faceDataNArr = for o in geometry where classOf o == Editable_Poly collect 
	(
		for f = 1 to (polyop.getNumFaces o) collect
			faceData o (polyop.getFaceCenter o f) (polyop.getFaceArea o f) (polyop.getFaceNormal o f) f;
	)
	
	-- compare all faces and collect equal ones
	local equals = #()
	for x in faceDataNArr do
		for i in x do
			for y in faceDataNArr where (x != y) do
				for o in y do 
					if ((i.center == o.center AND i.area == o.area) AND i.normal == -o.normal) do (append equals o);
	
	-- sort them by owner(object)
	local sortedOwners = #();
	local sortedVals = #();
	for each in equals do
	(
		local found = findItem sortedOwners each.owner
		
		if (found != 0) then
		(
			sortedVals[found][each.i] = true;
		)
		else
		(
			append sortedOwners each.owner;
			append sortedVals #{each.i};
		)
	)

	-- now delete the equal ones
	for i = 1 to sortedOwners.count do
		polyop.deleteFaces sortedOwners[i] sortedVals[i];
	
	OK
)

tuxmask75 · 2012-12-24

Aww man, I couldn't get it to work.
What is the workflow for this script?
Can i just use standard cubes? or do they need to be editable poly/mesh?
(ive attempted all scenarios i could think of)

Does the script need to be installed somehow?
Right now i'm just doing the run script and or drag and drooping it into Max 2012 and 2013.