2023-08-31 03:16 AM - last edited on 2023-11-21 08:45 PM by Laszlo Nagy
Hi, I am trying to create a new light switch object that works with my Electrical Legend ( I know there is one created in archicad, but it doesnt work the way I would like) I am trying to create one object that can switch between 1, 2, 3 & 4 switches. I have created the. '1 switch' but cannot work out how to add the others in.
I have attached a screen grab on another object I have that shows what I am trying to achieve, any help would be greatly appreciated.
2023-08-31 03:29 AM - edited 2023-08-31 08:40 AM
If you want multiple choices, then it is not a matter of just saving a selection to create an object.
You will need to get into scripting.
You can use FRAGMENTs if there are just a few options - one fragment for each 2D symbol, you can have up to 16 fragments.
But if there are going to be many then you will need to start using sub-routines for each type.
If you can script in GDL, you should know what I am talking about.
If you can't script in GDL, prepare to put in a fair few hours to learn.
Barry.
2023-08-31 08:34 AM - last edited on 2023-09-06 06:02 AM by Laszlo Nagy
Add parameter in "Parameters" as in the snip attached.
Add below line to your "Parameter" script:
VALUES "switchType" "1 Switch", "2 Switch", "3 Switch", "4 Switch"
From here in 2D and 3D script you can use gosub
GOSUB switchType
END
"1 Switch":
!your code
RETURN
"2 Switch":
!your code
RETURN
2023-11-18 01:53 PM
2023-11-18 03:54 PM - edited 2023-11-18 03:55 PM
Hi @MikeRaats_FOX ,
Adding to all the replies, you could also do an ENUM style scripting.
1. Using an integer type parameter that we'll call "type_Switch"
2. In Main script, we create the variables to integers and use an array to label them easily
SWITCH_1 = 1
SWITCH_2 = 2
SWITCH_3 = 3
SWITCH_4 = 4
dim name_SWITCH[4]
name_SWITCH[1] = "Name of switch 1"
name_SWITCH[2] = "Name of switch 2"
name_SWITCH[3] = "Name of switch 3"
name_SWITCH[4] = "Name of switch 4"
3. In Parameter script, we link the integers to the labels
values{2} "type_Switch" SWITCH_1, name_SWITCH[SWITCH_1],
SWITCH_2, name_SWITCH[SWITCH_2],
SWITCH_3, name_SWITCH[SWITCH_3],
SWITCH_4, name_SWITCH[SWITCH_4]
4. In the 2D and/or 3D scripts, we go to the part of the code according to the value of the type_Switch parameter :
gosub 10000 + type_Switch ! adding 10000 to give the switch choices a unique ID
end
10001: ! 10000 + SWITCH_1
! Code for 1st switch
return
10002: ! 10000 + SWITCH_2
! Code for 2nd switch
return
...