ZBrushCentral

How to identify interface by their type

Hi there , anyone here know how i can with no false result, to identify the type of an interfaces of a given path, like ibutton, iswitch or islider.
I make a sort of logging tools and I need that stuff,.
I tried with different method, here is the code :

[VarSet, type, "not defined"]

[If, [IExists, winid],
	[VarSet, info, [IGetTitle, winid,1]]
	[VarSet, status, [IGetStatus, winid]]
	[VarSet, max, [IGetMax, winid]]
	[VarSet, value, [IGet, winid]]

	[If, value > 1,
		[VarSet, type, "Slider"]
	]
	[If, value == 1,
		[VarSet, type, "Switch"]
	]
	[If, value == 0,
		[VarSet, type, "Button"]
	]
	,//else 
	// nothign
]

Oh I have another quick question :
how to make a note interface that do not have the frame border and the blink red icon in top left corner. And how to display it on the side of the canvas, just like Subtool Master plugin, I give it a try but didn’t found a way to remove that frame :thinking:

Nicolas

Hi Nicolas,

There’s not an easy way to do this that I can think of. I suppose you could test each item but you’d need to undo in some circumstances. For example:

    [VarSet,state1,[IGet,path]]
	[IToggle,path]
	[VarSet,state2,[IGet,path]]
	[If,state1 != state2,[Note,"It's a switch!"],[Note,"It's not a switch!"]]

For the NoteInterface UI, it uses a large transparent button that covers the UI and then the other buttons are placed relative to that. Attached is an example.

NoteInterface_example.zip (19.8 KB)

HTH,
Marcus

1 Like

I think you can also assume that

[If,[IGetMin,itemID]==0 && [IGetMax,itemID]==1,

it’s a button or a switch. It’s possible that there are sliders with a min value of 0 and a max of 1 but I don’t think there are very many of them, and you could always check for those as special cases (if you can locate them!).

-Marcus

Hi Marcus thx for the quick help.
well about the note interface, i though i didn’t not get it, but now it makes senses somehow.
on the main topic, yeah i already tried to use igetmax/min to know if it a slider or not.
If i found a more reliable way to identify by the type of UI item, then i will update this post.

Nicolas

Hi There !

@marcus_civis, I finally got more time to work with note interface, and thank you alot again. it works well.
Either I am trying to load an image for the [INoteButton], but it seems to not working like with [IButton] where the image path can be the path of a ZBP file. I tried different methods but none seems to work. is there any way i can get the brush icon image. or extract the image so I can load it in a different fashion ?

Nicolas

Hi Nicolas,

This works for me (change to relevant lines in the above example):

[NoteIButton,"Do It"/*text*/	,	"ZBRUSH_ZBrushes\Clay\ClayFinish.ZBP"/*image*/	,/*pressed?*/	, /*disabled?*/,hPos /*HPos*/,vPos /*VPos*/	,	 /*HSize*/	, /*VSize*/	, butnCol /*color*/	, butnTxt	/*text color*/,	/*opacity*/, /*text opacity*/	,	 /*image opacity*/	]		
[VarAdd,vPos,110]		
[NoteIButton,"Exit"/*text*/	,	/*image*/	,/*pressed?*/	, /*disabled?*/,hPos /*HPos*/,vPos /*VPos*/	,	96 /*HSize*/	,	vSize /*VSize*/	, butnCol /*color*/	, butnTxt	/*text color*/,	/*opacity*/, /*text opacity*/	,	 /*image opacity*/	]		

HTH,
Marcus

oh yeah it works with ZBRUSH_FOLDER as prefix, but not with full path that contain backslashes :thinking:
so that works well now that so great, so I can even use pure black as alpha, but on the top edge of the image I can see a pixel black line you know how to fix that ?

I got another question for you Marcus :stuck_out_tongue:
Can we store a string using MVarDef, MVarSet, MVarGet ?
usually I read a file with MemReadString, but this time I’d liked to store some strings into a mem block which is accessible with [MVarSet]. and when i iterate with a loop on that memblock, it returns the index (1,2,3,4,5,6,7,8,9,10,etc…) and no string.

I also tried to do that for another macro and I failed at making it work , but that wasn’t as crucial as it is now with the new project.

I can’t to thank you enough for the assistance you provided in the past, and you are still there and you help is greatly appreciate Marcus, so thank you again for being around :slight_smile:

Nicolas

Hi Nicolas,

I don’t know why your image file path doesn’t work with backslashes. It does for me - I just used the ZBRUSH folder so that the code would work for you. You could try forward slashes, and remember to use quotation marks in case the path has spaces. Also [FileNameResolvePath] for relative paths.

You can’t use MVarDef etc. for strings because when using those commands the memblock is divided into 4 byte offsets for storing floats. (Strings will take a variable number of bytes up to 256.)

Thanks for the kind words - I’m glad you find my answers useful! :slight_smile:

-Marcus

Hi Marcus,
I don’t know too, but i did not took too much time investigating on that.
Okay nice to know that about MVarDef/Get/Set.
is there anyway to store a string in a float using zscript ?
I wondering what kind of algorithm to apply to do that.

Nicolas

ooh i forget to ask you if you think it’s possible to display the icon of a specific subtool into a note interface ?
and hmm another one :smiley:
can you exit a note interface by click out of the note, but how to do that when the note got the size of the Zbrush interface but the main note is note visible ?

about my question for exiting the note interface. I made the very first INoteButton being not disable so i can cover the whole zbrush window and i can exit without to press any INoteButton items.
I had some hard time to make it cover the full interface we can still see the white button borders, but when you click on it the effect applied on pressed button flash I bit too much,
i thought it would be possible to lessen the effect playing with the opacity but it doesn’t work.

Nicolas

Hi Nicolas,

  1. Storing a string in a float: I suppose it might be possible to add ascii values together somehow but you’d only be able to store a very short string.
  2. Displaying the subtool icon: No, this isn’t available to zscript, sadly.
  3. Clicking outside of a note to exit a Note Interface: the only way is to make the background NoteIButton enabled. As you have found, this produces display issues. Personally, I think a better way is to set up your NoteIButtons so that pressing the Enter key will exit. You do this by making sure all values other than the specific buttons lead to exit, something like:

[If, (result < 2)||(result > 3), [LoopExit]]

where “result” is the NoteIButton that has been clicked.

HTH,
Marcus

Okay thank you,welli just wanted to convert from string to float to sotre in mvarsdef, but yes on 4byte you can’ to store a huge value, i guess memwrite on signed long type, but anyway it no more something that could work with mvarget/set, so nevermind about it and I already made something so i can still store string with varsave/varload and it works well.
i thought the var array would be global variable but it’s great that using it locally remove the data from the memory stack.

Sad yes, it would have been so great with the current project, but anyway i will only display the name as label on my notes interface :slight_smile:

Yes but finally i do prefer to not have to press a key, but just click somewhere on screen to exit even with that button animation, but i will have a global settings so in the end the user can change this behavior.
actually i don’t display the note in a loop, it s a one shot and it closes the ui.
but depending of the menu i want to display, I will have redraw the ui after pressing any item from the interface.

this is what i am working on if you want to give it a look :slight_smile:
thank you Marcus, i will post another question soon :stuck_out_tongue:

Nicolas
smart-ui

1 Like

That looks very cool! Nice work. :+1:

nice that you like it Marcus :slight_smile:
it will come with more consistent workflow, but the base is almost complete.

so here come the next question ! :stuck_out_tongue:
I have some issue to determined, depending of the custom ui the size height and width, of the floating menus.
do you know any way to define precisely about these values ?

because the height and width of the canvas includes the floating menus( the blue rectangle on screen represents the size of the canvas)
and each floating menu around the canvas can have different size depending of the custom ui.
I wonder if that would be not better to add two slider so we can set the gap manually, what do you think ?

Nicolas

I also have a problem when i want to select a subtool by his path ( ex : tool:subtool:polymesh13) but if the subtool is off of the subtool list that is displayed within the UI, then I can’t to select the subtool.
so is there a way to do that ? i will have to use the name to get its index to move the scrollbar, but i am not sure how to do that.
on the side the project progress well :smiley:

ok i get it fixed for the issue with selecting a subtool by its title and for context which the subtool is off of the list.
so I went to this:

[VarSet, inc, 0]
    [VarSet, subToolPath, "Tool:Subtool:Polymesh3D8"]
    [SubToolSelect, 0]
    [If, [IExists, subToolPath],
        [IPress,subToolPath]
        ,//else
        [Loop, [SubToolGetCount],
            [ISet,"Tool:SubTool:SubTool ScrollBar",0,[SubToolGetCount]-inc]
            [If, [IExists, subToolPath],
                [IPress,subToolPath]
                [LoopExit]
            ]
            [VarInc, inc]    
        ]
    ]

EDIT : urf it looks like it works only if the subtool is after the current selected on in the list.
EDIT 2 : I just forget to select the very first subtool so the subtool i look for can’t be on top of the selected subtool.

EDIT 3 : instead of making a new reply i gonna ask for that one here

// sadly that do not works at all
// Zbrush  popup with a error message about 
// being unable to found the routines...
[RoutineDef, build_routines,
     [Loop, 50,
         [RoutineDef, [StrMerge, "button_", n],
             [VarDef, button_link(50),""]
             [VarLoad, button_link, "smart_ui_2020/data/link.zvr"]
             [If, DEBUG, [Note, [StrMerge, "button::",n,"::",button_link(n)]]]
             [IPress, button_link(n)]
        ]
     ,n]
]
[RoutineCall, build_routines]

So is there any reason why this doesn’t work , or am I doing something wrong ?
I have 50 routines that i use as templates and just that would save me to edit each templates at a time.

Nicolas

Hi Nicolas,

The height and width of the canvas does not include the floating palettes - if you look again at the NoteInterface example I posted at the top of this thread it uses the canvas size to place the buttons. It will always be 200 pixels from the left edge of the canvas whether the floating palette is showing or not.

For the build_routines, I guess ZBrush doesn’t like you creating routines at runtime.

-Marcus

Ok I get it working perfectly now, it was because of a missing inotebutton, one that cover the whole zbrush size in pixel, so all items positions was relative to that first note item.
sadly the offset on h and V was exactly the pixel size of the floating menu, that made me confuse haha :rofl:.

The build_routines do not run at runtime, the loop is a top level command, so it create the routines at the startup.

Now i got some issue with the use of varload, when the variable has a different size.
the issue i got is that with the way i code things, the result of the varload is most of the time equal to 0 even if the zvr file got dozen of variables

So here is a script for testing purpose, it generate randomly a size for the varlist,
and after i generate another random value, so i can test when both aren’t the same size
in some case it should matches but when the second random value is greater than the previous one when i run the code, it will fail telling me taht the variable type is not correct.
the objective with that is with the subtool toolbar I 'd added.
it check and rechek all subtool to gather each subtool names, but i want something that can compare if the subtool list has changed or not, because to generate all subtool names, even with that process encapsulated into an [IFreeze], let show on the ui (the progress bar on top), that it switches from subtool to subtool.
so it take long time and the subtool toolbar do not show up as fast as i d liked it.
and is the reasonf why i want to generate a key code, i want it based on the subtoolcount,
and a random value, that i will store in a varsave (zvr).
so what is you opinion on that you might have other suggestion to make sure the menu show the very last version of the tool and his subtools.

[RoutineDef, saveVariable,
    
    [VarDef, itemsList(items), ""]
    // [VarSet, x, 0]
    [Loop, items,
        [VarSet, text, [StrMerge, "item-", n]]
        [Note, text,,-1]
        [VarSet, itemsList(n), text]
        // [VarInc, x]
    ,n]
    [Note,]
    [VarSave, itemsList, path]
    // [MemDelete, itemslist]
,path, items]


[RoutineDef, init, 
    [VarSet, items, INT(RAND(5)+1)]
    [Note, [StrMerge, "random:: ", items,"\n"],,]
    [RoutineCall, saveVariable, "data/varsave.zvr", items]
]

[IButton, "???", "Save variable array on disk",
    [RoutineCall, init]
    [VarSet, count, [Val,INT(RAND(5))+1]]// 0 crash ZBrush
    [Note, [StrMerge, "random item count :: ", count,"\n"],,]

    [VarDef, itemsList(count), ""]    
    [VarSet, check, [VarLoad, itemsList, "data/varsave.zvr",1]]
    [VarSet, size, [VarSize, itemsList]]
    [Note, itemList(0),,-1]

    [Note, [StrMerge, "result::\Cff0000", check, "\n\Cffffff"],,-1]
    [Note, [StrMerge, "varsize::\Cff0000", size, "\n\Cffffff"],,-1]

    [If, count != size,
        [FileDelete, "data/varsave.zvr"]
        [Note, "values are different.."]

        ,//else
        // then do something
        [If, check == count,
            [VarLoad, itemsList, "data/varsave.zvr"]
            [Loop, count,
                [Note, "List :\n",,-1]
                [Note, [StrMerge, item >>, itemsList(n)],,-1]
            ,n]
            [Note,]
            ,//else
            [Note, "\Cffffffvalues are different.."]
        ]
        // [Note, "do something",,-1]
    ]    
]

Oh and a last one, hope i can complete everything without to ask for your help again and again :stuck_out_tongue:

so second question is abou tthe main Note interface frame, the thickness of the frame is too wide because of the blinking red light on the top left corner. IS there a way to reduce that gap ?
as the invisible button that exit the note interface, i d liked to have a value of 1 for hpos/vpos, but that do not work because of that icon, i tried to replace the note icon using the very last parameter, with a black 1px size icon, so i can turn its opactiy to zero, but unfortunately the gap is even bigger while I am trying to lessen it :stuck_out_tongue:

Nicolas

so to resume my previous question
why this never returns the right value ?

[varset, result, [varload, tempuser, "file.zvr"]]

Nicolas