Learn to manage BIM workflows and create professional Archicad templates with the BIM Manager Program.

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

Change of parameter under the set list and ...

Anonymous
Not applicable
Hello, experts!
Help me solve a problem(task):

The parameter "B" can have any value.
The parameter "D" should accept the nearest value from the list greater or equal "B".
Example of the list:
RANGE[8, 20]STEP 2,
25, 30, 35,
RANGE[40, 130]STEP 5

That is, if "B" = 27, then "D" = 30.
If "B" = 40, then "D" = 40.
If "B" = 41, then "D" = 45.

How it to make? And how to make the list?
8 REPLIES 8
Frank Beister
Moderator
Why to use a second parameter "D"?

Can you post the whole script, you want to use? Or describe exactly, why you want to use two parameters?

Which AC you are working with?
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Anonymous
Not applicable
Hello, F. Beister.
I try to alter a library part "Schraube" under other standard. "Schraube" is on www.opengdl.org. It, apparently, your site. In picture are shown the parameters. In an original variant the step of parameter "D" makes 5 mm. I want to make so that "D" changed under the established list. It is not necessary to consider a library part. It is better to consider the simplified variant. The principle which can be applied in other parts is important.

I work in ÀÑ7.
Schraube.gif
Anonymous
Not applicable
In the first message I have allowed discrepancy in the list. Here I give more exact list.

!RANGE[8, 22)STEP 2,
!RANGE(22, 28)STEP 3,
!RANGE(28, 32)STEP 2,
!RANGE(32, 38)STEP 3,
!RANGE(40, 130)STEP 5,
!RANGE(130, 200)STEP 10,
!RANGE(200, 300]STEP 20

Has found the following decision:

IF B < 0.022 THEN
D = 0.008
D_step = 0.002
ENDIF

IF B > 0.022 AND B < 0.028 THEN
D = 0.022
D_step = 0.003
ENDIF

IF B > 0.028 AND B < 0.032 THEN
D = 0.030
D_step = 0.002
ENDIF

IF B > 0.032 AND B < 0.038 THEN
D = 0.032
D_step = 0.003
ENDIF

IF B > 0.038 AND B < 0.130 THEN
D = 0.040
D_step = 0.005
ENDIF

IF B > 0.130 AND B < 0.200 THEN
D = 0.130
D_step = 0.010
ENDIF

IF B > 0.200 THEN
D = 0.200
D_step = 0.020
ENDIF

FOR j = 0 TO (B - D)/ D_step
D = D + D_step
NEXT j

Very long script has turned out. It is possible to make it more shortly?
Frank Beister
Moderator
Because you work with AC7 you can't use the graphical hotspots, which would make it very comfortable to edit.

I would change the script to

lang=INT(B/0.001)*0.001
IF B>=0.008 then lang = 0.008 + INT((B-0.008)/0.002)*0.002
IF B>=0.022 then lang = 0.022 + INT((B-0.022)/0.003)*0.003
IF B>=0.028 then lang = 0.028 + INT((B-0.028)/0.002)*0.002
IF B>=0.032 then lang = 0.032 + INT((B-0.032)/0.003)*0.003
IF B>=0.040 then lang = 0.040 + INT((B-0.040)/0.005)*0.005
IF B>=0.130 then lang = 0.130 + INT((B-0.130)/0.010)*0.010
IF B>=0.200 then lang = 0.200 + INT((B-0.200)/0.020)*0.020
I haven't tested, so be aware of bugs.

If you are successful, remember that the deeper sense of openGDL is to return improvements to the community. 😉
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Anonymous
Not applicable
F. Beister, I thank for participation.
I too tried to use function INT, but have not achieved the necessary result.

Let's consider one set of numbers (IF B> =0.008 then...), the rest works similarly.
So, there will be following results:
IF B=0.009, then lang=0.008! Corrects to smaller value. It is necessary to correct to the greater value.
IF B=0.010, then lang=0.010! Result true.

I have tried to make change.
IF B> =0.008 then lang = 0.008 + INT ((B-0.008+0.002)/0.002) *0.002
Has received the following results:
IF B=0.009, then lang=0.010! Corrects to the greater value. Result true.
IF B=0.010, then lang=0.012! Result incorrect. There should be identical values.

There are still ideas?
If you are successful, remember that the deeper sense of openGDL is to return improvements to the community
I adapt an element for the standard of GOST (Russia). And it will be freely distributed. Whether it will be interesting in Europe or in other countries?
Frank Beister
Moderator
Try this:

IF B>=0.008 then lang = 0.008 + INT((B-0.008)/0.002+0.0019)*0.002

I thought indeed, that you want to round down, not up. You need to be the smallest value below the next step.

What is "the standard of GOST"?
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Oleg
Expert
May be something like this will work. It is like Frank's solution, but I think it is more readable due using of millimeters.

B = 1000*B
IF B<=8 then B = 8
IF B>8 AND B<=22 THEN B = 8 + CEIL((B-8 )/2)*2
IF B>22 AND B<=28 THEN B = 22 + CEIL((B-22)/3)*3
IF B>28 AND B<=32 THEN B = 28 + CEIL((B-28 )/2)*2
IF B>32 AND B<=40 THEN B = 32 + CEIL((B-32)/3)*3
IF B>40 AND B<=130 THEN B = 40 + CEIL((B-40)/5)*5
IF B>130 AND B<=200 THEN B = 130 + CEIL((B-130)/10)*10
IF B>200 THEN B = 200 + CEIL((B-200)/20)*20
B = B/1000

PS: Actually I think a more flexible solution will be using an array and a subroutine which will search the range and do the calc finally.
Anonymous
Not applicable
Perfectly!
The decision laid on a surface. It is necessary more? Use CEIL (). It is necessary less? Use INT ().
Use of function CEIL (), yields identical results with my first script.
If "B" = 39, then "D" = 40.
If "B" = 40, then "D" = 40.
Thanks, Oleg! Thanks, Frank!
Actually I think a more flexible solution will be using an array and a subroutine which will search the range and do the calc finally.
This idea was the first in my head. But absence of knowledge, has led to to search of other method.
What is "the standard of GOST"?
GOST are standards used in Russia. As DIN in Germany.