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

GDL
About building parametric objects with GDL.
SOLVED!

Material is forgotten in a 3D subroutine

Sam Karli
Enthusiast

In a moderately complicated 3D script, that uses multiple subroutines (one calling another in a tree-like order) i have a material defining

 

 

 

 

 

! ---------------------------------
"Venting Window":
! ---------------------------------
! ---------------- Outer Frame ----------------
	addz yFrameIn
	print mFrameOut
		_mat		= mFrameOut
		_profile	= prFrameOut
		_xProfSize	= xFrameOut
		_yProfSize	= yFrameOut
		_xRectL		= 0
		_xRectR		= wFrame
		_yRectT		= -_hFrame
		_yRectB		= 0

		gosub "DrawRectangularFrame"
	del 1

 

 

 

 

where mFrameOut is a valid parameter of the script.

 

 

 

 

! ---------------------------------
"DrawRectangularFrame":
! ---------------------------------
!	_mat - material
!	_profile - profile ID to draw
!	_xProfSize, _yProfSize - if _profile = 0, profile rectangle height and width
!	_xRectL, _xRectR, _yRectT, _yRectB - path left, right, top, bottom corners

	_ = _mat			! Dummy op
	material _mat		!_mat

	if _profile then
		_autoShiftProfiles  = bAutoShiftProfiles

		gosub "GetProfile"
	endif

	if _bProfError | not(_profile) then
		put 0,			0,			 0
		put _xProfSize,	0,			 0
		put _xProfSize,	_yProfSize,	 0
		put 0,			_yProfSize,	 0
		put 0,			0,			-1
	endif

	TUBE nsp/3, 7, 1 + 2,
		get(nsp),

		_xRectL + 1,	_yRectB,		0,	0,

		_xRectL,		_yRectB,		0,	0,
		_xRectL,		_yRectT,		0,	0,
		_xRectR, 		_yRectT,		0,	0,
		_xRectR,  		_yRectB,		0,	0,
		_xRectL, 		_yRectB,		0,	0,

		_xRectL, 		_yRectB - 1,	0,	0
return

 

 

 

 

problem is that if the

    _ = _mat            ! Dummy op
(or print _mat, anything using that _mat variable)
row is missing/commented out the material command in the next row will practically no effect: the material will not be set.
If I print out the material etc, it looks like having the right numeric ID all the time.
Looks like a lóbaszó nagy bug.
Original development was done in AC26 and now I check it in AC27, both versions having this bug (this workaround fix using the _ variable is done in AC27, I haven't checked it in AC26). BTW I have used similar approaches (in previous ArchiCADs) and haven't seen anything similar.
Note that _mat variable is only used here, so I think there is no any hidden overwriting that.
GDL/Python/C++ dev
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Jochen Suehlo
Moderator

Sometimes it happens that variables declared in a subroutine which is laid physically below the place where the variable is used, the variable cannot be found by the GDL interpreter. This always happens with Array declarations. I never had this before with material declerations, but in your case is it so.
Please place the subroutine "DrawRectangularFrame":

at the end of the script: then it works (for me it did).

Jochen Suehlo . AC12-27 . MAC OSX 14.4 . WIN11
GDL object creation: b-prisma.de

View solution in original post

5 REPLIES 5
Jochen Suehlo
Moderator

In this script the material is correctly set (AC 26 macOS):

! ---------------------------------
"Venting Window":
! ---------------------------------
! ---------------- Outer Frame ----------------
	addz yFrameIn
	!print mFrameOut
		_mat		= mFrameOut
		_profile	= 1
		_xProfSize	= 1
		_yProfSize	= 1
		_xRectL		= 0
		_xRectR		= 1
		_yRectT		= -1
		_yRectB		= 0
		_bProfError = 1

		gosub "DrawRectangularFrame"
	del 1

! ---------------------------- E N D ----------------------------------- !
! ---------------------------- E N D ----------------------------------- !

END  ! -- END -- END -- END -- END -- END -- END -- END -- END -- END -- !

! ---------------------------- E N D ----------------------------------- !
! ---------------------------- E N D ----------------------------------- !

! ---------------------------------
"DrawRectangularFrame":
! ---------------------------------
!	_mat - material
!	_profile - profile ID to draw
!	_xProfSize, _yProfSize - if _profile = 0, profile rectangle height and width
!	_xRectL, _xRectR, _yRectT, _yRectB - path left, right, top, bottom corners

	material _mat		!_mat

	if _profile then

		gosub "GetProfile"
	endif

	if _bProfError | not(_profile) then
		put 0,			0,			 0
		put _xProfSize,	0,			 0
		put _xProfSize,	_yProfSize,	 0
		put 0,			_yProfSize,	 0
		put 0,			0,			-1
	endif

	TUBE nsp/3, 7, 1 + 2,
		get(nsp),

		_xRectL + 1,	_yRectB,		0,	0,

		_xRectL,		_yRectB,		0,	0,
		_xRectL,		_yRectT,		0,	0,
		_xRectR, 		_yRectT,		0,	0,
		_xRectR,  		_yRectB,		0,	0,
		_xRectL, 		_yRectB,		0,	0,

		_xRectL, 		_yRectB - 1,	0,	0
return

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


"GetProfile":

PUT 0, 0,0,
0, 0, 1,
1, 0, 1,
1,0, 0


RETURN

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

 

Jochen Suehlo . AC12-27 . MAC OSX 14.4 . WIN11
GDL object creation: b-prisma.de
Jochen Suehlo
Moderator

What happens, if you put "

material _mat

after

gosub "GetProfile"
Jochen Suehlo . AC12-27 . MAC OSX 14.4 . WIN11
GDL object creation: b-prisma.de
Sam Karli
Enthusiast

Hi,

thanks for Your answers, I think the bug shouldn't come out for short scripts (it's too eye-popping), so I have put here the whole gsm (standalone), AC27 .gsm.

The difference is something like this:

SamKarli_0-1698162316258.png

and if You comment out 3D script line 280:

    _ = _mat          ! Dummy op
SamKarli_1-1698162381640.png

(the frame is 'grey' instead of the given colour.

 

GDL/Python/C++ dev
Solution
Jochen Suehlo
Moderator

Sometimes it happens that variables declared in a subroutine which is laid physically below the place where the variable is used, the variable cannot be found by the GDL interpreter. This always happens with Array declarations. I never had this before with material declerations, but in your case is it so.
Please place the subroutine "DrawRectangularFrame":

at the end of the script: then it works (for me it did).

Jochen Suehlo . AC12-27 . MAC OSX 14.4 . WIN11
GDL object creation: b-prisma.de
Sam Karli
Enthusiast

Good point, I have seen things like that, too.

 

Thanks

GDL/Python/C++ dev

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!