ZBrushCentral

Question: controlling Subdirectory paths in ZScript

Thanks. :slight_smile: A pure zscript solution is preferable, of course because they work on either platform. I’m only just starting to learn VC++ .NET but I’d be very interested in any info you care to share. But you’d certainly need to compile a separate Mac dll using Code Warrior as Macs are bigendian.

I have a feeling that in order for this stuff to all work out, Pixelogic is going to have to make an OS test in their scripting so scripts know whick dll/File’s to use. …I mean, nothing HAS to be done by them but it would make it easier on everyone in the long run. There are always workarounds. May have to make script installers or something.

Oh well, just some silly ramblings…:rolleyes:

Chris Reid

We do the OS test ourselves through Zscripting. Using the [ZbrushInfo,…] command you can test which OS zbrush is running on. Then it is a simple matter of including 2 [FileExecute,…] commands in an [If,…] command.

Regarding passing variables to a dll, I will post some info a bit later on how to implement the numerical value and memory blocks in a [FileExecute,…] command.

Edit: Wrong thread. I posted the DLL info in this thread.

TVeyes,
Great to hear :smiley:

I should of done a bit more research before I typed. :cry: sorry

I have only been Z’ing for a week or so. I am sure there are plenty of functions that I havn’t stored in my little brain yet. So much fun so far.

I can’t wait to see how the numeric and memblocks work with FileExecute. I will play some more tonight, now that I got it workin with text.

Thanks again

Edited comment:
Here is TVeyes expanation of passing variables to [FileExecute]

Concerning Davey’s tip on an alternative way to define a filepath:

Here’s another tip: you can specify any path starting at the ‘top’ of the ZBrush folder tree: i.e. ‘ZBRUSH_ZData\ZPlugs\WebZPlug.dll’ specifies the ZData\ZPlugs\WebZPlug.dll path within the ZBrush folder.

Has anyone else been able to get this to work? I can’t, but don’t know what I’m doing wrong.

example:
[FileNameSetNext,“ZBRUSH_ZStartup\ZPlugs\myscript\myscript.zsc”]
[IPress,ZScript:Load]

This doesn’t do it. What am I missing?

Sven

Hi Sven,
Yes, I’ve used this but with forward slashes rather than backward:

[FileNameSetNext,“ZBRUSH_ZStartup/ZPlugs/myscript/myscript.zsc”]
[IPress,ZScript:Load]

(This is how it is given in Davey’s online code reference).

Cheers,

Thanks Mark,

I tried substituting forward slashes and still can’t get a clean result… However, as with many of the obstacles I run into with ZScripting, I figured out a work-around that took me about five minutes to get working.

I’m still upset I can’t get Davey’s tip to work as I’m thinking forward to other scripts where it might really be handy (and the only way to resolve path differences in user installations). :rolleyes:

Anyway, thanks for the pointer on the forward slashes. I’ll have to try out path designations in other scripts where I couldn’t figure out syntax that worked, (For example, the lame Load Dialog work-around I sent you…:stuck_out_tongue: )

Later, Sven

Sven,

AH, now I am worried - I use this in a script I’m working on and it’s pretty much essential. :frowning: Perhaps you would post a small sample zscript with the code that won’t work for you? Then we could test it and see what result we get.

OK, here’s a simplest version of what I’ve been trying to do:

PathTest1 runs PathTest2. PathTest2 runs PathTest1.
According to Davey’s tip, the paths should resolve using Zbrush_ZScripts/, but for me it does not.

Since both scripts are in the same ZScripts directory, I can change that one line of code in each script like this: PathTest1.txt to [FileNameSetNext,“PathTest2.txt”] and [FileNameSetNext,“PathTest1.txt”] and it runs, toggling between the two scripts.

// PathTest1.txt
// test of Davey's tip

// - - - - - run other script

[IButton,"runPathTest2","press to launch other script",
	[FileNameSetNext,"Zbrush_ZScripts/PathTest2.txt"]
	[IPress,ZSCRIPT:Load]
]

// PathTest2.txt
// test of Davey's tip

// - - - - - run other script

