Notifications
Clear all

[Closed] How to get smoothing group of Edit_Poly faces?

What I want to do:

  1. apply Edit_Poly modifier
  2. select face
  3. get the smoothing gropu of that face

1 and 2 are easy, but 3 is not(for me)

MaxScript reference say:

[left]<Edit_Poly>.[b]smoothingGroupsToSet[/b] Integer default: 0 -- integer;  Smoothing_Groups_to_Set
 [/left]
  [left]Get/Set the  smoothing group to set.
 [/left]
 

Whit this I can set the smoothing group, but how to get it?

20 Replies

if edit_poly face selected the corespondent trimesh face(s) selected too. use meshop method to get the ID


getfacematid node.mesh node.mesh.selectedfaces[1]

Thank you.

I don’t kno why but when I use

getfacematid node.mesh node.mesh.selectedfaces[1]

the error occure:
– Unable to convert: #faces(1072 : TriMesh) to type: Integer

So. i’m using this


selFace = ($.mesh.selectedfaces[1]) as bitarray
selFace1 = (selFace as array)[1]
	
 for i = 1 to 32 where bit.get (getFaceSmoothGroup $.mesh selFace1) i do print i

my bad… you asked about smoothing groups i’ve answered about mat id.
sorry… but the idea the same:
(if function doesn’t like vertex we give it index)


 [b]getFaceSmoothGroup node.mesh node.mesh.selectedfaces[1].index[/b]
 

ps. you have to collect all smoothing groups using sm group value. so you are onto the right track.

Thank you again. :0
One more question. I want to check the smoothing group of all faces and then to apply different material ID to each face based on it smoothing group. Is there a way to do this without selecting every face one by one?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

heh… it sound too familiar for me. i bet you are making the tool that colorizes the mesh based on their face smoothing groups.

#1. use full sm group value
#2. don’t use multi-material (mat id). 32bits value can give you very bid mat IDs. that’s OK for the system (as i remember (not sure) the system allows 65535 mat ids, but multi-material can handle only 100 ids for UI and 256 for the system).
#3. use vertex colors (actually face colors)

if you interested how to gen unique color using integer (sm group) i can show…

you can get all faces sm id without selecting edit_poly faces. go through all trimesh faces, and find correspondent edit_poly faces. i posted several times on this forum how to get poly face using mesh face id.

I have to add Mask Map to RTTAssist. My first version of mask map was to copy the objects, cobvert them to editable_poly and then separate by elements, material ID or smoothing groups. But, as I expected, copying the big objects(imported from Zbrush) can crash max. So we came to idea to add Edit_Poly modifier on top of each objects and then separate by elements, material ID or smoothing group. The code that separate objects by elements is already done, but smoothing groups…
Thanks to your help, this is what i’v done:

max modify mode
 subobjectlevel = 4
 faceCount = getNumFaces $
 allFaces = #{1..faceCount}	
 with redraw off
 (
 	for f in allFaces do
 	(
 		$.modifiers[#Edit_Poly].SetSelection #Face #{}
 		$.modifiers[#Edit_Poly].Select #Face #{f}
 		for i = 1 to 32 where (bit.get (getFaceSmoothGroup $.mesh $.mesh.selectedfaces[1].index) i) do
 		(
 			$.modifiers[#Edit_Poly].SetOperation #SetMaterial
 			$.modifiers[#Edit_Poly].materialIDToSet = i
 			$.modifiers[#Edit_Poly].Commit ()
 		)
 	)
 )
 redrawviews()

But every face get the materialID = SG+1 (if the SG = 5 the matID = 6). I have to select every face adn this is slow.
For colorizing I use multimaterial with 100 ids.
Generating random colors using integer – something like this
random (color (sgr sgg sg*b)) or I’m on wrong path.

Edit: I didn’t see your last post. Is there a way to set the material ID for every faces without selecting them one by one?

with really big objects (imported from Zbrush) you can do nothing. they crash the system any way.
however i don’t understand the using of Edit_poly modifier. What do you not to do with editable_poly that needs Edit_poly modifier?
edit_poly modifier is VERY slow, it needs to BE OPEN in modpanel to be working…
i try to limit the using of edit_poly modifier in my tools by very specific cases.

I’m using edit_poly modifier because not every object may be an editable_poly or editable_mesh objects(i’v already write the code that do all that I want for editable_poly and editable_mesh objects).
Few minutes ago I execute the code(posted in my previous post) on object with 2368 faces and max crash – “Application run out of memory. Do you want… “.

i know why it was crashing.
i also explained on this forum why you can’t use node.mesh in intensive operations.
every time you call node.mesh in function the system creates a copy of the trimesh…
so to get some data using trimesh make a copy of it and use it in loop:


mesh = copy node.mesh
for f in mesh.faces as bitarray collect (getfacesmoothgroup mesh f)

also you will see how faster is it… for 2000 faces it takes nothing

Page 1 / 2