GDL
About building parametric objects with GDL.

Hotspot with integer to drive values{2} list

GDL Enthusiast
Enthusiast

Hi, 

 

I have seen hotspots used to drive values{2} lists in the past but can't find the example to show now.

 

I have tried to link a variable 'Switch' driven by a values{2} list:

 

values{2} "Switch", 0, `Off`,
                    1, `On`

 

By using a hotspot called 'dragpoint':

 

hsid=hsid+1 
HOTSPOT2 0, 0, hsid, dragpoint, 1+128
hsid=hsid+1 
HOTSPOT2 dragpoint, 0, hsid, dragpoint, 2+512
hsid=hsid+1 
HOTSPOT2 0-1, 0, hsid, dragpoint, 3

 

'dragpoint' has a Values Range to snap at 10mm points:

 

VALUES 'dragpoint' RANGE [0.01,0.02] STEP 0.01,0.01

 

Then using INT() to make it into an integer, and multiplying to convert 10mm to 1 integer unit so the values list is driven by a 1 or 2: 

 

Switch = INT(dragpoint*100000)

PARAMETERS Switch = Switch

 

But alas it doesn't play. My hope is to be able to drag a hotspot along snap points to allow selection of a list parameter on the floor plan. Would be very fun.

Many thanks, Matt

3 REPLIES 3
Barry Kelly
Moderator

I have not done it with VALUES{2}, but I often use switch hotspots in my objects.

Maybe this will help.

I actually have a boolean on/off parameter and a text parameter for on/off.

I find the text parameter is clearer for the user in the parameter list of the object.

Hide one or the other.

 

In parameter or master script.

 

 

swch_dist = 0.075

VALUES "select_hs_swch" "On", "Off"
VALUES "select_hs_yDist" swch_dist, -swch_dist

!!! ---------- show Selector ----------
	if GLOB_MODPAR_NAME = "select_hs_swch" then
		if select_hs_swch = "On" then
			select_hs_yDist =  -swch_dist
			select_hs = 1
		else
			select_hs_yDist = swch_dist
			select_hs = 0
		endif
	endif

	if GLOB_MODPAR_NAME = "select_hs_yDist" then
		if abs (select_hs_yDist-swch_dist) < TOL then
			select_hs_swch = "Off"
			select_hs = 0
		else
			select_hs_swch = "On"
			select_hs = 1
		endif
	endif

	if GLOB_MODPAR_NAME = "select_hs" then
		if select_hs = 1 then
			select_hs_yDist =  -swch_dist
			select_hs_swch = "On"
		else
			select_hs_yDist = swch_dist
			select_hs_swch = "Off"
		endif
	endif

!!! ---------- parameters ----------
	parameters select_hs_swch = select_hs_swch,
				select_hs_yDist = select_hs_yDist,
				select_hs = select_hs

 

 

In 2D script.

 

 

!!! ---------- show Selector hotspot----------
	HSID=HSID+1
	hotspot2 0.0, 0.0    , HSID, select_hs_yDist, 1    ! base
	HSID=HSID+1
	hotspot2 0.0,0.0-1    , HSID, select_hs_yDist, 3    ! ref
	HSID=HSID+1
	hotspot2 0.0, 0.0+select_hs_yDist, HSID, select_hs_yDist, 2, select_hs_hs_swch    ! moving
	HSID=HSID+1     

 

 

And of course the parameters.

 

BarryKelly_0-1702095720250.png

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Pertti Paasky
Advocate
Hello
this little button works in any scale just by clicking the hotspot.
 
!Used parameters
!OnOff [2]  (length type)
!on_           (length type)
!off_           (length  type)
!Parameters script
if glob_modpar_name="on_" then
parameters off_=0
parameters on_=.002
endif

if glob_modpar_name="off_" then
parameters on_=0
parameters off_=.002
endif

!2d script:
pos_x=.02
pos_y=-.02
define style"on_off" arial,3,4,0:style"on_off"

scalemultiplier=.0100*glob_scale
circle2 pos_x, pos_y, .5*scalemultiplier

if abs(on_)<.001 then 
insx=pos_x
insy=pos_y
HOTSPOT2 0, insy, id, on_, 1+128 :id=id+1
HOTSPOT2 insx, insy, id, on_, 2 :id=id+1
HOTSPOT2 -1, insy, id, on_, 3 :id=id+1
circle2 pos_x, pos_y, .2*scalemultiplier
circle2 pos_x, pos_y, .1*scalemultiplier
circle2 pos_x, pos_y, .3*scalemultiplier
text2 insx+1*scalemultiplier,insy,"ON"
endif

if abs(off_)<.001 then 
insx=pos_x
insy=pos_y
HOTSPOT2 0, insy, id, off_, 1+128 :id=id+1
HOTSPOT2 insx, insy, id, off_, 2 :id=id+1
HOTSPOT2 -1, insy, id, off_, 3 :id=id+1

text2 insx+1*scalemultiplier,insy,"OFF"
endif
- AC-24 FIN - WIN 10 - HP Zbook -
“A winner is just a loser who tried one more time.”
George M. Moore, Jr.

@Pertti Paasky wrote:
 
this little button works in any scale just by clicking the hotspot.
 

Wow, this is really brilliant !

Joachim Suehlo . AC12-27 . MAC OSX 13.5 . WIN11
GDL object creation: b-prisma.de

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!