ZBrushCentral

(solved):TransformSet problem

Hi again !

The more I script, and the more I encounter problems :slight_smile:

so this time I try to make a script which saves the current tool coordinates, then clear and resize the canvas, then puts the tool back three times in different angles.

but for some reasons, the transform set doesn’t work and nothing happens afetr the canvas resizing.

Here is the code :

[VarDef, VGCurrentGradientRate, [IGet, document:rate ] ]

[VarDef, VGCurrentWidth, [Iget, document:width ] ]
[VarDef, VGCurrentHeight, [Iget, document:Height ] ]

[VarDef, xPos, 0]
[VarDef, yPos, 0]
[VarDef, zPos, 0]
[VarDef, xSc, 0]
[VarDef, ySc, 0]
[VarDef, zSc, 0]
[VarDef, xRot, 0]
[VarDef, yRot, 0]
[VarDef, zRot, 0]

[IButton, “Tool:Vinny Tools:VSheet”, "Create a sheet ",

[TransformGet, xPos, yPos, zPos, xSc, ySc, zSc, xRot, yRot, zRot ] [Iset, document:rate, 0] [IUnpress, Document:Pro ] [Iset, Document:width, (VGCurrentWidth*3) ] [IUnpress, Transform:Edit ] [IPress, Layer:clear ] [Ipress, document:Resize ] [IPress, Zoom:AA half] [TransformSet, xPos, yPos, zPos, xSc, ySc, zSc, xRot, yRot, zRot ] [TransformSet, xPos, yPos, zPos, xSc, ySc, zSc, xRot, (yRot+45), zRot ] [TransformSet, xPos, yPos, zPos, xSc, ySc, zSc, xRot, (yRot+90), (zRot+180) ]

] //end IButton

I guess that the transformset cant, f9ind that last drawn tool, but how can i proceed in this case ?

Thx !

The joy of zscripting is finding the solution when things don’t work as expected. :wink:

The model can’t be transformed after a document resize because it’s out of Edit mode. You need to draw it on the canvas again and enter Edit mode, then apply the values. You also need to snapshot the model if you want all three changes to show - otherwise you’ll just get the last one! I also include a test for edit mode (so that your code only runs when there are some values to get):


[IButton, "Tool:Vinny Tools:VSheet", "Create a sheet ",
	
[VarSet, VGCurrentWidth, [Iget, document:width ] ]
[VarSet, VGCurrentHeight, [Iget, document:Height ] ]
	
[If,[IsEnabled,Transform:Edit]&&[IGet,Transform:Edit],
[TransformGet, xPos, yPos, zPos, xSc, ySc, zSc, xRot, yRot, zRot ]

[Iset, document:rate, 0]
[IUnpress, Document:Pro ]
[Iset, Document:width, (VGCurrentWidth*2) ]
[IUnpress, Transform:Edit ]
[IPress, Layer:clear ]
[Ipress, document:Resize ]
[IPress, Zoom:AA half]

[VarSet,xPos,Document:Width/6]
[VarSet,yPos,Document:Height/2]
[CanvasClick,10,10,10,20]
[IPress,Transform:Edit]

[TransformSet, xPos, yPos, zPos, xSc, ySc, zSc, xRot, yRot, zRot ]
[IPress,Transform:Snapshot]

[TransformSet, xPos*3, yPos, zPos, xSc, ySc, zSc, xRot, (yRot+45), zRot ]
[IPress,Transform:Snapshot]

[TransformSet, xPos*5, yPos, zPos, xSc, ySc, zSc, xRot, (yRot+90), (zRot+180) ]
[IPress,Transform:Snapshot]
,
[Note,"No model in Edit mode"]
]
] //end IButton

HTH,

Once again a huge Thx marcus, it works like this !

I just tweaked the canvas size for my need.

I tried the canvas click but for some reason it didn’t work (should have been the problem you spoke ).

thx it helps me improving myself

Hey Marcus !

I tweaked it a bit, cause the previous version assumed that the pivot point is at the center of the Ztool, which is not necessary the case.

I created 2 variables which contain the offset between the xpos and ypos, and the center of the canvas.

I can then reapply them later in the script.

Works well so I am happy :smiley:

Once again thx for your help

Ohh,
Thanks for posting such a good information.
I am looking for this and i suddenly found this post.
Thanks !!

No problem :wink: