Select Reset Transform tool with George

A forum dedicated to George scripting questions
Post Reply
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Select Reset Transform tool with George

Post by Mads Juul »

The transform tool can have 2 states. visualised with the bounding bom being red or green.¨
I would like to use George to select the transform tool but always have the reset state when I start. the green bounding box.
I use

Code: Select all

tv_setactiveshape "position" 
But If I dont have applied the transformation(pressed enter) the last time I used the transform tool then the bounding box is red. and I cannot read the state of the transform tool through George. I think.

we can obtain it with an action, and these two functions

Code: Select all

Shape Transform : Position
Shape: Cancel
But I need it sometimes in a middle of a script when special conditions arise. so is there somehow to do this in George?
-Mads
Svengali
Posts: 1571
Joined: 28 Dec 2006, 10:08

Re: Select Reset Transform tool with George

Post by Svengali »

Have you tried a pair of commands: tv_ReApply tv_Undo. returns to the previous green box as you want.

Adding tv_ImagePush and tv_ImagePop (adds up to a net nothing) yet it gets rid of any residual undo as well.

Sven
TVP Pro 11.0.10-64bit Win10 - 64GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.41-1
Android Tablet: rel. 11, Samsung Galaxy Note10.1 - 32GB with microSD 32GB
Android Tablet: rel. 11.5, Samsung Galaxy Tab S7plus - 128GB with microSD 64GB
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: Select Reset Transform tool with George

Post by Mads Juul »

Svengali wrote:Have you tried a pair of commands: tv_ReApply tv_Undo. returns to the previous green box as you want.

Adding tv_ImagePush and tv_ImagePop (adds up to a net nothing) yet it gets rid of any residual undo as well.

Sven
but where do i know if i got a red or a green box to start?
Svengali
Posts: 1571
Joined: 28 Dec 2006, 10:08

Re: Select Reset Transform tool with George

Post by Svengali »

I think you are right that there is no scripted test to know what the momentary state of the transform tool is. Script-wise I think the best you can do is guarantee that the box is green by doing a tv_ReApply and tv_Undo before proceeding with further scripted actions.


Sven
TVP Pro 11.0.10-64bit Win10 - 64GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.41-1
Android Tablet: rel. 11, Samsung Galaxy Note10.1 - 32GB with microSD 32GB
Android Tablet: rel. 11.5, Samsung Galaxy Tab S7plus - 128GB with microSD 64GB
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: Select Reset Transform tool with George

Post by Mads Juul »

Svengali wrote: is guarantee that the box is green by doing a tv_ReApply and tv_Undo before proceeding with further scripted actions.
How can i guarantee it is green?
If I have this code on a embedded george scipt in an Action

Code: Select all


tv_setactiveshape "position" 
tv_ReApply
tv_Undo 
tv_updateUndo
Which must be the same as if it was inside a script. every second time I press the Action the box is red and the other is green. So how can I guarantee it is green? This is the problem of my script.
-Mads
Svengali
Posts: 1571
Joined: 28 Dec 2006, 10:08

Re: Select Reset Transform tool with George

Post by Svengali »

Mads,

I see your point. Maybe the following will help:

Code: Select all

// ResetBoundingBoxTest.grg

tv_GetWidth
Width = result
tv_GetHeight
Height = result
CenterX = Width/2
CenterY = Height/2

tv_UpdateUndo

tv_GetActiveShape
Shape = result
tv_GetActiveTool
Tool = result

Status = BoundingBoxState()

tv_warn Status

tv_CMD Tool
tv_SetActiveShape Shape
tv_SetActiveShape "position"


//------------------------------------------
//
//	BoundingBoxState
//
//	Function: returns current bounding box state
//
//	Call: BoundingBoxState()
//
//	Returns BBState Message that box is red or green
//
//------------------------------------------

FUNCTION BoundingBoxState()

// cutbrush and capture size and center - store as result 1
	tv_UndoOpenStack
	tv_BrushCut 0 0 Width Height 0
	tv_BrushRestore Optimize 1
	tv_BrushInfo
	parse result TWidth THeight TCenterX TCenterY dummy
	Result1 = TWidth" "THeight" "TCenterX" "TCenterY

// clear screen, drop repositioned brush capture size and center - store as result 2
	tv_SetActiveShape "position"
	tv_ReApply
	tv_BrushCut 0 0 Width Height 0
	tv_BrushRestore Optimize 1
	tv_BrushInfo
	parse result TWidth THeight TCenterX TCenterY dummy
	Result2 = TWidth" "THeight" "TCenterX" "TCenterY

	tv_ReApply
	tv_Undo

	IF CMP(Result1, Result2) == 1
		Message = "bounding box is red"
	ELSE
		Message = "bounding box is green"
	END
	Return Message
	tv_UndoCloseStack
END
It compares the two transform states and seems to give a reliable report, though each time it runs it toggles between red and green borders. Since I have no notion of what it is you are trying to do, it may or may not work for you... :?

Sven
Last edited by Svengali on 07 May 2013, 08:41, edited 1 time in total.
TVP Pro 11.0.10-64bit Win10 - 64GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.41-1
Android Tablet: rel. 11, Samsung Galaxy Note10.1 - 32GB with microSD 32GB
Android Tablet: rel. 11.5, Samsung Galaxy Tab S7plus - 128GB with microSD 64GB
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: Select Reset Transform tool with George

Post by Mads Juul »

It doesnt seem to work the first time I tried it . But I will look into it. thank you for the help. But it could be a nice feature to be able to reset the transform tool. and be able to read the "state" of the transform tool
for instance with
tv_setActiveShape "position" "backup"

I will make a feature request
Svengali
Posts: 1571
Joined: 28 Dec 2006, 10:08

Re: Select Reset Transform tool with George

Post by Svengali »

Testing it, I just drew a shape in the frame, then selected the Transform tool, then moved, scaled and rotated, then ran the script. Each time through, it correctly identified the new status (color) of the bounding box, home position = green, transformed position = red.

Could be useful if there were a George command that supplied panning X panning Y scale and angle transform status... even let you update it in a script... I'm still curious what kind of script you are making. :?

Good luck with it,

Sven

Edit: I just retested some more and you're right it sometimes doesn't work. I think its a problem with how I'm managing the undo stack. Anyway, there's definitely a need for some kind of expanded Transform status command here.
TVP Pro 11.0.10-64bit Win10 - 64GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.41-1
Android Tablet: rel. 11, Samsung Galaxy Note10.1 - 32GB with microSD 32GB
Android Tablet: rel. 11.5, Samsung Galaxy Tab S7plus - 128GB with microSD 64GB
Post Reply