ZBrushCentral

Screen coordinates of interface items

Hi,

I’ve been trying to send the screen coordinates of a ZBrush interface item to a dynamic library, but I am failing at the last hurdle.

Using [IH/VPos,…] and [IWidth/Height,…] commands I can accurately detect the coordinates of a ZBrush interface item within the ZBrush window, but not the position of the ZBrush window itself. No problem. My script requires the user to activate it using a hotkey while the cursor is hovering over an interface item. I can instead send the coordinates as an offset from the ZBrush cursor position and make a system call to get the cursor screen coordinates from my dynamic library. Apply offset and voila! Everything works.

Except reading the [IHPos,…] of the Projection Master button, for example, results in the coordinates of the button in the Plugin palette, not the Projection Master button I was hovering over next to the canvas (in the default UI config).

Anyone come across this problem and solved it? I should mention that I have only tried this in the Mac version of ZBrush 4R5 but I do not imagine anything has changed in ZBrush 4R7P2 on PC.

Hi Mark,

Good to see you here and that you are still zscripting.

I remember coming across the issue you describe but I don’t think I found a solution. It was a while ago though and I’ll take another look. I’ll let you know if I find out anything useful.

All the best,

Cheers Marcus.

Yeah, just got back into zscripting recently. Trying to remember all the ins and outs, the idiosyncrasies, the gotchas, the dead ends and the unexplained commands (I am looking at you [IDialog,…]). It is like falling in love all over again :wink:

Take care,

unexplained commands (I am looking at you [IDialog,…]). It is like falling in love all over again :wink:

LOL. Welcome back, I look forward to what you might be cooking up. Ready to test :wink:

Thank you very much Doug. I am glad to be, as you put it, “back”. Hah. Back!

Don’t worry, I can follow your misconception. Perhaps because I was not active for a few years I was then “away”? But you need to realise, Doug, that none of us has ever truly been “away” or that we will ever be coming “back”. When we all signed up for ZbrushCentral I bet only a few of us read the small print or told others about it. I won’t bore you with the details but you and I are most definitely here to stay…we all are. Nobody leaves.

As much as the screams and tears of children fed the energy craving monsters of Monsters, Inc. so do the squeals of delight and laughter feed the overlords at Pixologic. They are through and through, truly evil people.

And that is all I have to say on the matter,

:smiley:

But seriously, thanks for the welcome back :+1:

Hi TVEyes, again I had exactly the same problem with ZSwatches. It seems that ZB’s always referring to the first instance of the button when you query its position (so that’s the one within it’s original palette)…

If you find a workaround for this, I’ll be very pleased to know it !!!

Have a nice day, try not to loose all your hair coding :wink:

Must be a way to ‘force update’ somehow. Maybe you’ll have to use a note interface? Lots of people would like this to work :wink: I made some color buttons with text on them, hack away at the code if you wish :smiley:

For my swatchs, I had to rely on reading the color under the cursor when you click to know which swatch was clicked :lol:.
That’s why you can’t have two times the same colour :lol:. But it gave a convenient way to reorganise the swatches (if the colour is already present, it swaps swatches positions). How hacky is that :lol:. And I won’t even talk about how I forced the interface to update the button’s image :o.

Please do :wink: code snippets always welcome :wink:

Hi KeuPon. Would love to hear how you forced the interface to update the swatch button. My method was also hack. It involved [IClose,…]'ing the subpalette which contained the button, which seems to remove it from memory. Then reloading the script ( I think from a secondary script ) which restored the button. Using [IClose,…] first ensures the button works when you reload. The only problem with this method is the ever increasing button ID. At some point, a couple of thousand ID’s later, ZBrush becomes unresponsive.

As for the original question it looks like a dead end. We can probably get the horizontal position but only if the palette the UI item belongs to, is NOT in the left or right tray. To do that you can [IShow,…] the palette which shows the palette, centered horizontally at the cursor position. Then it would be a matter of subtracting the cursor’s horizontal position from the palette’s and adding the relative palette horizontal position of the UI item in question. I don’t think that would work for the vertical position as palettes have variable height and might not even fit on the screen.

A theoretical solution then. Though I think there are too many variables for it to work reliably. So that was that. What are you all up to? Seen any good movies lately :slight_smile: