The Global Archicad Community

Stay informed. Get help. Share your knowledge.

Everything about using Libraries and Library Parts - Doors/Windows/Objects/Stairs etc. (Example: How can I display a Transom above my Door?)

Moderators: ejrolon, Barry Kelly, Karl Ottenstein, LaszloNagy, gkmethy, Gergely Feher

User avatar
By Matthew Johnson
#208596
Trying to update our zone GDL to automatically calculate occupancy numbers using use tables from the Building Code. I'm using an external text file to hold the table data so that it can be updated if the Building Code changes.
!-- Getting NCC Table D1.13 values

dim value_use[], value_rate[]

filename= "NCCTableD113.txt"
ch1=OPEN("TEXT",filename,"SEPARATOR='\t',MODE=RO,LIBRARY")

!--counting the total number of rows
row=0
do
row= row+1
n=INPUT(ch1,row,1,string1)
while n>-1

!--reading the first column for NCC_TableD113_Use
for k= 1 to row-1
n=INPUT(ch1,k,1,string1)
value_use[k]= string1
next k

!--reading the second column for NCC_TableD113_Rate
for m= 1 to row-1
n=INPUT(ch1,m,2,string2)
value_rate[m]= string2
next m

CLOSE (ch1)

VALUES "NCC_TableD113_Use" value_use, custom
Not having done much work yet with arrays I'm now stuck as to the next step to use the value the user selects from the drop down for NCC_TableD113_Use to select the matching value for the NCC_TableD113_Rate.

Can anyone suggest some code or point me in the right direction for a guide for this?
User avatar
By Juha Vesen
#208641
Hello,

If you are just filling the NCC_TableD113_Rate with the chosen NCC_TableD113_Use then
this should do the job.

Two parameters needed; NCC_TableD113_Use (string) and NCC_TableD113_Rate (number)
Code: Select all
!-- Getting NCC Table D1.13 values 

dim value_use[], value_rate[] 

filename= "NCCTableD113.txt" 
ch1=OPEN("TEXT",filename,"SEPARATOR='\t',MODE=RO,LIBRARY") 

!--counting the total number of rows
do
row= row+1
n=INPUT(ch1,row,1,string1)
while n>-1

!--reading the first column for NCC_TableD113_Use
for k= 1 to row-1
	n=INPUT(ch1,k,1,string1)
	value_use[k]= string1
next k
values "NCC_TableD113_Use" value_use, custom

!--reading the second column for NCC_TableD113_Rate 
for k= 1 to row-1
	n=INPUT(ch1,k,1,string1,string2)
	if NCC_TableD113_Use = string1 then
		values "NCC_TableD113_Rate" string2
	endif
next k

CLOSE (ch1)

Hope this works.

PS. What kind of a boat are you sailing?
Attachments
(1.3 KiB) Downloaded 187 times
User avatar
By Matthew Johnson
#208651
Juha,

Thanks for the assist. Works well and simple code keeps it tidy.

PS: the avatar is the sail from my Cobra catamaran. Don't get to sail it much since I had my ankle reconstructed. Spend most of my spare time now teaching kids to sail.
User avatar
By Juha Vesen
#208667
Nice to hear that the problem was solved.

Sorry about the ankle...as they say: "keelboats are for elderly
people" ;-)

Regards, Juha