ZBrushCentral

Error with Memory Block variables

Keep getting error not sure I added variable correctly :frowning: The script should save the current tool and ZTLs I open as variables then when pressed a 2nd time it should copy and paste current tools into the others.

[RoutineDef,Test,

//Create Memory Block to store which cycle the macro is on
[If,[MemGetSize,MP_ToolsCycleMemBlock ],
//Create and then set to 0
[MVarDef,MP_ToolsCycleMemBlock ,4,0]
[MVarDef,MP_ToolsCycleMemBlock ,3,0]
[MVarDef,MP_ToolsCycleMemBlock ,2,0]
[MVarDef,MP_ToolsCycleMemBlock ,1,0]
[MVarSet,MP_ToolsCycleMemBlock ,0,0] //CurrentCycle
]
[VarSet,CurrentCycle,[MVarGet,MP_ToolsCycleMemBlock ,0]]

//Get Subtool
[If,CurrentCycle==0,
//Save Current Subtool
[MVarSet,MP_ToolsCycleMemBlock ,1,[IGet,Tool:Item Info]]
[FileNameSetNext,“C:\Program Files (x86)\Pixologic\ZBrush 4R7\Testfolder\Test1.ZTL”][IPress,Tool:Load Tool]
//Save Test1 Subtool
[MVarSet,MP_ToolsCycleMemBlock ,2,[IGet,Tool:Item Info]]
[FileNameSetNext,“C:\Program Files (x86)\Pixologic\ZBrush 4R7\Testfolder\Test2.ZTL”][IPress,Tool:Load Tool]
//Save Test2 Subtool
[MVarSet,MP_ToolsCycleMemBlock ,3,[IGet,Tool:Item Info]]

//Go to 3rd variable and copy paste to other tools
[If,CurrentCycle==1,
[ISet,Tool:Item Info,[MVarGet,MP_ToolsCycleMemBlock ,3]]
[IPress,Tool:SubTool:Copy]
[ISet,Tool:Item Info,[MVarGet,MP_ToolsCycleMemBlock ,2]]
[IPress,Tool:SubTool:Paste]
[ISet,Tool:Item Info,[MVarGet,MP_ToolsCycleMemBlock ,1]]
[IPress,Tool:SubTool:Paste]
,]

[If,CurrentCycle>=1,
[VarSet,CurrentCycle,0]
[MVarSet,MP_ToolsCycleMemBlock ,0,CurrentCycle]
,
[MVarSet,MP_ToolsCycleMemBlock ,0,CurrentCycle+1]
]

]//Routine Test

[IButton,???,“Test”.
[IShowActions,0]
[IConfig,4.73]
//[IFreeze,
[RoutineCall,Test]
//]
,1,]

I’ve no time to test this out now but you’re not declaring the memory block correctly - you only need to do it once:

//Create Memory Block to store which cycle the macro is on
[If,[MemGetSize,MP_ToolsCycleMemBlock ],
//Create and then set to 0
[MVarDef,MP_ToolsCycleMemBlock ,4,0]
]
[VarSet,CurrentCycle,[MVarGet,MP_ToolsCycleMemBlock ,0]]

In the code above, MVarDef creates a memory block that will store 4 variables and it initialises them all to 0. So that’s all the code you need.

Thank that code fixed it, forgot 0 counts as one of the four numbers in the memblock