We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

GDL
About building parametric objects with GDL.

Sensitize gdl object to story level

Bhtsz_pyd
Contributor

Hello, I'm new to Gdl.
I have an object in my hand. I want to make a gdl object where I can choose which floor level this object will be at. However, I could not write a suitable code for this. There is the feature I want in the elevator object, but the gdl codes were too complicated for me. Which command should I use for this?

Thank you.

7 REPLIES 7
MF BIM
Enthusiast

Hello @Bhtsz_pyd ,

 

You would need to REQUEST the STORY_INFO global variable. It holds info on all stories including the names, elevations and heights.

n = REQUEST("STORY_INFO", expr, nStories,
            index1, name1, elev1, height1 [,
            index2, name2, ...])

 

https://mfbim.fr | https://youtube.com/@mfbim
AC24 FRA 7600 - AC26 FRA 4027 | MacBook M1 Pro
Bhtsz_pyd
Contributor

Thank you MF BIM for your reply.
Obviously I tried that, but that's where your problem starts. What I want to do is to create a parameter that I can choose between. Ground Floor Plan, 1st Floor Plan, 2nd Floor Plan and link the position of the object to that floor. With the code you mentioned, I can get data such as story name or story height. I can also write it to the screen with the Text2 command. However, I cannot create a parameter that I can choose between them. Is there a sample video you can suggest about this? Creating a parameter similar to the “car position” parameter in the elevator object.

 

maxresdefault.jpg

Hi,

 

the additional code you need is:

n = REQUEST ("Story", "", index, story_name)
Returns in the index and story_name variables the index and the name of the current story.
n = REQUEST ("Home_story", "", index, story_name)
Returns in the index and story_name variables the index and the name of the home story.

 

you cannot physically move the object to a different story using the GDL code, but you can move where it appears in floor plan, and 3d Position using the code...

i.e.

n_current = REQUEST ("Story", "", index_current, story_name_current)

n_home = REQUEST ("Home_story", "", index_home, story_name_home)

 

nn_current = REQUEST ("STORY_INFO", index_current, total_stories, Index_Of_current, Name_Of_current, Elevation_Of_Current, Height_of_Current)

nn_home = REQUEST ("STORY_INFO", index_home, total_stories, Index_Of_Home, Name_Of_Home, Elevation_Of_Home, Height_of_Home)

 

nn_Ground = REQUEST ("STORY_INFO",0, total_stories, Index_Of_Ground, Name_Of_Ground, Elevation_Of_Ground, Height_of_Ground)

nn_First= REQUEST ("STORY_INFO",1, total_stories, Index_Of_First, Name_Of_First, Elevation_Of_First, Height_of_First)

nn_Second = REQUEST ("STORY_INFO",2, total_stories, Index_Of_Second, Name_Of_Second, Elevation_Of_Second, Height_of_Second)

 

and then you have the ability to calculate position/display based on designated story.

 

you can then have a parameter that has the story you wish to display

show_on_story

i.e.

values "show_on_story" "Ground Floor Plan", "First Floor Plan", "Second Floor Plan"

 

AllanP_0-1724036027332.png

 

!2D Script

n_current = REQUEST ("Story", "", index_current, story_name_current)

if show_on_story = "Ground Floor Plan" and index_current = 0 then

    !Show 2d content for ground floor option here

endif

if show_on_story = "First Floor Plan", and index_current = 1 then

    !Show 2d content for First floor option here

endif

if show_on_story = "Second Floor Plan", and index_current= 2 then

    !Show 2d content for Second floor option here

endif

 

 

I have been using ArchiCAD continually since ArchiCAD 4.5, 4.5.5, 5, 5.1, 6, 6.5, 7, 8, 8.1, 9, 10, 11, 12, 13, 15, 18, 21, 22, 25, now testing 27
Member of Architalk since 2003, but missed the migration to Graphisoft.
(where have all my original posts gone?)

@Bhtsz_pyd,

 

If you want to move the car then I would do it like this :

- Have an CarElevation parameter (length type)

- Have a CarPosition parameter (integer type)

- Request the story names and elevations after you requested the story info) and use VALUES{2} to display them as a drop down menu

- After selecting the CarPosition, calculate the sum of the elevations up to the chosen story

- Give that value to the CarElevation parameter to move the car

 

If you're new to GDL, you may need to go there to get some of the basics : https://gdl.graphisoft.com/gdl-basics

https://mfbim.fr | https://youtube.com/@mfbim
AC24 FRA 7600 - AC26 FRA 4027 | MacBook M1 Pro
Bhtsz_pyd
Contributor

@MF BIM @AllanP 

Thank you both very much for your response. However, I think I asked my question wrong. The question I am looking for an answer to is to create an infinite loop “values{2}”
i.e.
values{2} “stryname” , 1 , Ground Floor Plan,
2, First Floor Plan,
3, Second Floor Plan

I can write this manually, but depending on the size of the project, sometimes it can be a 10-storey project, sometimes a 20-storey project. Every time I add a new floor to the project, I want that stories to be added to the parameter automatically.

Lingwisyer
Guru

You could PUT all of the values into a parameter through a loop using nStories from your Request. From there you can use GET to insert it into your VALUES{2}. 

 

https://gdl.graphisoft.com/reference-guide/parameter-buffer-manipulation

 

n = REQUEST ("Story_info", "", nr, ss)

FOR i = 1 TO nr
!nr = STR ("%.0m", ss [4 * (i - 1) + 1])
!name = ss [4 * (i - 1) + 2]
!elevation = STR ("%m", ss [4 * (i - 1) + 3])
!height = STR ("%m", ss [4 * (i - 1) + 4])

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660

FYI

Put only allows Numbers, so you cant use put on a story name that contains text.

 

but you can use:

 

dim s_info[]
dim s_index[]
dim s_name[]
n = REQUEST("STORY_INFO", "", nrstories, s_info)

for j = 1 to nrstories
  s_index[j] = s_info[j*4-3]
  temp_name = s_info[j*4-2]

  !!!!-------Note: you can't have the same name description for 2 different numbers, so this bit here for unique story names------!!!!
  if j > 1 then
    for ii = 1 to j -1
      if s_name[ii] = s_info[j*4-2] then
        temp_name = s_info[j*4-2] +"Story="+str(s_index[j],1,0)
      endif
    next ii
  endif

  !!!!-------Note: you can't have the same name description for 2 different numbers, so this bit here for unique story names------!!!!
  s_name[j] = temp_name
next j

values{2} "stryname" s_index, s_name

 

AllanP_0-1724198203826.png

 

I have been using ArchiCAD continually since ArchiCAD 4.5, 4.5.5, 5, 5.1, 6, 6.5, 7, 8, 8.1, 9, 10, 11, 12, 13, 15, 18, 21, 22, 25, now testing 27
Member of Architalk since 2003, but missed the migration to Graphisoft.
(where have all my original posts gone?)