ZBrushCentral

Q: saving variables to file over network

Hi

So I made a tool to manage camera’s etc. that saves out the camera’s info fine locally but for some reason when you want to save the .zvr file over the network it does not save, but also does not give an error.

This is the chunkc of code:

[VarDef, transforms(45),0]

[IButton,[StrMerge, “Zplugin:”,toolName,":",“Export Cam’s”],
[VarSet, camPath, [FileNameAsk, “ZVR(.zvr)|.zvr”, “File name”, “Title name”]]
[MessageOK, camPath]
[VarSave,transforms, camPath]
,.5]

Any advice how to make tool more robust over network as well?

Thanks

I just want to add that it seems that the file gets saved in the same location as the plugin which only happens when you save on network not local.

You could try using [FileNameResolvePath, camPath] after you’ve selected the file location. That might help.

Thanks Marcus, tried that but did not seem to work. It has something to do with the formatting of the file path I think but no idea how to debug it yet

@marcus_civis

still haven’t figured this one out: (code below)

Exporting the render over network is fine and the message that displays the path is exactly the same but for some reason the one is not working correctly. Any help on how to debug this would be great :slight_smile:

[VarDef, transforms(90),0]

[IButton,export,

[VarSet, camPath, [FileNameAsk, "","File name" , "Title name"]] [Note,camPath] [Note,[FileNameExtract,camPath,1]] [VarSave,transforms,camPath]

]

[IButton,export render,

[VarSet, renderPath, [FileNameAsk, "","File name" , "Title name"]] [Note,renderPath] [Note,[FileNameExtract,renderPath,1]] [IPress, Render:BPR RenderPass:Render Best Preview] [FileNameSetNext,[StrMerge, renderPath,_,01,.PSD]][IPress,2206]

]

Unless the file extension is not getting added - and ZBrush probably adds it anyway with VarSave - I can’t think of what might be the problem.

I suggest you try a different method, using a memory block to store the transforms:

[MVarDef,CN_Transform_Mem,90,0]//create memblock for 10 transforms
//get values
[VarSet,i,0]//index for transform
[VarSet,offset,i*9]//offset for transform memblock
[MTransformGet,CN_Transform_Mem,offset]//get the values starting at the offset

//save the memblock to file:
[VarSet,camPath,“F:\My_Folder\TransformsMem.dat”]
[VarSet,err,[MemSaveToFile,CN_Transform_Mem,#camPath,1]]//overwrite if file exists
[If,(err <=0 ),[Note,“Error saving to file”]]

//to load the file into memory:
[MemDelete,CN_Transform_Mem]//make sure not around
[VarSet,err,[MemCreateFromFile,CN_Transform_Mem,#camPath]]
[If,(err <=0 ),[Note,“Error loading from file”]]

Excuse my ignorance but the first part after the memblock creation I am clueless to why there is offsets happening.

this part:
//get values
[VarSet,i,0]//index for transform
[VarSet,offset,i*10]//offset for transform memblock
[MTransformGet,CN_Transform_Mem,offset]//get the values starting at the offset

I will implement the above just want to understand it a bit better.

Just some context:
What I currently have is 10 slots where I store camera info (rotation/scale/position), this info gets saved on disc from the moment you set camera’s because the data gets lost when you use another plugin, maybe there is a better way. If you don’t specify where you want to save it, it does it in the location where the plugin is located. Otherwise it uses the path specified,importing the transform info over a network also gives me a error. I think the network editing and combination of “//” in the path location is causing something to go wonky. I am thinking alternatively to copy the transform.zvr file to the location as a alternative but will probably run into the same issue.

It is probably me and if your interested in going through a lot of code (I wouldn’t recommend) then I can send it to you.

Thanks

The memblock CN_Transform_Mem is just a chunk of memory so you need to specify where in the block you want to save or recall your values - that’s the point of the offset. So, the first “slot” for storing the camera info (of 9 values) starts at offset 0, the next slot will start at offset 9, and so on up to the last slot which starts at offset 81. (Yes, I made a mistake and the offset should be calculated with i*9.):

[VarSet,i,1]//index for second slot
[VarSet,offset,i*9]//offset for second slot
[MTransformGet,CN_Transform_Mem,offset]//record the values for second slot

So you would just increment the variable i and repeat the code for the other slots. The same method can be used for setting the camera using MTransformSet.

If all you want to do is keep the values through a ZBrush session then with this memory block method you don’t need to save to disk as the memory blocks persist even when a different plugin is loaded.

Thanks Marcus, I think I made a typo with the i *10 :stuck_out_tongue:

Keeping the camera’s for the session is important but also for future use so exporting and importing them definitely needed.

Thanks so much for explaining this I will report back soon hopefully!

No, I corrected my mistake in my post! :o

haha sneaky