Value liste as text instead of numbers?

Home Forums General discussions Value liste as text instead of numbers?

Tagged: ,

Viewing 12 reply threads
  • Author
    Posts
    • #4517
      Mats Knutsson
      Participant

      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.
      /Mats

    • #4519
      David Shorter
      Participant

      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

    • #4520
      David Shorter
      Participant

      or like this

      Attachments:
      • #4534
        Mats Knutsson
        Participant

        Works like charm. Thank you 🙂

    • #4522
      Mats Knutsson
      Participant

      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

    • #4523
      David Shorter
      Participant

      send me the list of text and the matching colours
      david.shorter@internode.on.net

    • #4524
      David Shorter
      Participant

      no worries, try this

      Attachments:
    • #4527
      Mats Knutsson
      Participant

      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

    • #4528
      David Shorter
      Participant

      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.8

      if 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+1

      mul2 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 screenshot

      Attachments:
      • #4535
        Mats Knutsson
        Participant

        This solution is very interesting but it yields string ending quote is missing on line 1!?

    • #4536
      Péter Baksa
      Keymaster

      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] = 1

      param script:
      values{2} “iVal” aVal, sVal

      ui 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, aVal

      This 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

    • #4539
      David Shorter
      Participant

      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

    • #4540
      David Shorter
      Participant

      this is how its supposed to work

      Attachments:
    • #4543
      Péter Baksa
      Keymaster

      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

    • #4544
      David Shorter
      Participant

      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.

Viewing 12 reply threads
  • The forum ‘General discussions’ is closed to new topics and replies.