ZBrushCentral

How do I correctly place these "Then" commands after an "If" command.

In this macro I want to perform the lines in green only if the Transform:Move button is off.
How do I properly format this? as far as [ ] and or commas?
(this macro is not even loading so somethings wrong maybe not just the formatting)

Also the first green line or “then” command I want to do is to Invert Selection, I recorded a macro of control + shift + right click drag to do this, hence the long Canvas stroke line, is there any other text command for Invert Selection?

Thanks

[IConfig,4.73]
[IPress,Transform:Activate Symmetry]
[IPress,Transform:>X<]
[IUnPress,Transform:>Z<]
[VarDef,MoveMode,0]
[IGet,Transform:Move]]
[If,Movemode = 0
[CanvasStroke,(ZObjStrokeV03n23%p2390BA4pBF9BB2PnEC97n5AF6n-23DAsE154CFsE154CFsE154CFz-617=YH387V1E6K3XH386V1E6H385V1E6H384V1E5H383V1E4H381V1E3H380V1E2H37DV1E1H37CV1DFH37AV1DEH379V1DEH379V1DDH378V1DCH378V1DBH377V1DBH376V1D9H375V1D9H375V1D8H374V1D8H374V1D7H373V1D7H373V1D6H373V1D6)]
[IPress,Tool:Masking:MaskAll]
[IPress,Tool:Visibility:ShowPt]
]
[IPress,Transform:Rotate]
]

Hi Susan,

The macro isn’t loading because it doesn’t have any button code. You need the commands inside a button.

For the If statement, you need a comma after the “test”. It’s formed like this:

[If, /this is true/,
/commands if true/
,//else
/commands if false/
]//end if

So, using the code as you have it, you would need:

[IButton,???,“Pop up info about this macro”,

[IConfig,4.73]
[IPress,Transform:Activate Symmetry]
[IPress,Transform:>X<]
[IUnPress,Transform:>Z<]

[VarSet,MoveMode,[IGet,Transform:Move]]
[If,MoveMode = 0, // if Move mode is off then do the following
[CanvasStroke,(ZObjStrokeV03n23%p2390BA4pBF9BB2PnEC 97n5AF6n-23DAsE154CFsE154CFsE154CFz-617=YH387V1E6K3XH386V1E6H385V1E6H384V1E5H383V1E4H3 81V1E3H380V1E2H37DV1E1H37CV1DFH37AV1DEH379V1DEH379 V1DDH378V1DCH378V1DBH377V1DBH376V1D9H375V1D9H375V1 D8H374V1D8H374V1D7H373V1D7H373V1D6H373V1D6)]
[IPress,Tool:Masking:MaskAll]
[IPress,Tool:Visibility:ShowPt]
,//else Move mode is on
//commands for on would go here
]//end if Move mode
[IPress,Transform:Rotate]

,0.5]//end of button & macro

If all you did with the CanvasStroke is invert the mask then you could replace that line with:

[IPress,Tool:Masking:Inverse]

But note that you follow this with [IPress,Tool:Masking:MaskAll] which would cancel out the previous mask.

Marcus, thanks so much for showing me how to do that correctly.
It worked fine but I had a question about the notes you added in the complete macro below I highlighted in blue .

When the the Transform:Move button was found On I just wanted to skip the the green lines go to the last line of the macro. But if I just included that last line as part of the original IF command would it have been this (in blue):

[IPress,Tool:Visibility:ShowPt]
,[IPress,Transform:Rotate]
]
,0.5]//end of button & macro

Or do I need another “If” with in the original “If” like this this:

[IPress,Tool:Visibility:ShowPt]
,[If,MoveMode = 1, [IPress,Transform:Rotate]
]
,0.5]//end of button & macro

Also just to clarify. The canvas stroke in the macro that I was asking about was not for a Mask Invert but for a Invert Selected, where I have some objects hidden and I want to show those and hide the visible ones. I was wondering if there was a text command for that? I don’t think there is any UI button for that, The only way I know perform it is to Ctrl + Shift + Click and drag background.

Thanks


[IButton,???,“Pop up info about this macro”,
[IConfig,4.73]
[IPress,Transform:Activate Symmetry]
[IPress,Transform:>X<]
[IUnPress,Transform:>Z<]
[VarSet,MoveMode,[IGet,Transform:Move]]
[If,MoveMode = 0, // if Move mode is off then do the following
[CanvasStroke,(ZObjStrokeV03n23%p2390BA4pBF9BB2PnEC 97n5AF6n-23DAsE154CFsE154CFsE154CFz-617=YH387V1E6K3XH386V1E6H385V1E6H384V1E5H383V1E4H3 81V1E3H380V1E2H37DV1E1H37CV1DFH37AV1DEH379V1DEH379 V1DDH378V1DCH378V1DBH377V1DBH376V1D9H375V1D9H375V1 D8H374V1D8H374V1D7H373V1D7H373V1D6H373V1D6)]
[IPress,Tool:Masking:MaskAll]
[IPress,Tool:Visibility:ShowPt]
,//else Move mode is on
//commands for on would go here
]//end if Move mode
[IPress,Transform:Rotate]

,0.5]//end of button & macro

Yes, that’s right. The [If command is for true or false tests and has parts for when the answer is true and when it’s false. You don’t need to put code in both parts but they’re there if you need them. So if you wanted to turn on Rotate mode only if Move mode was on your top code would do it. The [If statement in your second bit of code isn’t necessary because ZBrush already knows that you want that code to run if Move mode is on.

And apologies for confusing mask and selections! I obviously wasn’t paying close enough attention. :frowning:

You can simulate a SHIFT+CTRL+drag in zscript using a combination of IKeyPress and CanvasClick. The CanvasClick is done a long way off the canvas so it is sure to be on the background. The IFreeze is just to make it look smoother.

[IButton,???,“Pop up info about this macro”,
[IConfig,4.73]
[IPress,Transform:Activate Symmetry]
[IPress,Transform:>X<]
[IUnPress,Transform:>Z<]
[VarSet,MoveMode,[IGet,Transform:Move]]
[If,MoveMode = 0, // if Move mode is off then do the following
//invert the selection
[IFreeze,

[IKeyPress,CTRL+SHIFT,[CanvasClick,-4096,-4096,-4096,-4000]]

]
[IPress,Tool:Masking:MaskAll]
[IPress,Tool:Visibility:ShowPt]
,//else Move mode is ON
//commands for ON would go here
]//end if Move mode
[IPress,Transform:Rotate]

,0.5]//end of button & macro

HTH,

Yes, very helpful thanks.

One last question, in reguards to:

The CanvasClick is done a long way off the canvas so it is sure to be on the background.

Do the canvas clicks have to be within the document size you are using?
In other words if you run a macro that has a canvas click that is out side the outer edge of your loaded document will the macro still run?

Thanks

Used like this, the CanvasClick will work with any document size. The coordinates used relate to the canvas, with the top left being (0,0), so (-4096, -4096) will always be well off which is what is needed here. But CanvasClick can be used for other things and then the document size might need to be taken into account.