Explode objects to elements by smoothgroup


Hello All,

I just spend one week to get hold of this problem but i must do something wrong here…
maybe i’m using a totaly wrong approche…

The problem is that i have to explode the objects into elements before exporting
to preserve smoothinggroups.

here is what i have come up with so far…

global snaps
   global num_faces
   global snaps = snapshot selection[1]
   global num_faces = snaps.numfaces
   global sg_1 = #()
   global sg_2 = #()
   global sg_3 = #()
   global sg_4 = #()
   for s = 1 to num_faces do (
   		local sg_face = getFaceSmoothGroup snaps s
   		if sg_face == 1 do (
   		append sg_1 s
   		if sg_face == 2 do (
   		append sg_2 s
   		if sg_face == 3 do (
   		append sg_3 s
   		if sg_face == 4 do (
   		append sg_4 s
   delete snaps

it works OK for spheres and meshes…but not for simple objects like a cube…

here i get the following:

for a cube i get 2,4,8,16,32,64 as smoothinggroups using the above command…
when i enter subobjectLevel = 3 and select the faces manually i get 1,2,3,4,5,6 in the
smoothinggroups rollout…

I don’t get it…

Is there a better way to do this…also i would like to have to total count of smoothgroups used and a better way to scan through all the smoothgroups…

I really would apprechiate some help from you pros…:slight_smile:
As i’m sure this is quite easy if you know how.

Thanks slot for your help in advance…



The number returned by getFaceSmoothGroup is not a normal number because there is sometimes more than one SG for a single face. For example the face 3 has the SG 5 and 17… at the same time

The convertion of this number in a bitarray is already indicated in maxscript reference.


Thanks arketip :slight_smile:

yes i already went through the maxscript reference but still have no clue on how
to implement this into the exporter.

Some help would be apprechiated.



Hey, I think the best way to do this would be to check all the edges if their faces have the same smoothing group and if not, split them. Here is example code for a polyobject:

alledges = #{1..(polyop.getNumEdges $.baseobject)} -- all edges bitarray
alledges -= polyop.getOpenEdges $.baseobject --exclude open edges
splitedges = #{}
for i in alledges do
edgefaces = polyop.getFacesUsingEdge $.baseobject i as array --the faces of the edge
smoothgroup1 = polyop.getFaceSmoothgroup $.baseobject edgefaces[1]
smoothgroup2 = polyop.getFaceSmoothgroup $.baseobject edgefaces[2]
if smoothgroup1 != smoothgroup2 or smoothgroup1 == 0 or smoothgroup2 == 0 do splitedges[i] = true
-- if the smoothing groups are different or nonexsisting add edge to splitedges bitarray
polyop.setEdgeSelection $.baseobject splitedges
$.EditablePoly.splitEdges ()



Here is another example.
I create an array which indicates for every SG the faces which belong to him.
Of course 1 face can be inside several SG at the same time.

fn getSGarray obj = (
	local SGarray=for i=1 to 32 collect #()
	local theFaces=#{1..obj.numfaces}
	for f in theFaces do (
		local SGnumber = getFaceSmoothGroup obj f
		local SGbitarray=#{}
		if SGnumber < 0 do (
			SGnumber -= 2^31
		for i = 1 to 31 do (
			SGbitarray[i] = (mod SGnumber 2 > .5)
			SGnumber /= 2
		for sg in SGbitarray do append SGarray[sg] f

obj = selection[1]
SGarray=getSGarray obj
for i=1 to 32 do (
	if SGarray[i].count!=0 do format "smoothing group % includes faces % 
" i SGarray[i]

The result will be in the listener (F11)


Hello all ,

thank you so much for helping me ! :)

The Exporter works smooth like a charm..:)

TO Rivendale: i tried your suggestion but unfortunatelly i only got messed up meshes 
in Kerkythea...maybe because i use a snapshot of the objects to export from
so i had to convert to editable_poly and back to mesh.....or maybe it's Kerkythea..
Thanks alot anyway....:)

TO arketip: After taking care of the case that there might be objects with no faces
it runs smoothly...already exported objects with more than 400thousand faces..:)
including smoothing groups...so far i had no problems with faces sharing smoothinggroups.

But maybe my solution isn’t the best for this case…Does anyone know a better solution ? But as long as it works,.:slight_smile: alot better than before where the smoothinggroups where lost and objects were smoothed wrong.
thanks alot…:slight_smile:

u3dreal ;)


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.