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

Limiting Range Of Parameter Arrays

Anonymous
Not applicable
Hi all,
I am trying to figure out how to create a limit range for an object with parameter arrays, using a loop.
basically it is just a grid with adjustable grid line lengths controlled by loops:

for i = 1 to nGridLines
add2 gridLineX, 0
gosub “Grid Line”
del 1
next i

however i want to limit the minimum & maximum spacing for the grid spacing:
this is what i would do if it was not an array:

VALUES "gridXPosition" Range [1, 5]

Help me please!

Thank you
33 REPLIES 33
Anonymous
Not applicable
Hi Olivier,
When you pass a parameter to objects, is a new memory holder used each time or is it the same one?
That's a good question...

I'm not sure, but my feeling is: as all macros have to be loaded in order to have a correct object function, I presume that each macro has its own reserved memory stack... Therefore all those giant arrays would contribute to the slowdown of the object.

But as I said its just my gut feeling...

BTW... I was talking other day with our good friend Frank Beister about array handling methods and he showed me a brilliant way to "shrink" dynamic arrays!

He even created a sample code object with the method... which I'm posting in attachment.

I thought there would be lots of people here on the forum that would appreciate this precious information.

Thank you very much Frank!
Anonymous
Not applicable
Thanks Paulo for the nice function.
Although I would like to have the point of view of Zsolt about the slowdown, especially when it comes to moving hostspots.(this giant arrays generate moveable hostspots)
owen
Newcomer
Hi guys,

This thread has been very helpful - i've always struggled with arrays a little but after reading through this several times and working through the GS object Zsolt mentioned i think i have a pretty good grasp of whats going on. Armed with the array tips discussed here i was going to fix a bunch of objects i have known arrays would have simplified greatly, but had never really gotten down to doing it
.
.
or so i thought i did
.
.

I'm having problems with a pretty simple set of arrays designed to create a vertical dynamic array of elements and have each elements profile be selectable from a range of options.

The first part is working well with a parameter for the number of elements and then editable hotspots controlling the dimension between each element being fed into the first array.

The second array is meant to store a text value for the type of each element .. A, B, C or D. The script for this array is duplicated from above, with parameter names changed and values changed from dimension to text. However a couple of things are not working or only part working:

1. Default initial value of 'A' set in the Master script is only passed into the first array value, the other 4 are empty until set by the user (see attached image)
TEXT2 0,0, STR(fjmt_pc_n_h,8,3)+'-'+fjmt_pc_n_type
The above works in the 2D script to display the dimension between elements and also the type. This shows that when the object is first placed the type array is not being filled with default values, but that these can be subsequently set and stored. Sometimes the type value seems to get passed to other array values when editing (e.g change to edit element 2 and this also edits element 3 type)
	IF fjmt_pc_n_type='A' THEN fjmt_gen_rad=0.100
	IF fjmt_pc_n_type='B' THEN fjmt_gen_rad=0.200
	etc
The above IF statements do not work in the 3D Script to set the element radius as the element type parameter is not returning a value

i will post the scripts in a following post

i have a feeling i am missing something really obvious but its too late for me to see it

any clues?

cheers,

owen
cheers,

Owen Sharp

Design Technology Manager
fjmt | francis-jones morehen thorp

iMac 27" i7 2.93Ghz | 32GB RAM | OS 10.10 | Since AC5
owen
Newcomer
[EDIT] In cleaning up the script to test i missed a couple of lines (did not fix the problem, they were only lines to update the 'fjmt_pc_n_prev' counter). I have not updated the attached GSM as i have moved on from this version. I'm now editing each array value directly via the Interface script which works, although somewhat limiting. However I'm still looking for the reason behind the editing method shown here not passing the string values into the array

apologies for posting the whole script - i've attached the object but thought i might save people having to download and open it to check

!===========================================================================================
!MASTER SCRIPT
eps = 0.00001
unID=1

IF GLOB_MODPAR_NAME = 'fjmt_pc_n_edit' THEN
	DIM temp1[]
	DIM temp2[]

	FOR i= 1 to fjmt_pc_n
		temp1 = 0.500
		temp2 = 'XX'
	NEXT i

	IF fjmt_pc_n < fjmt_pc_n_prev THEN
		FOR i= 1 to fjmt_pc_n
			temp1 = fjmt_pc_n_h
			temp2 = fjmt_pc_n_type
		NEXT i
	ELSE
		FOR i= 1 to fjmt_pc_n_prev
			temp1 = fjmt_pc_n_h
			temp2 = fjmt_pc_n_type
		NEXT i
	ENDIF

	PARAMETERS fjmt_pc_n_h = temp1 : fjmt_pc_n_h = temp1
	PARAMETERS fjmt_pc_n_type = temp2 : fjmt_pc_n_type = temp2
	PARAMETERS fjmt_pc_n_prev = fjmt_pc_n : fjmt_pc_n_prev = fjmt_pc_n
ENDIF


!===========================================================================================
!PARAMETER SCRIPT

