How to create a tool that selects a specific layer?

Please use this part to report bugs & errors, ask questions & "How to..."
Post Reply
Farrow
Posts: 4
Joined: 26 Feb 2014, 19:02

How to create a tool that selects a specific layer?

Post by Farrow »

Hi, I was hoping there may be a way to create a tool that automatically selects a specific layer. For example if I have a black pen size 1.60 in a custom panel, is it possible that whenever I select that tool it could automatically take me to a specific layer, for example named "sketch"?

Something like Layer: Select "Sketch" Layer, if you know what I mean? :|
User avatar
Thierry
Site Admin
Posts: 2780
Joined: 07 Jan 2013, 08:28

Re: How to create a tool that selects a specific layer?

Post by Thierry »

Hello Farrow,

Yes it is possible :)
Here is a custom panel that does it. It contains a custom panel, with a black Pen Brush, with size 1.60, and it select a layer named "Sketch". If no layer named "Sketch" is found, then it display a warning.
Select-Sketch-Layer.tvpx
(56 KiB) Downloaded 925 times
And the George code :

Code: Select all

loop=1
i=0
found=0
tv_layerCurrentID
current=RESULT

WHILE (loop)
	tv_LayerGetID i
	curLID = result
	IF (CMP(curLID,"none")==0)
		tv_layerSet curLID
	
        tv_LayerInfo
        PARSE result layerDisplay layerPosition layerOpacity layerName layerType layerStart layerEnd layerPrelighttable layerPostlighttable layerSelection

        IF (CMP(layerName,"sketch")==1)
        	found=1
        	loop=0
        END
	ELSE
		loop=0
	END
	i=i+1
END

IF (found==0)
	tv_layerSet current
	tv_warn "Layer sketch not found !"
END
User avatar
ZigOtto
Posts: 4102
Joined: 17 Feb 2006, 22:50
Location: south-Petazonia

Re: How to create a tool that selects a specific layer?

Post by ZigOtto »

thanks Thierry, cool script and button freely configurable,
for the layer's name, as for the tool's type and settings 8)
(just to mention it, a little mis-typing in your panel's name :
"select-sketcg", a "h" in place of the "g" would suit better)
Last edited by ZigOtto on 28 Jul 2015, 09:06, edited 1 time in total.
User avatar
Thierry
Site Admin
Posts: 2780
Joined: 07 Jan 2013, 08:28

Re: How to create a tool that selects a specific layer?

Post by Thierry »

ZigOtto wrote:(just to mention it, a little mis-typing in your panel's name : "select-sketcg", a "h" in place of the "g" would suit better)
Woops, fixed 8)
User avatar
ZigOtto
Posts: 4102
Joined: 17 Feb 2006, 22:50
Location: south-Petazonia

Re: How to create a tool that selects a specific layer?

Post by ZigOtto »

ultra-fast service ! 8)

a last note about this handy tool :
if you have several layers with the same "sketch" name,
the script will select always the upper one.
Post Reply