ScriptSpot home

SME Get Selected Materials

Downloads

Release history (1)
  • Version 0.10Listed version

    Listing updated

    No download linked to this version

3ds Max compatibility
Unknown
Report a problem
Community reviewsNo reviews yet.

Listing details

Version
v0.10
Author’s update date
Legacy votes
6
Listing created
How compatibility works

Compatibility comes from the author’s supported range or requirements in the original listing. A tested version records what the author tried.

“2020 unconfirmed” in the catalog means support for 3ds Max 2020 is still unknown.

Community reports record successful tests on specific releases.

Posted by

pixamoon

Credited author: Pixamoon

More by this author

Description

This script is useful only for script writers.

This is just simple function to get selected materials / textures / controllers from active view in SME.

Function returns materials :) - not names of materials.


function SMEGetSelMats = (    
	viewNode = sme.GetView (sme.activeView)
	smeSelMats = #()
	for n = 1 to trackViewNodes[#sme][(sme.activeView)].numSubs do (
		m = trackViewNodes[#sme][(sme.activeView)][n].reference
		b = viewNode.GetNodeByRef m
		if b.selected do append smeSelMats m
	)
	return smeSelMats
)

-- do something here
print (SMEGetSelMats())

I've got message - it doesn't work with 2012. If anybody has 2012, please test and let me know

Enjoy
Pixamoon

Comments (3)
3dwannab

Just to expand on this more :)

notes to comment:


ar_smeSel = #()
ar_smeSelFCtrl = #()
ar_smeSelMaps = #()
ar_smeSelMats = #()
getActiveViewSME = sme.GetView (sme.activeView)
viewNodeCount = getActiveViewSME.GetNumNodes()

smeViewMaterials = for n = 1 to viewNodeCount where isProperty trackViewNodes[#sme][sme.activeView][n] "reference" do
(
	maxObj = trackViewNodes[#sme][(sme.activeView)][n].reference -- collect entire curent views: materials, maps, etc.
	b = getActiveViewSME.GetNodeByRef maxObj -- GetNodeByRef of entire current view

	-- collect everything if selected
	if b.selected == true do append ar_smeSel maxObj

	-- get materials from ar_smeSel array
	ar_smeSelMats = for o in ar_smeSel where (superclassOf o == material) collect o

	-- get texture maps from ar_smeSel array
	ar_smeSelMaps = for o in ar_smeSel where (superclassOf o == textureMap) collect o

	-- get floatControllers from ar_smeSel array
	ar_smeSelFCtrl = for o in ar_smeSel where (superclassOf o == floatController) collect o
)
Shawn Olson

Thanks for sharing. I've used a similar set of logic for a while but ended up simply abandoning it. You might want to look at http://forums.autodesk.com/t5/programming/sme-maxscript-access/m-p/56339… because the results seem to be bugged in many cases. I noticed that the results were sometimes correct, but just as often totally wrong.

AD has confirmed the bug. It's annoying, but at least as of June it was still broken in all versions of Max. I haven't tested in 2016 SP1 yet.

Reply to Shawn Olson
pixamoon

`

hey hey,

I saw that on AD forum and CGSociety forum but it didn't work for me because:

view.GetNode n

"n" index is different than "n" index in:

trackViewNodes[#sme][v][n]

I noticed that index can be the same on beginning only - till double click on node (to load it into right panel). After that index is moved.

That's why we can't get selected material from selected node by

if (view.GetNode n).selected do mat = trackViewNodes[#sme][v][n].reference

But your post was a big step to find this solution :) Thanks!

Best,
Pixammon