VALUES 'fjmt_pc_n' RANGE [1,)
VALUES 'fjmt_pc_n_type_f_edit' RANGE [1,4]
VALUES 'fjmt_pc_n_type_edit' 'A','B','C','D'

!-------------------------------------------------------------------------------------------
!GET Panel Number Editors from Panel Number Array Values

IF GLOB_MODPAR_NAME = "fjmt_pc_n_edit" THEN
	PARAMETERS fjmt_pc_n_h_edit = fjmt_pc_n_h[fjmt_pc_n_edit] : fjmt_pc_n_h_edit = fjmt_pc_n_h[fjmt_pc_n_edit]
	PARAMETERS fjmt_pc_n_type_edit = fjmt_pc_n_type[fjmt_pc_n_edit] : fjmt_pc_n_type_edit = fjmt_pc_n_type[fjmt_pc_n_edit]
ENDIF

!-------------------------------------------------------------------------------------------
!PUT Panel Number Editors to Panel Number Arrays

IF GLOB_MODPAR_NAME = "fjmt_pc_n_h_edit" THEN
	PARAMETERS fjmt_pc_n_h[fjmt_pc_n_edit] = fjmt_pc_n_h_edit : fjmt_pc_n_h[fjmt_pc_n_edit] = fjmt_pc_n_h_edit
ELSE
	fjmt_pc_n_h_edit = fjmt_pc_n_h[fjmt_pc_n_edit]
	PARAMETERS fjmt_pc_n_h_edit = fjmt_pc_n_h_edit
ENDIF

IF GLOB_MODPAR_NAME = "fjmt_pc_n_type_edit" THEN
	PARAMETERS fjmt_pc_n_type[fjmt_pc_n_edit] = fjmt_pc_n_type_edit : fjmt_pc_n_type[fjmt_pc_n_edit] = fjmt_pc_n_type_edit
ELSE
	fjmt_pc_n_type_edit = fjmt_pc_n_type[fjmt_pc_n_edit]
	PARAMETERS fjmt_pc_n_type_edit = fjmt_pc_n_type_edit
ENDIF

!-------------------------------------------------------------------------------------------
!Set & Get Number of Panels for Panel Count

FOR i = 1 TO fjmt_pc_n
	PUT i
NEXT i

VALUES 'fjmt_pc_n_edit' GET (fjmt_pc_n)


!===========================================================================================
!2D SCRIPT


PEN 1
HOTSPOT2 0,0

FOR i=1 TO fjmt_pc_n
	HOTSPOT2 0,0
	TEXT2 0,0, STR(fjmt_pc_n_h,8,3)+'-'+fjmt_pc_n_type
	ADD2 0,fjmt_pc_n_h
NEXT i
DEL i-1

PROJECT2 3,270,2



!===========================================================================================
!3D SCRIPT

HOTSPOT 0, 0, 0
HOTSPOT A, 0, 0

FOR i=1 TO fjmt_pc_n 
	HOTSPOT 0, 0, 0, unID, fjmt_pc_n_h, 1+128 : unID = unID +1 			!Base
	HOTSPOT 0, 0, fjmt_pc_n_h, unID, fjmt_pc_n_h, 2 : unID = unID +1 	!Moving
	HOTSPOT 0, 0, -1, unID, fjmt_pc_n_h, 3 : unID = unID +1				!Reference
	ADDx A
		HOTSPOT 0, 0, 0, unID, fjmt_pc_n_h, 1+128 : unID = unID +1 			!Base
		HOTSPOT 0, 0, fjmt_pc_n_h, unID, fjmt_pc_n_h, 2 : unID = unID +1 	!Moving
		HOTSPOT 0, 0, -1, unID, fjmt_pc_n_h, 3 : unID = unID +1				!Reference
	DEL 1

	ADD 0, 0, fjmt_pc_n_h

	GOSUB 1: !fjmt_pc_n_type_f
NEXT i
DEL i-1

!-------------------------------------------------------------------------------------------

END !End of 3D Script

!===========================================================================================
!SUBROUTINES
!===========================================================================================
!-------------------------------------------------------------------------------------------
1: !Louvre
	
	fjmt_gen_mat1=1
	fjmt_gen_mat2=1
	fjmt_gen_w1=A

	IF fjmt_pc_n_type='A' THEN fjmt_gen_rad=0.100
	IF fjmt_pc_n_type='B' THEN fjmt_gen_rad=0.200
	IF fjmt_pc_n_type='C' THEN fjmt_gen_rad=0.500
	IF fjmt_pc_n_type='D' THEN fjmt_gen_rad=0.750

	ROTz -90
	ROTx 90

	MATERIAL fjmt_gen_mat1
	CYLIND 	-fjmt_gen_w1, fjmt_gen_rad
	DEL 2
		
RETURN
cheers,

Owen Sharp

Design Technology Manager
fjmt | francis-jones morehen thorp

iMac 27" i7 2.93Ghz | 32GB RAM | OS 10.10 | Since AC5