Making a Simple interface to get material

Making a Simple interface to get material

Anonymous
Not applicable
550 Views
8 Replies
Message 1 of 9

Making a Simple interface to get material

Anonymous
Not applicable
Hello,
I trying to make a simple script to get a material by drag and drop from the slate ME.
Anyone can help me?
I have search but witout success...
Regards.
Nick.
0 Likes
551 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
By default, if there are not a button or function that do this,
How to get the name of the material(s) selected ?
Thanks
0 Likes
Message 3 of 9

barigazy
Enthusiast
Enthusiast
Read this thread on scriptspot
0 Likes
Message 4 of 9

Anonymous
Not applicable
Thanks, very interesting. It's helpful.
but I need to assign an existing material in the sme to the temp. object.
How ?
0 Likes
Message 5 of 9

Anonymous
Not applicable
Ok, I have find how to apply the material to multiples objects in scene, but my problem is simple :
When I start a new scene with Slate and that I make a new material, the n° of this material are > to 24 -- here is the problem : the function meditMaterials to apply the material are limited to 24...
How to solve the problem ?
0 Likes
Message 6 of 9

Steve_Curley
Mentor
Mentor
You are reading it wrong.

The MeditMaterials collection refers only to the Sample Slots in the old "compact" material editor, and even there there is no restriction on the number of materials there can be in a scene. Those slots are for editing only and are virtually redundant in the Slate editor, seving only as a link between the 2 editors.

Any material you create and apply to an object will appear in the SceneMaterials collection, so use that instead.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 7 of 9

Anonymous
Not applicable
Here my code :


nbrObjects = selection.count
getActiveViewSME = sme.GetView (sme.activeView)
viewNodeCount = getActiveViewSME.GetNumNodes()
smeViewMaterials = for n = 1 to viewNodeCount collect ((getActiveViewSME.GetNode n).name)

if (nbrObjects) == 0 then
messagebox "Please, select one or more object"
else
(
for obj in $ do
(
RandomSelection = random 1 viewNodeCount
MatSelector = smeViewMaterials
obj.material = sceneMaterials
)

)



The problem that the script work only if the materials are be put in the scene on an object before...
There are another fonction to assign a material to 1 or more objects ?
Sorry... I'm new in scripting.
0 Likes
Message 8 of 9

Steve_Curley
Mentor
Mentor
There's nothing really wrong there, except that it seems Maxscript simply doesn't expose enough for you to do what you want.

The problem is that the node returned by getNode() is a MixInInterface:Node about which there is precious little information. It's odd that you get at the Name but not at the material the node represents. Unless they put something in but didn't document it, I think you might be out of luck.

One alternative, as you noticed, is to apply the materials to objects so they appear in the SceneMaterials.

This old thread (probably for Max2011) has much the same problem.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 9 of 9

Anonymous
Not applicable
Ok, thanks Steve.
Regards.
0 Likes