select by submaterial

Hi,

i wonder if it possible to write a scritp that would select all object including such or such instanced submaterial that stands in various multimaterials.

thanks in advance.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
draging's picture

hello, try this one select (

hello, try this one

select ( for obj in $* where classof obj.material == multimaterial collect obj )

is this what you want ?

cheers !

barigazy's picture

...

Is not that simple.
He want to select by sub-Material not multimaterial
I'll post solution later

barigazy

draging's picture

oopss... ok :D

oopss... ok :D

barigazy's picture

...

Try this tool for change :)
How it works:
Press "Pick MultiMaterial" button and from "Material/Map Browser" (in "Scene Material" Roll) pick multi material or any sub-material of some multimaterial.
This tool will check if picked material are assigned already and check wether is belongs to a multimaterial.
Spinner represents sub-material index.

try(DestroyDialog ::mmtlSelector) catch()
rollout mmtlSelector "Select by SubMtl"
(
	local mmtl
	fn filtMtl mat = (isKindOf mat multimaterial or (for r in (refs.dependents mat) where isKindOf r multimaterial collect r).count != 0)
	materialbutton choosemtl "Pick MultiMaterial" pos:[5,5] width:140
	spinner mtlSubs "Sub Material:" type:#integer pos:[5,30] width:140 enabled:off
	button btn "Select Object By Sub-Mtl" pos:[5,50] width:140 enabled:off
	on choosemtl picked mtl do
	(
		if not filtMtl mtl then
		(
			messageBox "Pick Already Assigned Multimaterial Or Some Sub_Material " title:"Warning" beep:off
			choosemtl.text = "Pick MultiMaterial" ; mtlSubs.value = 0 ; mtlSubs.enabled = btn.enabled = off ; mmtl = null
		)
		else
		(
			mmtl = if isKindOf mtl multimaterial then mtl else (for r in (refs.dependents mtl) where isKindOf r multimaterial collect r)[1]
			choosemtl.text = if mmtl.name == "" then mmtl.name = ("MultiMtl_#"+(random 1000 2000) as string) else mmtl.name
			mtlSubs.range = [1, (mmtl.materialList.count), 1] ; mtlSubs.enabled = btn.enabled = on
		)
	)
	on btn pressed do 
	(
		if isKindOf mmtl multimaterial do
		(
			if not MeditUtilities.isMaterialInUse (sub = mmtl.materialList[mtlSubs.value]) then 
			(
				messageBox "This Material Is Not Assigned To Any Object!" title:"Warning" beep:off
			)
			else
			(
				select (refs.dependentNodes sub)
			)
		)
	)
	on choosemtl rightclick do (choosemtl.text = "Pick MultiMaterial" ; mtlSubs.value = 0 ; mtlSubs.enabled = btn.enabled = off ; mmtl = null)
)
createDialog mmtlSelector 150 75 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

barigazy

barigazy's picture

...

I did not test this but you can try it :)

barigazy

appius's picture

waow!

waow! that was fast! you rock!

it seems to work fine. thanks a lot.

I just don't understand what's the choice between instance and copy.
it's a detection method? if so, the copy method never get results, even if I copy a submat from a multimat into an other multimat and after renaming it with same name...

barigazy's picture

...

That's the default behavior of material/map buttons. Material Editor works also that way. U need to choose "Instance" because "Copy" will create new material which is unused in the scene

barigazy

appius's picture

...

ok, thanks.
could you make it installable in user interface?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.