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

Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Request assocel_properities

Anonymous
Not applicable
Hi I'm working on a label that shows the keycodes of the components of the associated properties.

I used the example in gdl guide on REQUEST ASSOCEL_PROPERTIES
I used the command in the 2D script not in parameter or master script

To make an example I used a composite wall and its associated property object.

The property object has many components that retrieve information from different databases.

The resulting label is alittle bit odd.
It retrieves the key codes from the property object from components of both of the databases that is use, but not all of them.

furthermore I would like to ask how I could limit my results to the key codes of the components of a certain database? I don't understand clearly how the matrix stores data and if I should use one or two dimensinal array and how to retrieve certain information.

Thanks

2016-09-01_13h34_03.png
13 REPLIES 13
Anonymous
Not applicable
pic2
2016-09-01_13h35_54.png
Anonymous
Not applicable
pic3
2016-09-01_13h35_17.png
Anonymous
Not applicable
pic4
Anonymous
Not applicable
I finaly managed to get the code running. A kind of property label is ready.
It filters info from the retrieved array by category of info.

Generally filtering within the array can be made only by index.
I tried many combinations of string functions and expressions and nothing works you cannot make string comparisons or filter info by string contents.

for example
IF DATA = "KEYNOTEDB" THEN 
TEXT2 0,J, DATA[i+2]
is not working

if I want to get the keycodes of the descriptors that come from keynotedb
I could filter iscomp for descriptors 0 or 1 then the database "keynotedb" and ask for KEYCODE but this seems not be possible

I also noticed that descriptor info is read first then it reads the components
they are stored linearly in the 1D array in a series of packets of requested values in the order that was requestd by the REQUEST command


2D Script
n=0
DIM DATA[], xxx[]
nnn = REQUEST ("ASSOCEL_PROPERTIES", "dbsetname,iscomp,keycode,keyname,code,name,fullname,quantity,totquantity,unitname,unitformatstr,propobjname", n, DATA)
if n = 0 then
    TEXT2 0, 0, "No properties"
ELSE
	j = 0
	for i=1 to n 

!!!!			xxx = strlen (data)			!string functions or string expressions do not work

			IF   i/intype = 1 or (i-intype)/12 = int((i-intype)/12) THEN 

			TEXT2 0, -j, DATA
!!!!			text2 -1,-j, xxx					!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
			j=j+1 

			ENDIF 

NEXT i
ENDIF	

Parameter script


!lock "xxx"     !!!!!!!!!!!!! tryied to pass data from DATA[] to other 
!values "xxx" xxx !!!! !! parameters or variables---doesn't work----


values "_intype" "dbsetname" ,"iscomp" ,"keycode" ,"keyname" ,"code" ,"name" ,"fullname" ,"quantity" ,"totquantity" ,"unitname" ,"unitformatstr" ,"propobjname"




IF _intype = "dbsetname" then values "intype" 1
IF _intype = "iscomp" then values "intype" 2
IF _intype = "keycode" then values "intype" 3
IF _intype = "keyname" then values "intype" 4
IF _intype = "code" then values "intype" 5
IF _intype = "name" then values "intype" 6
IF _intype = "fullname" then values "intype" 7
IF _intype = "quantity" then values "intype" 8
IF _intype = "totquantity" then values "intype" 9
IF _intype = "uniname" then values "intype" 10
IF _intype = "unitformatstr" then values "intype" 11
IF _intype = "propobjname" then values "intype" 12

sinceV6
Advocate
ispyridis wrote:
Generally filtering within the array can be made only by index.
I tried many combinations of string functions and expressions and nothing works you cannot make string comparisons or filter info by string contents.

for example
IF DATA = "KEYNOTEDB" THEN 
TEXT2 0,J, DATA[i+2]
is not working

if I want to get the keycodes of the descriptors that come from keynotedb
I could filter iscomp for descriptors 0 or 1 then the database "keynotedb" and ask for KEYCODE but this seems not be possible

I also noticed that descriptor info is read first then it reads the components
they are stored linearly in the 1D array in a series of packets of requested values in the order that was requestd by the REQUEST command
Hi.
There are several things going on here. You could certainly use
IF DATA = "KEYNOTEDB" THEN
but you have to make sure that you are comparing the same thing (contents of the array vs checked value): a requested array could be of mixed value types and you could be comparing a numeric value vs a string, and in this case it is better if all of the DATA array contain values like "KEYNOTEDB" for AC to compare. It is quite easy to loose track of this, for example, after your comparison you put
DATA[i+2]
but you just stated that the value in was as string for comparison, so "i+2" wouldn't work.

Filtering within the array, as you point out, can only be done by index number -or any expression that resolves to a number-, so your could be 1 or MyVariable as long as MyVariable resolves to 1 or any number (e.g. MyVariable=1, or =2+3, or =1+anotherNumericVariable)

As with many things in ArchiCAD, it is better to work with integers/index numbers to reference things, so to better understand this, you could use a single integer type parameter and use values{2}. I've found it works great!
So you could have something like this in your parameter script:
DIM iselection[], stSelection[]
iselection[1]=1		:stSelection[1]="dbsetname"
iselection[2]=2		:stSelection[2]="iscomp"
iselection[3]=3		:stSelection[3]="keycode"
iselection[4]=4		:stSelection[4]="keyname"
iselection[5]=5		:stSelection[5]="code"
iselection[6]=6		:stSelection[6]="name"
iselection[7]=7		:stSelection[7]="fullname"
iselection[8]=8		:stSelection[8]="quantity"
iselection[9]=9		:stSelection[9]="totquantity"
iselection[10]=10	:stSelection[10]="uniname"
iselection[11]=11	:stSelection[11]="unitformatstr"
iselection[12]=12	:stSelection[12]="propobjname"

