Home › Forums › General discussions › Value liste as text instead of numbers?
- This topic has 14 replies, 3 voices, and was last updated 5 years, 10 months ago by David Shorter.
-
AuthorPosts
-
-
February 22, 2019 at 19:11 #4517Mats KnutssonParticipant
Hi,
I have a simple circular fill that respresents different door options. All in all about 17 different colours and the object is supposed to be placed on the plan view. I can make a list in the Parameters field but I don’t understand how to list text values like “Red”, “Green, “Blue” etc instead of the pen index numbers?
I tried various Red = 1 etc but no success.
/MatsAttachments:
-
February 23, 2019 at 06:57 #4519David ShorterParticipant
Hi Matt
Not sure about the rest of the script but I would set the var type as a PEN then you dont need a value list or you could have a value list which contains a selection of pen numbers.
Sent me your script if you like.
regard D -
February 23, 2019 at 07:11 #4520David ShorterParticipant
or like this
Attachments:
-
February 27, 2019 at 09:17 #4534Mats KnutssonParticipant
Works like charm. Thank you 🙂
-
February 23, 2019 at 10:10 #4522Mats KnutssonParticipant
or like this
I have it just like in your example but I want the user to choose a function (text) and then a pen color gets assigned to the fill. User choose “Door magnet” and the circle fill turns red. User choose “Door car reader” and the circle fill turns green and so on. I can’t do individual objects because there will be too many.
/Mats
-
February 23, 2019 at 10:13 #4523David ShorterParticipant
send me the list of text and the matching colours
david.shorter@internode.on.net -
February 23, 2019 at 10:43 #4524David ShorterParticipant
no worries, try this
Attachments:
-
February 25, 2019 at 10:41 #4527Mats KnutssonParticipant
no worries, try this
Thx. Seems logical. Will try :).
I so miss simple code snippets like yours and others!
We have skiled architectural programmers in our company and their focus is 100% on GH/python.
/Mats -
February 25, 2019 at 12:11 #4528David ShorterParticipant
be careful with a dedicated programer …. they MUST understand ARCHICAD AND must leave the code (scripts) unlocked
here is another option…
values “zPos” 0,0.2,0.4,0.6,0.8,1,1.2,1.4,1.6,1.8if zPos =0 then penAttribute_1= 15
if zPos =0 then text2 .5,zPos,”t1″
if zPos =.2 then penAttribute_1= 16
if zPos =0.2 then text2 .5,zPos,”t2″
if zPos =.4 then penAttribute_1= 17
if zPos =0.4 then text2 .5,zPos,”t3″
if zPos =.6 then penAttribute_1= 18
if zPos =0.6 then text2 .5,zPos,”t4″
if zPos =.8 then penAttribute_1= 19
if zPos =0.8 then text2 .5,zPos,”t5″
if zPos =1 then penAttribute_1= 20
if zPos =1 then text2 .5,zPos,”t6″unID=2000
HOTSPOT2 .5, 0, unID, zPos, 1:unID=unID+1
HOTSPOT2 .5,-0.1, unID, zPos, 3:unID=unID+1
HOTSPOT2 .5, zPos, unID,zPos, 2 :unID=unID+1mul2 A/0.467201, B/0.467201
add2 0.233600530869, 0.233600530869
set line_type lineTypeAttribute_1
pen penAttribute_1
fill fillAttribute_1
poly2_b{5} 5, 3, 1, 3, penAttribute_1, penAttribute_2,
0, 0, 1, 0, 0, 1, 0,
-0.233600530869, 2.860781424079E-17, 33,
0, 1.430390712039E-17, 900,
0, 180, 4033,
0, 1.430390712039E-17, 900,
0, 180, 4033
!_____________________________________
zPos is a length parameter
and the script creates a moveable hotspot that you can drag vertically and change the text and the pen at each position.
Means you dont have to open the object dialogue to change the settings its all done through the moving hotspot.
all the above is in the Master script and the parameters are in the screenshotAttachments:
-
February 27, 2019 at 09:28 #4535Mats KnutssonParticipant
This solution is very interesting but it yields string ending quote is missing on line 1!?
-
February 27, 2019 at 10:16 #4536Péter BaksaKeymaster
Hi all,
a more flexible way is to use the VALUES{2} command.
set parameter “iVal” as integer
master script:
dim aVal[], sVal[], picVal[] ! parameter value, string shown on UI, icon index shown on UI
aVal[1] = 1 : sVal[1] = “Option 1” : picVal[1] = 2
aVal[2] = 2 : sVal[2] = “Option 2” : picVal[2] = 1param script:
values{2} “iVal” aVal, sValui script:
ui_infield{3} iVal, x, y, w, h,
2, ! pop-up with icons
picture_name,
images_number,
rows_number, cell_x, cell_y,
image_x, image_y,
picVal, sVal, aValThis way you can easily re-organize the strings in the popup, by re-ordering the aVal, sVal, picVal arrays. You can rename the strings or swap icons by changing just one line in the master script.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE -
February 27, 2019 at 11:35 #4539David ShorterParticipant
Thanks Peter, but a bit advanced for a novice scripter
Mats, if you replace the values statement with this it will work
values “zPos” 0,0.2,0.4,0.6,0.8,1,1.2,1.4,1.6,1.8
apparently in the script I sent you the parenthesis each side of the zPos were different causing the error, very difficult to spot
Peter perhaps the developers could fix this
this “zPos” snd this “zPos” are different causing the error
regards
D -
February 27, 2019 at 11:45 #4540David ShorterParticipant
this is how its supposed to work
Attachments:
-
February 27, 2019 at 12:22 #4543Péter BaksaKeymaster
David, that’s intentional, this way it is possible to include quotation marks in a string.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE -
February 27, 2019 at 12:34 #4544David ShorterParticipant
Be that as it may, it took me about an hour to locate the problem because its almost impossible to see the difference in the scripting window. A trap for the unwary.
-
-
AuthorPosts
- The forum ‘General discussions’ is closed to new topics and replies.