ZBrushCentral

Edit: Problems with using Routines

I’m sorry to come back at my hilarious ‘discovery’-thread. ZB or I must have been very confused the moment I wrote that one, but the recursive routinecall does not work either. And to make things worse: I do not get the non-recursive Routine working. See my example; I can not figure out what I’m doing wrong.

So please some help from the masters?
EddyL

[VarDef,extrudemasked,0]
[VarSet,extrudemasked,0]

This code I use for the Def:

[RoutineDef,MakeSkin,
[IPress,Tool:Masking:Clear]
[IPress,Transform:Draw Pointer]
//extruded is actief, nog niet geexporteerd
[TransformSet, (Document:Width*.5), (Document:Height*.5), 0, 100, 100, 100, 0, 0, 0]
[FileNameSetNext,“ZBRUSH_ZStartup\ZPlugs\Temp\extruded.obj”]
[IPress,Tool:Export]//gecentreerd extruded bewaard
[FileNameSetNext,“ZBRUSH_ZStartup\ZPlugs\Temp\original.obj”]
[IPress,Tool:Import]
[TransformSet, (Document:Width*.5), (Document:Height*.5), 0, 100, 100, 100, 0, 0, 0]
[FileNameSetNext,“ZBRUSH_ZStartup\ZPlugs\Temp\original.obj”]
[IPress,Tool:Export]//gecentreerd original bewaard
[IPress,Tool:Clone]//original in Tool-tray
[FileNameSetNext,“ZBRUSH_ZStartup\ZPlugs\Temp\extruded.obj”]
[IPress,Tool:Import]//extruded actief
[ISet,Tool:Unified Skin:Resolution,128]
[ISet,Tool:Unified Skin:Smt,40]
[IPress,Tool:Unified Skin:Make Unified Skin] //krijgt automatisch de naam: Skin_extruded
[IPress,Tool:Skin_extruded] //De Skin_extruded is the active tool now
[IPress,Tool:Subtool:Append]
[If,([IExists,Tool:original]=0),
[MessageOK,“geen original in Tool-tray!”]
,//else
[IPress,PopUp:original]
[IPress,Transform:Activate]
[ISet,Draw:Focal Shift,-100]
[ISet,Draw:Draw Size,40]
[MessageOK,“Mask (Ctr+LMB) the extruded Part of the ‘skin_extruded’ with some margin into the original area; Only then Press:NewSkin again.”]
[IPress,Transform: Move Edit]
[VarSet,extrudemasked,1]
]//endif
,extrudemasked
]

This code I use for the Call:
[RoutineCall,MakeSkin,extrudemasked]

Eddy,

I’ve not looked at your code closely but I notice that you have a global variable when there should be a local variable as argument for your routine. If you use a global variable in a routine there is no need to specify it as an argument. Take out the argument from RoutineDef & RoutineCall and I think all should be well.

Replace:


[RoutineDef,MakeSkin,
//commands...
,extrudemasked
]

with:


[RoutineDef,MakeSkin,
//commands...
]

And replace:


[RoutineCall,MakeSkin,extrudemasked]

with:


[RoutineCall,MakeSkin]

Hi, Marcus,

I come back to this thread, because it would really be handy for my new plugin, NewGeoExtrude, to be able to [IPress,ButtonX] from within the commands that belong to this same ButtonX. So I want to come back to ButtonX, I can ask the user to do that of course, but that means another mouseclick (on this ButtonX) and I want to make the plugin work with the least possible Button-clicking.

I hope I am clear and do not ask for the impossible.
Greetings, EddyL

Eddy,
I think that there is a restriction on using recursive behaviour of the type you describe so as to avoid endless loops (and so tying up ZBrush and the CPU for ever). This means that you’re likely to get a ‘too many inputs’ message if you attempt anything along those lines and your zscript will fail.

Whether you can find a solution will depend on exactly what you are trying to achieve but if you simply want to repeat an action until a particular state is reached then generally using an [If… statement and a loop will work perfectly well.

HTH,