2023-12-09
	
		
		04:27 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 - last edited on 
    
	
		
		
		2024-09-26
	
		
		01:33 PM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 by 
				
		
		
			Doreena Deng
		
		
		
		
		
		
		
		
	
			
		
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
			
    
	
		
		
		2023-12-09
	
		
		05:24 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 - last edited on 
    
	
		
		
		2023-12-10
	
		
		07:37 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 by 
				
		
		
			Laszlo Nagy 
		
		
		
		
		
		
		
		
	
			
		
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.
Barry.
			
    
	
		
		
		2023-12-09
	
		
		09:11 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 - last edited on 
    
	
		
		
		2023-12-10
	
		
		07:38 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 by 
				
		
		
			Laszlo Nagy 
		
		
		
		
		
		
		
		
	
			
		
!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"
endif2023-12-09 11:30 PM
@Pertti Paasky wrote:
this little button works in any scale just by clicking the hotspot.
Wow, this is really brilliant !