ZBrushCentral

Question: on Variables and FileNamegetLastTyped

Below is some code: It is erroring when I try to use a variable in an [IPress]
If someone could point out where I am in error. Help would be apreciated.

[varDef,canvasObject,""]
[VarSet,canvasObject,[FileNameGetLastTyped]]//Keep name of canvas object
[CanvasStroke,(ZObjStrokeV02n23=H-4DV-2DH-4Dv-2CC0H-4DV-2BH-4DV-29H-4DV-28H-4DV
-27H-4DV-25H-4DV-24H-4DV-23H-4DV-21H-4DV-1FH-4DV-1EH-4DV-1DH-4DV-1BH-4DV-19H-
4DV-18H-4DV-17H-4DV-16H-4DV-15H-4DV-14H-4DV-13H-4DV-12H-4DV-12)]
[IPress,Transform: Edit]
[CanvasStroke,(ZObjStrokeV03n2%P-4DP-2DPNNN-1s131780s131780s131780Z=YH-4120V-
40C8K4XH-4120V-40C8)]
[IShowActions,-1]
[IPress,Tool:PolyMesh3D]
[IPress,Tool:Import]
[varDef,sculptObject,""]
[VarSet,sculptObject,[FileNameGetLastTyped]]//Keep name of sculpt object
[IPress,Tool:SubTool:Append]
[IPress,[StrMerge, "PopUp: ",“canvasObject”]]
[IPress,Transform:Activate]
[IPress,[StrMerge, "Tool:SubTool: ",“canvasObject”]]
[IUnPress,Tool:Geometry:Smt]

Thank you in advance,

Rich Suchy

FileNameGetLastTyped will return a file name, its extension and its path. Unless you trim that to just the filename then canvasObject will lead to an error when you try to use it wherever a simple tool name is required, such as in [IPress,[StrMerge, "PopUp: ",“canvasObject”]].

You can do this by using FileNameExtract:


[VarSet,sculptObject,[FileNameGetLastTyped]]//Keep name of sculpt object
[VarSet,sculptObject,[FileNameExtract,sculptObject,2]]//extract file name
[Note,[Var,sculptObject]]// just to check that we've got the right name

If things don’t work as expected use a Note (as I have done above) to check the value for a variable.

HTH,

When my email didn’t seem to show up right away I assumed that there was some problem with my posting. :slight_smile: I plugged away at the code and, late last night, ended up doing exactly as you suggest!

You are dead on. My code is working now. There were lots of errors in leaving spaces in my [StrMerge] as well as using double quotes on the variable. GAH!

BUT I learned a lot.

Thank you for responding. Let me apologize, If I had seen that the post went through I would have saved you the effort.

Now I foresee a lot of zscripting in my future!

I’m glad you got it sorted. As you’re new to ZBC your first few posts will take a little while to appear as they are checked by a moderator (an anti-spam measure).

Good luck with the zscripting. If you encounter any problems, ask away. There are some regulars on these forums that are always ready to help.