PDA

View Full Version : I am looking for material cycling script


kursadk
09-26-08, 03:05 PM
Hi
I need a script that cycles materials via shortcut. I searched the forum but have not seen such thing. Does anyone know any script or way to cycle-toggle materials?

thanks

ChamberBorchestra
09-26-08, 03:18 PM
Wouldn't it be possible to sequentially load a sequence of materials to apply, and then have them advance through time or another means?

kursadk
09-26-08, 03:22 PM
I am not a zscripter but that should be possible. In the end probably the user would not want to cycle all the materials, rather a select list of materials would be great. Also a nice interface can be neat as well which would streamline this.

Svengali
09-26-08, 04:15 PM
What is a material cycling script? Can you describe what it would do or how it would function?

kursadk
09-26-08, 04:22 PM
Well, basically it will change the active object`s material squentially. So instead of clicking material menu and clicking on materials to try materials one by one, this way user will just press the same key to cycle through predefined set of materials

marcus_civis
09-27-08, 01:13 AM
That's not too difficult to do if you use the ZFileUtils [see the sticky thread at the top of this forum] to get the files in a folder. Here's a basic script, though you may want to adapt for your needs.

Note that the dll should be in its own data folder.

EDIT: I added in a default settings so it will reload the last used list.

EDIT2: Plugin operation - buttons in the Material palette. Code included.

Christian Michelin
09-27-08, 03:07 AM
God ,YES!!!! :D
You did it!
This is so helpful,I'm always baking zbrush shaders in my texture works
and I'm not always sure which shader is better ,so not being forced to
click on each of them is awesome
(especially when you got hundreds of them) .


I think you should post it in the zscript utilities forum,it's
something that I'm sure a lot of people baking shaders would find useful.
Thanx again !

marcus_civis
09-27-08, 03:23 AM
Hello Christian, :)

I updated the script to save the last used folder, so download again. :)

Perhaps I'll make into a plugin if it would be useful.


EDIT: if you change the 'fileMax' value (to say 300 instead of 100 so as to cycle thru more mats) you will need to delete the 'settings.zvr' file in the LoadMatsData folder or you'll get an error.

Thanks,

Svengali
09-27-08, 07:33 AM
Nice. A button pair similar to these might be useful added to the ZMats library plugin too. Maybe I'll try an update after 3.5 arrives and we see what else Pixolator has in store. :D

Sven

kursadk
09-27-08, 09:49 AM
hmm, I am getting an error. It says its skipping loadmats due to error.

kursadk
09-27-08, 09:58 AM
Btw, how do you use this tool? I think I have managed to load the script fine(through zscript menu this time), but I do not see any button anywhere?

Svengali
09-27-08, 10:47 AM
With a model in edit mode, click on the handle at the bottom of the screen (opens the tutorial window) and the two buttons become visible. First click Getfolder and select the materials directory and choose a material, then click Cyclemats to loop through the other materials.

kursadk
09-27-08, 11:37 AM
That is exactly what I am talking about!! Amazing, life is easier now. :cool:

kursadk
09-27-08, 11:41 AM
Marcus
when you have time, one more addition would be helpful actually. It would be nice to have another button for calling the original shader. So the user would not deal with material window again ::)


Svengali, thanks for the help. It was nto very obvious for me for some reason :)

ok here is a better wish list for next possible update if you will :)


-Previous-next material buttong (so that one can go back and forth hopefully)
-Folder profiles. I guess you would put one button per folder. I would think that 5-6 profiles should be sufficient
-Button for calling the original shader

This is great Marcus, seriously this was bothering me for a while. I hate the material window :( I mean It is nice, it has nice preview but it was not working well with a shortcut. Thanks again

marcus_civis
09-27-08, 01:42 PM
kursadk,

I'm glad you found the script useful. I intended it as an example of what might be done rather than a solution. I may develop something similar at some stage but I'm too busy to take this further at the moment. Should you or anyone else like to try then you are free to do so.

kursadk
09-27-08, 01:49 PM
Here is first bug report. After first use, the buttons disappears from the tray. I do not have clear step to reproduce but I need tor restart to bring it back again.

kursadk
09-27-08, 01:50 PM
Thanks for your help! I am not a scriptter so this would be out of my league but I hope that someone might pick it up from here.



kursadk,

I'm glad you found the script useful. I intended it as an example of what might be done rather than a solution. I may develop something similar at some stage but I'm too busy to take this further at the moment. Should you or anyone else like to try then you are free to do so.

spaceboy412
09-27-08, 02:28 PM
kursadk, the buttons are disappearing most likely because you are using another zscript or a plugin, zbrush only allows one at a time(something that i think is a major flaw and really could benefit from being fixed).

kursadk
09-27-08, 04:48 PM
I see, it makes sense. Is it possible to run this script without button, only through shortcut maybe?

marcus_civis
09-28-08, 01:44 AM
OK, I've updated the script to operate as a plugin. Unzip to your hard drive and copy the files and folder to you ZStartup/ZPlugs folder. Make sure the unzipping doesn't create an extra folder. The .zsc & .txt files, and the data folder with the dll inside, should be in the ZPlugs. Restart ZBrush and you will find the buttons at the bottom of the material palette.

You can move the buttons to the interface if you want by following intructions for customizing the interface here (http://www.zbrush.info/docs/index.php/Changing_the_Interface_Layout). You can also assign hotkeys by Ctrl+clicking on the buttons.

I've refined the operation for moving forward and backward thru the list. If you have a model in Edit mode and wish to be able to return to the original material, switch to a different material in the material palette before using the plugin. That way you can reselect your original mat from the palette as needed.

Christian Michelin
09-28-08, 04:27 AM
Foward and ....backward!
Great! :D

kursadk
09-28-08, 08:08 AM
Marcus thank you so much, I will try asap.

Do you accept paypal donations? :)

kursadk
09-28-08, 08:52 AM
I do not see a website , page to send you paypal donation?

marcus_civis
09-28-08, 10:02 AM
kursadk,

This is generous of you but there is really no need. I'm employed by Pixologic to help out here, specifically to answer zscripting questions. Although I can't always provide scripting solutions, in this instance I had been working on something similar so it was straightforward to adapt the code.

Thanks,

kursadk
09-28-08, 10:28 AM
Marcus,

This script officially rocks! I know you said you would not have time for fine tuning but seriously I am very grateful that you have refined it.


Thanks for explaning your position on donations.

spaceboy412
09-30-08, 11:09 PM
marcus this is pretty awesome and something i wanted as well for awhile, i've hit a snag, right now i have 479 mats in my material folder, but for some reason it only reads 222 of them, only from mats named A to M. as you said in another thread i changed the zscript to have 600 max instead of 100, deleted both the settings.zvr, and the LoadMats.zsc (reloaded the .txt to make a new one, should i have not done this?EDIT: i reinstalled that file and still no change).

marcus_civis
10-01-08, 12:20 AM
spaceboy,

I've no idea why you should be getting this problem. I just tested with over 260 materials and although I didn't cycle thru them all they appeared to load OK.

When you select the folder what number is shown in the NoteBar [progress bar] as the files are read? (If you have other files besides materials in the folder then this number will reflect that.)

And when you load a material what number is given as the total in the NoteBar?

spaceboy412
10-01-08, 12:44 AM
all i'm seeing is "1/222 2tone_clay loaded" this will change if i change the mat to 2/222, etc. if it says something when i first run the script its going way to fast to be read. also i tried selecting a mat after Marble which was the last one it was doing, it still only reads the first 222, not any after that even if i try to start it at them, hope the makes sense. is this only for Matcaps? or for all mats?

BTW i have only 30 files in that folder that are not matcaps, but they are jpgs or .zlights

spaceboy412
10-01-08, 12:52 AM
okay i removed everything that wasnt a mat in that folder and now it reads as 1/237
so it went up but still not all the mats, barely half.
EDIT:
just to note, i selected all the mats from the name of the first one its giving me and the last and in my folder that comes out to be 254, so its definitly dropping some. also still only stopping halfway through the alphabet.
EDIT AGAIN:
i found out which of the above it was skipping, it seems they were named M_blue etc, i removed the underscore and reloaded the script and the missing ones showed up, its still topping out at 242 though.
LAST EDIT b4 i go to bed:
i removed all mats that had _ in them, now it tops out at 257.
is it possible i didn't edit the txt file correctly, there was only one number to change correct? this one:
[VarDef,fileMax,600]

even stranger if i have it look at the folder that has all the mats with _ then it finds them all, but there are only 151 of them. strange

marcus_civis
10-01-08, 01:57 AM
I don't think you've done anything wrong with editing the code. What may be causing a problem is that for some reason the material files are not been identified correctly. Try this version to see if it makes any difference (I've edited the fileMax already).

spaceboy412
10-01-08, 02:03 AM
if i do it on a folder with no _ files it stops at 250, a to o.
if i do it with the _ files mixed in it reads 242, a to m.

spaceboy412
10-01-08, 02:19 AM
okay i also tried this, i removed all my other plugins. same result.
with above removed i renamed all my mats (copied them first of course) to something like : 1 (1).ZMT, 1 (2).ZMT, etc.
now it will read 342 out of 475 materials. so getting there but who knows what the issue is.

(i accidentally deleted 4 mats somewhere in all of this, oh well)

marcus_civis
10-01-08, 02:33 AM
It's seems like it's a file recognition issue but I've no idea why it should go so far and stop like that. It's an odd one. Probably the simplest thing is to have fewer materials in a single folder. :)

kursadk
10-01-08, 08:08 AM
Marcus,

DO you think that I can duplicate this script file and give a different name to use it as seperate profile? I know you do not have time so I do not want you to spend more time on this. What I want is to have 4 5 different profiles. So I am hoping that I can duplicate this script 5 times give different names(also the settings file) and have seperate shortcuts for all profiles. This way I can have clays, metals, rocks as seperate profiles etc Does it sound like a stupid idea? :)

spaceboy412
10-01-08, 06:11 PM
marcus just wanted to give you an update, i renamed the files again with the simple 001.zmt 002.zmt etc. naming convention and it did finally recognize them all, guess it didn't like those (). i then attempted to use the above naming along with the files original names but once again it didn't work correctly. this is unfortunate. i agree about using less mats as well, these were just my 3.1 mats not even including all the z2 mats, haha. sigh.

marcus_civis
10-02-08, 12:34 AM
kursadk,

That would be possible but duplicating everything would be unnecessarily complex. Here's a solution which perhaps will solve your issue. Again this was code I had elsewhere and perhaps other zscripters will find it interesting.

This saves a 'last used list' of folders (10 maximum) so by clicking on the folder in the list it is moved to the top and becomes the current folder. The folders are scanned when selected so you don't have to worry if you have added files.

spaceboy412,
I'm not surprised that it was a naming problem, though I don't know where the issue arises. I'll do some more testing. Meanwhile you might find this latest version helpful too.

EDIT: Delete the previous install before installing this version - it allows for 200 materials in a folder.

HTH,

kursadk
10-02-08, 08:04 AM
Thanks Marcus, I will try.

I use direct folders as an explorer extension. It works especially great to browse folder and file history in ZBrush open-save dialog. It is free for personal use give try, it is amazing.

http://www.codesector.com/directfolders.php

spaceboy412
10-08-08, 09:23 AM
i just wanted to note a somewhat strange behavior. say i select one of my mats using the plugin, and they are numbered, so for example i use #42, i then do some sclupting etc. now say i want to go to mat #43, when i hit the mat> button it starts at #01 again. is there a way to fix this? or have a slider along with the buttons?

marcus_civis
10-08-08, 10:26 AM
i just wanted to note a somewhat strange behavior. say i select one of my mats using the plugin, and they are numbered, so for example i use #42, i then do some sclupting etc. now say i want to go to mat #43, when i hit the mat> button it starts at #01 again. is there a way to fix this? or have a slider along with the buttons?

It's because the index is not being stored, so if you use another plugin the index reverts to 0. Try this version (just put the file in the ZStartup/ZPlugs). I've not tested so if you get any errors, let me know.:)

kursadk
10-08-08, 10:32 AM
Marcus thanks for the update. I actually liked old behaviour, at the same time I was having the same issue spaceboy was having. In that respect can I use these 2 (new and old version) as seperate plugins? I just want them to show up in the material menu as seperate plugins :) So that I can assign different shortcuts to them.

spaceboy412
10-08-08, 11:27 AM
thanks, so far that seems to be working after a quick test. i like the folder addition as well.
one change i noticed is that you cannot go back from your first mat to the last, like a loop, but this is not really a big deal.
could a slider be added to this to save on hundreds of clicking, much like the normal mat slider?

marcus_civis
10-08-08, 01:10 PM
kursadk,

This is possible but quite a bit must be renamed so as not to cause conflicts or errors.

spaceboy,

You should get a loop so that if you press the backwards arrow it goes from 1/12 to 12/12 (with twelve mats). I suppose you could add in a slider but I think I've done enough on this particular script. :)

spaceboy412
10-08-08, 02:28 PM
ah!, sorry marcus, i had forgotten to change the max number of mats so that's what was wrong.
too bad about the slider, i looked into it myself but i just don't get it. thanks for doing so much on this.

marcus_civis
10-09-08, 01:33 AM
Slider added. :cool:

spaceboy412
10-09-08, 04:35 AM
super thanks marcus :tu: :tu: :tu:
works like a dream!
i'd also like to say that although this isn't one of the huge plugin releases it still is just as valuable.

kursadk
10-09-08, 08:59 AM
Marcus: :)

kursadk
10-09-08, 12:22 PM
It works great! Stop working on it! I know you just cannot help :)

marcus_civis
10-09-08, 12:46 PM
It works great! Stop working on it! I know you just cannot help :)

Yeah, I zscript in my sleep. :) Glad it's useful.

kursadk
10-12-08, 10:40 AM
I just saw the extra material folder slots. This is more than awesome. Thank you Marcus, I am now your humble servant, you can ask for 3 wishes!