Design forum
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Ralph Wessel
Mentor
Braza wrote:
Within those 3d hotspots I've created an array parameter called "NodeHeight" and defined it in the parameter list as "NodeHeith[50]"...
The thing is: Am I limited with this 50 instances or can I control it with a specific Dim NodeHeight[] script?...
And of course creating a dynamic (unlimited) number of editable 3d hotspots...
You're not limited to the 50 instances - just add as many rows as you need using the script I showed earlier. Every time you use the parameters statement on an array parameter - referencing an index beyond the array bounds - the array dynamically expands as required. No temporary array is needed.

Refer to the attached image showing some examples of the Modular Joinery object. Every joinery unit, including the large curtain-wall in the background, is a single instance of the same object. Although it starts with enough storage space for just one window, it can expand indefinitely. Each frame can also have a completely different arrangement of frames, windows, doors, and panels hierarchically nested within it (and any arrangement of panes can be nested within any door or window). Every row/column has hotspots for dynamic stretching, but the object only allocates sufficient space for the specified object.
Ralph Wessel BArch

Anonymous
Not applicable
Thanks Piotr and Ralph.

I'll try it later.

Karl Ottenstein
Moderator
Thanks for the excellent examples and explanations, Ralph!

Cheers,
Karl
One of the forum moderators   •   AC 25 USA and earlier   •   MacOS 11.6.5, iMac Pro

Anonymous
Not applicable
Ralph,

I've just tested your tip and it works like a charm!

I've seen the light!... I can drag out the big smile on my face...

I vote this tip as the tip of the decade.

Thank you very much for sharing your knowledge!

p.s.: Just to check: It seems that arrays are dynamic, but they are not "Elastic"... once I expand it I can't shrink it, right?

Ralph Wessel
Mentor
Braza wrote:
Just to check: It seems that arrays are dynamic, but they are not "Elastic"... once I expand it I can't shrink it, right?
Correct. GDL doesn't (yet) provide a mechanism to reclaim space once it has been allocated. However, given that this is isolated to single instances of the object, I don't see it as a significant problem.
Ralph Wessel BArch

Anonymous
Not applicable
Ralph wrote:
Correct. GDL doesn't (yet) provide a mechanism to reclaim space once it has been allocated...
This one would be nice for AC14. 😉

Anonymous
Not applicable
Thanks a lot for these explanations, that's great!

ztaskai
Graphisoft Alumni
Graphisoft Alumni
What a nice conversation developed while I wasn't watching:)

I guess we should add some recommendations to the GDL Technical Standards about handling array parameters... I create a task for it right now!

About shrinking arrays: you can do this using a temporary array. A workaround - I know. I don't think we will provide a GDL command for this in the near future; definitely not in AC14.

Regs,
Zsolt Táskai
ArchiCAD Development - GDL Team
AC13, AC14 and upwards...

Anonymous
Not applicable
Hi Zsolt,
ztaskai wrote:
...About shrinking arrays: you can do this using a temporary array. A workaround - I know...
I'm very interested in this... Could you please show a sample code with your workaround?... Does this workaround has any cons?

Anonymous
Not applicable
Hello all,
as we are in a interesting discussion I'd like to ask one more thing:
In the case of a complicate and heavy object with 3 nested macro calls, does the passing of big array parameters through subobjects make the objects slowlier?
I mean that if you have ten arrays of [50][150] in the first objects and you pass them to the first macro and then to the nested second macro, does such operations take more memory and time than if you would try to limit the arrays passed to the subobjects?
(like 10 items of one dim array of [150] instead of 10 items of [50][150] )

Maybe the question could be:
When you pass a parameter to objects, is a new memory holder used each time or is it the same one?

Hope I'm clear enough

Thanks in advance,
Olivier

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

Didn't find the answer? Start a new discussion

Labels

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!