[IButton,"runPathTest1","press to launch other script",
	[FileNameSetNext,"Zbrush_ZScripts/PathTest1.txt"]
	[IPress,ZSCRIPT:Load]
]

Again, is there something I’m not seeing?

Sven

Hi Sven,

You are simply not writing in upper case when using the zbrush root directory reference. Normaly zbrush does not care about lower/upper case in directory names but in order for the zscript interpretor to recognise the zbrush root directory reference it must be in upper case. i.e ’ ZBRUSH_Zstartup/Zplugs/MyScript.zsc ’

Don’t kick yourself too hard :wink:

And interestingly the direction of the slash makes no difference.

Argh! UpperCase grem strikes again.

Thanks TV, I guess that makes sense in a ZScript sort of way. I’ve long since stopped kicking myself over ZScript, though. :smiley:

[edit: ignore me for a while, I need a break!]

Sven

Here’s another apparent gotcha that might be good to know.

Using the previous code examples of Script A calling Script B… and Script B calling Script A, (with ZBRUSH_ appropriately capitalized of course… )

Each time one script calls the other, there is a tiny bit of MEM creep - - when you run the two, toggling back and forth, you can watch the MEM numbers click up in the title bar. (ZSCRIPT:Record is turned off)

However, if the code in each is changed so each calls the .zsc version of the other, the MEM creep stops. My guess is there’s some slight, unrecoverable overhead when ZScript’s interpreter converts .txt to .zsc to run it?

Agreed this is a special case situation… I was having the scripts call each other in .txt form so edits during script development would be immediately effective. However the creeping choke-off was creating stability problems - at least that’s what I’d like to think was causing it. :slight_smile:

Anyway, this is just another of those “BTW” observations. Any comments or feedback appreciated, especially if your milage varies.

Thanks, Sven :smiley:

Sven,

That’s interesting. I recently suffered serious stability problems after repeatedly reloading a script I was testing. I thought I was going to have to reinstal ZB but then the problem went away by itself. I don’t know why. With slight trepidation I’ll test your scripts to see what happens…

The defaultzscript is not rewritten as a zsc, is it? Although that doesn’t mean it’s not converted in memory.

Hi there,

I recently started using Zscript and I followed this thread for a while now as I run into problems with Dialogues every now and then. I can’t help with the problem at hand, but I have a question and feel that it is not to far off topic…

I am working on a SaveDialogue for ztl.-Format with a custom File Path that I currently read out with FileNameGetLastUsed. The Path I read out is a subdirectory to the directory I want to save my Files to, so I have to return to the parent directory. On the first page of this thread TVeyes mentioned through the use of “…” in StrMerge this can be done. My attempt looks like this:

[StrMerge, [FileNameExtract, [FileNameGetLastUsed, ] , 1 ], “…”]

Instead of delivering the parent directory I end up with two additional points merged to the path. Did i get something wrong about this functionality? How do I cut the last part from my Path?

Thanks for all the great answers to this topic so far, already helped me out a bunch!

That doesn’t seem to work any longer… An alternative way would be to have a routine that searches for the second-to-last backslash and trims the path appropriately:

[RoutineDef,GetParentFolder,
[VarSet,pPath,[StrExtract,pPath,0,[StrLength,pPath]-2]]//trim off last backslash
[VarSet,index,[StrLength,pPath]-2]
[VarSet,lp,index]
[Loop,lp,//loop checking for backslash while decrementing index
[If,[StrFind,"",pPath,index]>-1,
[LoopExit]
]
[VarDec,index]
]
[VarSet,i,[StrFind,"",pPath,[Val,index]]]
[If,i > -1,
[VarSet,pPath,[StrExtract,pPath,0,i]]
]
,pPath]

[IButton,TestPath,
[VarSet,filePath,[FileNameExtract,[FileNameGetLastUsed],1]]
[RoutineCall,GetParentFolder,filePath]
[Note,filePath]
]

**Note that the output using the example above won’t show the backslashes as [Note] does not display them but the path will be correct. Also, if coding for MacOSX allowance would need to be made for MacOSX paths and forward slashes.

Thank you for your help! I still have to try it out, but I’ll reply if I encounter a problem with it.