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.

Script run with Layout Number update

owen
Newcomer
hi all,

I'm having a mental block trying to solve a script update issue with a Titleblock object placed on a layout.

What i'm doing is requesting the layout number and using this parameter to determine what style of title block should be displayed for that layout - e.g Documentation vs Presentation. The problem i'm having is the object does not seem to read a change to the Layout Number unless you open the object settings dialog. As soon as I do this i can see in the Preview that the title block has read the layout number and changed appropriately, but I have to click OK for the object to update ... which is defeating the point of this system (mass title block style changes rather than layout-by-layout).

Here is the relevant script used in the Master Script - the integer parameter 'mi_SheetStyle' is then used in a GOSUB to point to the correct style:
	ii=REQUEST ("HomeDB_info", "", mi_ID, mi_LayoutNumber, mi_LayoutName, mi_context)
	
        ...

	mi_SheetStyleStr = ''
	PARAMETERS mi_SheetStyleStr = STRSUB(mi_LayoutNumber, 1, 4)
	PARAMETERS mi_DwgNumLen = STRLEN(mi_DwgNum)

	! mi_SheetStyle Values
	! 1 = Documentation
	! 2 = DA
	! 3 = Sketch
	! 4 = Feasibility

	IF STRLEN(mi_DwgNum) = 9 THEN PARAMETERS mi_SheetStyle = 1
	IF STRLEN(mi_DwgNum) = 12 THEN
		IF STRSTR (mi_LayoutNumber, "DA") > 0 THEN PARAMETERS mi_SheetStyle = 2
		IF STRSTR (mi_LayoutNumber, "SK") > 0 THEN PARAMETERS mi_SheetStyle = 3
		IF STRSTR (mi_LayoutNumber, "FE") > 0 THEN PARAMETERS mi_SheetStyle = 4
	ENDIF
	IF STRLEN(mi_DwgNum) <> 9 AND STRLEN(mi_DwgNum) <> 12 THEN PARAMETERS mi_SheetStyle = 1
There is probably a more elegant way of doing the last bit but it works for the moment.

Can anyone identify a problem in the above which would be causing this to only be run when the object settings dialog is opened? I thought the object script should be run whenever the layout is activated, zoomed, etc.

[Edit]: I am using PARAMETERS commands as I need to pass these parameters to a Macro object which draws the actual title block. It seems this is the problem - the PARAMETERS are not regenerated as I used the above script directly in the Macro object without the PARAMETERS cmds and the object instantly picks up the Layout Number change. Problem is I need to use a Macro - is there any way around using PARAMETERS to store values to pass to a called Macro?

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
3 REPLIES 3
Jochen Suehlo
Moderator
Please try to check, if it helps, when you not only set the parameters by the PARAMETERS command, but set the variables as well.
It is a normal behaviour, that parameters only change (running of the Parameters Script) when an object is run in the settings dialog and you click ok.
Maybe the object reads the changes, but does not change the parameters, but maybe not. If it does, it should help, when you set the variables too.
Example:

IF STRLEN(mi_DwgNum) = 9 THEN  
mi_SheetStyle = 1 
PARAMETERS mi_SheetStyle = mi_SheetStyle 
ENDIF
I think, you do not need to set parameters to pass them to a macro; in my opinion you can pass variables to the macro as well.
Jochen Suehlo . AC12-27 . MAC OSX 14.4 . WIN11
GDL object creation: b-prisma.de
owen
Newcomer
Joachim,

Thanks for your help ... that worked, and now its not so late your explanation makes total sense to me.

I did try passing variables direct to the macro but could not get it to work:

1. If the variable was generated in the caller and only used in the macro then it was uninitialized and the called object did not display.

2. If i initialized the variable in the Macro (e.g mi_SheetStyle = 1) then it isn't changed by the caller (or it is but then overwritten by this default value (1) which is read after the variable value passed from the Caller if i understand my script sequence correctly)

3. If i initialized the variable in the Macro by adding as a parameter with a default value then the default parameter value isn't changed by the variable in the caller (this requires a PARAMETERS statement)

.. Point 3 led me to setting as a parameter in the caller as well, then it works.

But there is a good chance i am just not doing it right ... what is the correct way to pass a variable from Caller to Macro?

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
Jochen Suehlo
Moderator
Owen, I don't know if I understand you right, but try this:

1. a caller object must not have to pass parameters;
example Master-Script:
CALL "testwuerfel" PARAMETERS A=1, B=2, zzyzx = 3
the passed values are fixed variables.
This PARAMETERS statement does not work the same as the one, that sets parameters within an object. But I don't know if you get the same problem then with the parameters that only change when you go to the settings dialog and click ok; i haven't checked this.

2. the called object must have the passed values as parameters, which means that the passed values have to be declared as parameters in the parameter section of the GDL editor.
example 3D in macro:
BLOCK a,b,zzyzx
2D:
PROJECT2 3,270,2
TEXT2 0,0,STR(A,4,2)+","+STR(b,4,2)+","+STR(zzyzx,4,2)

the 2d-plan of the caller shows the correct dimensions (text) of the passed values 1,2,3.
Jochen Suehlo . AC12-27 . MAC OSX 14.4 . WIN11
GDL object creation: b-prisma.de