We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2023-10-24 11:11 AM - last edited on 2024-09-26 01:48 PM by Doreena Deng
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
Solved! Go to Solution.
2023-10-24 06:33 PM
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).
2023-10-24 12:38 PM
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
! ---------------------------------------------------------------------- !
! ---------------------------------------------------------------------- !
2023-10-24 03:32 PM
What happens, if you put "
material _mat
after
gosub "GetProfile"
2023-10-24 05:47 PM
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:
and if You comment out 3D script line 280:
(the frame is 'grey' instead of the given colour.
2023-10-24 06:33 PM
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).
2023-10-25 09:58 AM
Good point, I have seen things like that, too.
Thanks