BIM Coordinator Program (INT) April 22, 2024
Find the next step in your career as a Graphisoft Certified BIM Coordinator!
Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.
SOLVED!

IF-OR-THEN Statement

Lingwisyer
Guru
Hi all,

I appear to be unable to create an IF-OR-THEN Statement. When I try, the statement is ignored...

If _clean = 1 then
	If GLOB_VIEW_TYPE = 4 or 5 then
			_status = 8
		else
			_status = 15
	endIf
endIf

I would rather not need to duplicate the statement for each case...



Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Nader Belal
Mentor
Try this one

If _clean = 1 then
	If (GLOB_VIEW_TYPE = 4 or GLOB_VIEW_TYPE = 5) then
			_status = 8
		else
			_status = 15
	endIf
endIf
A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.

View solution in original post

11 REPLIES 11
Barry Kelly
Moderator
What script are you using this in?
It is view dependent so won't work in parameter (master) or property scripts.

Barry.
One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Lingwisyer
Guru
I tried it in the Master and 3D scripts.

If I put just one of the views it works fine in the Master.



Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
Barry Kelly
Moderator
I would be wary of using it in the master script.
It may seem OK when you are looking at your object in 2D or 3D as the master script is run before the 2D and 3D scripts.
But it is also run before the parameter script is run so if you are adjusting parameters it may return the wrong values.
The master script is run many times when you interact with an object.

It is better to just be in the 2D and/or 3D scripts.

Barry.
One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Solution
Nader Belal
Mentor
Try this one

If _clean = 1 then
	If (GLOB_VIEW_TYPE = 4 or GLOB_VIEW_TYPE = 5) then
			_status = 8
		else
			_status = 15
	endIf
endIf
A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.
Lingwisyer
Guru
No difference...

If _clean = 1 then
		_status = 8
		PARAMETERS _status = 8
	else
		_status = 15
		PARAMETERS _status = 15
endIf

I can get the parameter to change by using that in the Parameter Script, but am unable to link it to the view type...



Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
Barry Kelly
Moderator
Lingwisyer wrote:
I can get the parameter to change by using that in the Parameter Script, but am unable to link it to the view type...
Remember GLOB_VIEW_TYPE is view dependant so will not work in the master script when it is run as the parameter script (i.e. you can not set the parameter).
And of course you can not set the parameters from the 2D or 3D scripts either.

Barry.
One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Lingwisyer
Guru
I tried that above in the Parameter Script with a different section in the 3D Script to make A = B with the view but that did not work... This is all for a status code toggle in the 3D Script but so far making any changes to the status code variable within the same script has broken it...



Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
Barry Kelly
Moderator
You can set the status code for use in the 2D and 3D scripts, but you can't set a parameter for it as you can't do that from the 2D and 3D scripts.

You can only set the parameter from the master or parameter script, but you can't use GLOB_VIEW_TYPE there.

So you will have to determine the GLOB_VIEW_TYPE at the beginning of the 2D and 3D script to set your status code.
The following parts of those scripts can then use that status code - but you will never see it as a parameter if that is what you are trying to do.

Barry.
One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Lingwisyer
Guru
I originally had the code in my original post in the 3D script but got an error about an undefined variable later in the script regarding the output of the IF statement.

If _clean = 1 then
		If (GLOB_VIEW_TYPE = 4 or GLOB_VIEW_TYPE = 5) then status = 8
	else
		_status = 15
endIf

The following section returns an error about an undefined variable.

cprism_ louvtopmat, louvbotmat, louvsidemat,
	5, gs_louvre_thk,
	-a / 2 + gs_fw_side_right + gs_int_fw,	-(gs_louvre_width) / 2,	_status,
	-a / 2 + gs_fw_side_right + gs_int_fw,	 (gs_louvre_width) / 2,	_status,
	 a / 2 - gs_fw_side_left - gs_int_fw,	 (gs_louvre_width) / 2,	_status,
	 a / 2 - gs_fw_side_left - gs_int_fw,	-(gs_louvre_width) / 2,	_status,
	-a / 2 + gs_fw_side_right + gs_int_fw,	-(gs_louvre_width) / 2,	-1

Even if I put "_status = 15" at the start, it will say that it is undefined and will not generate the relevant parts properly... It effectively uses "_status = 0". If I define it in the parameters, then it will use that instead...


Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
Learn and get certified!