ScriptSpot

Script

Detach by Material ID

By Jeff Lim · 2006-10-21

Version
2
Version requirement
3ds Max 9
Date updated
2008-12-09
Votes
38
Description

Detach Polygons based on its Material ID

Additional Info

Features
  • works on a selection of objects
  • options to automatically name detached objects
  • material propagation
    • this will assign a corresponding material by id to the detached object
Usage
  1. select any number of objects
  2. set the desired paramteters
  3. optional: if you know the maximun number of ids the object has, set the Max IDs to help speed up detachment.
  4. press detach

Internal Operations
Procedure:
  • object[s] is/are copied
  • then collapsed to an editable poly
  • faces are finally detached by material ID

Naming:
  • Numbered
    • will creae numbered names
    • e.g. 0,1,2,3
    • preferable to use with the Prefix option checked
  • Bitmap Name
    • if not diffuse bitmap found, it will use the material name
    • if no material applied, it will use the object's name
  • Material Name
    • if no material applied, it will use the object's name
  • Object Name
    • will create a unique name based on the object's name
Attachments

Tags: Material, detach, id

Comments (23)

Script Change

psh19989 · 2020-08-24

We want to change to mesh instead of poly when we run the script. How should I change it? We want the noodles to be mesh.

EditableMesh output would be great!

harumscarum · 2021-04-11

Could anyone adjust it to have EditableMesh as output objects?

abdelhameadrasslan · 2019-09-01

This script saves lifes thanks for the effort !

a lot of errors

chew · 2018-10-16

-- Error occurred in i loop; filename: C:\Users\XXX\Desktop\SCRIPTS\DETACH_BY_MATERIAL_ID\detachbyID.ms; position: 4358; line: 159
-- Frame:
-- theDetachedObj: $rug020
-- the_faces: #{1..114}
-- i: 1
-- called in obj loop; filename: C:\Users\XXX\Desktop\SCRIPTS\DETACH_BY_MATERIAL_ID\detachbyID.ms; position: 4471; line: 163
-- Frame:
-- the_orig: $rug18
-- the_mat: rug3:Standard
-- id_count: 7
-- obj: $rug18
-- Error occurred in detach_bot.pressed(); filename: C:\Users\XXX\Desktop\SCRIPTS\DETACH_BY_MATERIAL_ID\detachbyID.ms; position: 4553; line: 166
-- Frame:
-- the_sel: #($wassily_chair05, $wassily_chair04, $wassily_chair03, $coffee cups15, $coffee_table03, $rug18, $coffee_table05, $magazine_face_down01)
>> MAXScript Rollout Handler Exception:
-- Unable to convert: ReferenceTarget:Texmaps to type: Material <<
-- Error occurred in i loop; filename: C:\Users\XXX\Desktop\SCRIPTS\DETACH_BY_MATERIAL_ID\detachbyID.ms; position: 4358; line: 159
-- Frame:
-- theDetachedObj: $Maps001
-- the_faces: #{1..17214}
-- i: 1
-- called in obj loop; filename: C:\Users\XXX\Desktop\SCRIPTS\DETACH_BY_MATERIAL_ID\detachbyID.ms; position: 4471; line: 163
-- Frame:
-- the_orig: $cushion22
-- the_mat: farbric:Standard
-- id_count: 7
-- obj: $cushion22
-- called in detach_bot.pressed(); filename: C:\Users\XXX\Desktop\SCRIPTS\DETACH_BY_MATERIAL_ID\detachbyID.ms; position: 4553; line: 166
-- Frame:
-- the_sel: #($cushion22, $cushion08, $ceramic_bowl1, $cushion20, $sofa_right, $cushion11, $sofa_long_right06, $sofa_long_right04, $cushion12, $cushion21, $cushion13, $sofa_right01, $cushion14, $coffee_table01, $apples02, $ceramic_bowl02, $wooden_bowl02, $coffee_table, $apples01, $wooden_bowl1, ...)
>> MAXScript Rollout Handler Exception:
-- Unable to convert: ReferenceTarget:Texmaps to type: Material <<

The best script ever to import "bad" clients sketchup models

lipknik · 2015-11-13

This script is a life saver for that kind of models which comes all in one single layer. But the client toke the time to insert some materials definitions on it...

Really great man!, you save my morning!

request

harumscarum · 2015-07-14

would be great to have an option to detach by material ID to EditablePoly elements (not new objects) - separate macros without UI

thank you in advance

Random bitmap name

backflipbedlem · 2012-06-01

Great script dude,
But when tick the use bitmap name option, it saves it with a random bitmap name, not one that corresponds to the object!

Any ideas how to fix????

asymptote · 2012-05-30

This is great, but freaks out and throws up an error when one of the selected objects has only a single id and cannot be detached.
Can this be easily fixed ?

Very Cool, wish it had one thing though

mmaitland · 2011-08-12

Very Nice!! I wish it had an option to group the objects after it blows them apart, or at least have all of the objects selected that it tweaked. Thank you for the script!

thanks for this script but...

crystal3d · 2011-08-01

it gave this error when trying it on a bunch of vray materialed objects...

i think it errors when

crystal3d · 2011-08-01

one of the selected objects had no multiple materials applied so have to choose the objects carefully!:)

doesn´t work for me

jsrocha · 2010-10-27

Hey man, the script doesn´t work for me. I´m using max2009, and when i click the detach button, nothing happens....
is a pity, because it´s a very useful script.
Thanks,

Jsrocha

chalid · 2010-03-24

thanks bro.. this script is very useful..

Spacelord · 2010-02-05

Great work !!

Plus 1 to Titanes request :)
it would be handy to make each object end up with its separate material and not the multisub.

Jeff Lim · 2010-02-05

Thanks! I might need to test this again.. but I think that's what the "Propagate Materials" is for. :)

one808 · 2009-12-24

O O O O
verygood ,thanks.^_^

subburb · 2009-04-09

Woaw ! simple and efficient... 5 ***** for this perfect script !

jerome Prévost (Subburb)

titane357 · 2008-12-09

:-)

titane357 · 2008-12-08

happy to see you're here !!!! :-)
Thanks again !
I will abuse : could it be possible to have each resulting separate object with right material applied ? (and not the multi subobject material ?)
For chrismas ? New year ? :-))

Jeff Lim · 2008-12-08

ok! somehow, i couldnt get myself to not update this script. merry christmas.

Jeff Lim · 2008-12-08

thanks, I'll try to look into the code again and see if i can make feasible adjustments. I can't promise an update anytime soon coz of busy schedules, my apologies.. :)

titane357 · 2008-12-05

Great script, thanks !!!!
Last update 2005 is somebody strong enough to optimize it ? (a bit slow)