values{2} "intype" iselection,stSelection

!!!OPTIONAL VALUE ASSIGNMENT
!!!values{2} "intype",\
!!!1,"dbsetName",\
!!!2,"iscomp",\
!!!3,"keycode",\
!!!4,"keyname",\
!!!5,"code",\
!!!6,"name",\
!!!7,"fullname",\
!!!8,"quantity",\
!!!9,"totquantity",\
!!!10,"uniname",\
!!!11,"unitformatstr",\
!!!12,"propobjname"

You'll notice that your integer parameter gives text descriptions instead of the numeric value. The first way (with two arrays) is the better option as it would allow you to iterate between all array values in a loop, or call anything based on the selection, you just have to manage two arrays. The second, more static option will let you have index and value in the same sentence but wouldn't give you looping options. Works great when giving simple options to the user to select from.
In both cases, you would use the integer values in the script, e.g.
IF intype=5
!!!you know that 5=code
IF intype=iselection[5]
!!!but this is exactly the same as just using "5"
Be careful to NOT use
IF intype="code"
!!!intype is an integer parameter!
IF intype=stSelection[5]
!!!intype is an integer parameter!
I would place both arrays (integer and descriptors) in master script though, and just leave values{2} in parameter script.
This integer logic helps a lot when working with arrays, databases, keycodes and descriptors.

Best regards.
Anonymous
Not applicable
Hi SinceV6,

in your answer you state:
It is quite easy to loose track of this, for example, after your comparison you put

Code:
DATA[i+2]

but you just stated that the value in was as string for comparison, so "i+2" wouldn't work.


__i__ is an index counter and is integer
the data we don't know but what we do know is the sequence.
what I'm trying to do is point out the second record after the record "keynotedb"

Another thing is that string arrays can be compared string by string. Frank Beister in a GDLTips.zip has an example for sorting alphabetically the contents of an array.

The problem is when you request the data array. For some reason they are not stored as simple characters I think, so the data cannot pass on other variables or parameters.

just try to store the results in another array and then text2 that array. you will not get satisfactory results
sinceV6
Advocate
ispyridis wrote:
Hi SinceV6,

in your answer you state:
It is quite easy to loose track of this, for example, after your comparison you put

Code:
DATA[i+2]

but you just stated that the value in was as string for comparison, so "i+2" wouldn't work.


__i__ is an index counter and is integer
the data we don't know but what we do know is the sequence.
what I'm trying to do is point out the second record after the record "keynotedb"

Another thing is that string arrays can be compared string by string. Frank Beister in a GDLTips.zip has an example for sorting alphabetically the contents of an array.

The problem is when you request the data array. For some reason they are not stored as simple characters I think, so the data cannot pass on other variables or parameters.

just try to store the results in another array and then text2 that array. you will not get satisfactory results


Hi.
Oh! My bad. Misinterpreted the result (like
value in is a string, asking for value+2 won't work, instead of [i+2]). See how easy it is to loose track?
I know arrays can be compared value by value (be it a string or number), that's why I said you could actually use
IF DATA = "KEYNOTEDB" THEN
But if "i+2" is not working, then something else is happening. You might not have anything there, not have that exact value "KEYNOTEDB" (so IF is FALSE) or even be running out of values by asking for [i+2] in a loop.

Requested arrays could yield mixed value types in a single array, so you could end up with strings and numbers in each array element. I haven't tested the extent of an array's main type (the type of the first value), so can't tell if it has anything to do. If the request result is a mixed type array, you have to be careful to check the type of value you are trying to give to a parameter, as parameters have a fixed type. You could do that with variables, as they can change type depending on the given value. You can use VARTYPE(value) to check each array element. Function will return 1 for numbers, 2 for strings.

I don't have any issues when passing values to another array and using text2, but it would depend on how you are trying to make it work.

Great work nonetheless.
Best regards.
Anonymous
Not applicable
Hi SinceV6

Your comments are always helpful

You were right about the mixed arrays.

The array to be able to be manipulated has to have stored a common kind of information.

I attach below my last atempt with some basic sorting capabilities.

I wish someone could show us how to use the user interface of the label for text style control
Also when you chose to hide the arrow the whole label disappears

Best Regards
sinceV6
Advocate
Hello!
Glad I could help a bit.
You can manipulate arrays whatever the content. You just have to know what the values are so you can act accordingly. In your previous example, I added this to the 2D script to understand the array's content:
DIM texts[][]
FOR i=1 TO n
	texts[1] = DATA
	IF VARTYPE(DATA)=1 THEN texts[2]="number" ELSE texts[2]="string"
NEXT i

FOR i=1 TO n
	text2 4,0,texts[1]
	text2 12,0,texts[2]
	ADD2 0,-1
	IF i MOD 12 = 0 THEN LINE2 0,0,15,0
NEXT i

DEL n
In the current example, I think you could simplify things a lot. I didn't really dig that much in the code to understand what you are trying to do, but I don't think you need to separate everything into different arrays (don't take my word on it though).
If you need to do that, you could use a single loop to distribute the values into the different arrays, and another one to call the respecting values.

Best regards.