Home › Forums › Problems and solutions in GDL › Informations from the environment › What is the proper replacement for GLOB_CONTEXT=1?
- This topic has 23 replies, 7 voices, and was last updated 7 years, 11 months ago by Barry Kelly.
-
AuthorPosts
-
-
October 19, 2015 at 16:44 #1762James MurrayParticipant
I can’t figure out the right combination of Script Type, View Type, and Preview Mode to describe the situation being being in the library part editor.
James M
-
October 19, 2015 at 18:07 #1763Gergely FehérKeymaster
There is no replacement for that, GDL Editor’s context can not be described with the new globals. Can you tell me a situation why do you need that?
Gergely Fehér
Team Leader, Library Team
GRAPHISOFT SE -
October 19, 2015 at 19:15 #1764James MurrayParticipant
I found a workaround for the specific case. I was trying to define an array based on the wall skins data, while in the script there was currently 0 skins, which the DIM didn’t like. Turned out I didn’t need the array anyway. So I’ll file this one for now, thank you for the info.
James M
-
October 20, 2015 at 04:55 #1769Barry KellyParticipant
I use it to check settings in existing objects and modify them to new values then set a ‘flag’ parameter to say it has been done so it does not get checked again.
I don’t want this to happen in the GDL editor as I need to save the object with the ‘flag’ parameter set to 0 so I filter that with GLOB_CONTEXT <> 1.
This way it does not reset in the GDL editor but only when the object scripts are run in the model.!!set page type for existing objects so they don't default to wrong object if GLOB_CONTEXT <> 1 then if flag = 0 then if category = "LIGHTING" then if ind_objects = "MOTION SENSOR" then page_type = "SUPERSEDED" else page_type = "LIGHTING" endif endif if category = "POWER" then page_type = "POWER" endif if category = "DATA & SECURITY" then if ind_objects = "NX4 ALARM PANEL" then page_type = "SUPERSEDED" else page_type = "DATA & SECURITY" endif endif if category = "TELSTRA VELOCITY" then if STRSTR(ind_objects, "TELSTRA VELOCITY") > 0 then page_type = "SUPERSEDED" endif endif PARAMETERS page_type = page_type flag = 1 PARAMETERS flag = flag endif endif
A similar situation was posted here in Archicad Talk … https://archicad-talk.graphisoft.com/viewtopic.php?t=50571
Barry.
Versions 6.5 to 22
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit-
October 21, 2015 at 21:14 #1780Gergely FehérKeymaster
I think that a separate context for the editor is not needed: in your example the “flag” parameter should be deleted. It is a much better solution to use the source format of library parts, and modify parameter defaults with the lp_xmlconverter, during the library compilation. In this case, you should force your category parameters default to an empty string with a replacement definition file, and check that value instead of having one more parameter for checking if the default is set.
Gergely Fehér
Team Leader, Library Team
GRAPHISOFT SE
-
-
October 22, 2015 at 07:02 #1781Barry KellyParticipant
Thanks for the reply Gergely but I really didn’t understand it.
I have never used the lp_xmlconverter.
It is not a case of updating the actual library part.
What I am trying to do is trap an actual object instance in a plan.
If it has a certain parameter then swap that.
I only want to check it once which is why the flag parameter gets reset.
If I don’t have the GLOB_CONTEXT <> 1 then the flag will reset in the script editor which I don’t want.
It needs to be off and only reset when I am not editing the script.Not sure if that explains it any clearer.
Basically I need to trap (or exclude) when I am in the GDL editor.
How do I do that without GLOB_CONTEXT.Barry.
Versions 6.5 to 22
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit -
October 22, 2015 at 20:58 #1805Gergely FehérKeymaster
Barry,
There is no solution for that without the GLOB_CONTEXT in the GDL editor. That’s why I told you about the other solution, with the lp_xmlconverter. Use it, it’s a great tool for developers, many things are much easier with it.
Gergely Fehér
Team Leader, Library Team
GRAPHISOFT SE -
October 23, 2015 at 07:14 #1806Kristian GoodsellParticipant
Gergely
I don’t know about anyone else but to me, this ‘no solution’ answer is the exact reason these changes to GDL are not good enough!!!
Barry’s objects are VERY intelligent and have been developed over many years and in one foul swoop, that intelligence is taken away.
And the reasoning of teamwork display outputs varying per user is the weakest excuse I’ve heard in many years!-
October 23, 2015 at 07:40 #1807Gergely FehérKeymaster
Kristian,
I said there is no solution in GDL Editor, it is true. But for this problem, there is a much better, safer solution with using the lpxmlconverter. Setting the defaults for a complex library should be always done from source, professional GDL development can not be done without that, sorry. You simply do not have enough control on your objects without the source format and the checking/finalizing functions of the converter.
Gergely Fehér
Team Leader, Library Team
GRAPHISOFT SE-
October 23, 2015 at 09:25 #1808Kristian GoodsellParticipant
Gergely
I understand that it can be done xml but that only makes me think that the GDL Editor is the broken link not glob_context. GDL is Graphisoft’s own programing language, does it not make sense to provide professional level development tools within the editor designed to edit them?
-
-
-
October 23, 2015 at 09:40 #1809Barry KellyParticipant
I don’t know that the lpxmlconverter will help me with objects already placed in my plans.
Yes it will help me convert from one version to another and maybe even add parameters to an object – I really don’t understand what it does.
But I am sure it will not detect the settings of a parameter that has been placed in a file and then set another parameter based on the settings.I have attached a PDF that has images through it to try and explain my problem better.
Easier than to add individual attachments.Please let me know if what I describe can be done with lpxmlconverter.
Versions 6.5 to 22
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit-
October 30, 2015 at 02:59 #1853Ben CohenParticipant
Hi Barry
This is not really an answer to your glob_context issue. But..
You really need to look at the migration scripts. This is the answer to your problem. With the migration script you can determine the value of that redundant parameter and then set your new hotspot parameter accordingly. Its very very powerful. HTH
-
October 30, 2015 at 03:15 #1854Barry KellyParticipant
Yes I was thinking the same thing.
I have had a look at the manual and it hasn’t sunk in yet how it needs to be scripted.
Looking at examples in the GS library just confused n=me even more.Does anyone have a very simple example of migrating one object to another and setting new parameters based on the values of old object parameters?
Barry.
Versions 6.5 to 22
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit -
October 30, 2015 at 03:24 #1855Ben CohenParticipant
I have used this to migrate a GPO
You have to set the GUID’s in the migration section of the GDL editoractualGuid = FROM_GUID ! ============================================================================== ! Defined new parameters in migration ! ============================================================================== ! ============================================================================== ! electrical Different - (AC13 --> AC15) ! ============================================================================== if actualGuid = "3E6E2AC8-F1D9-4358-A538-5380B32D7718" or actualGuid = "24B2609D-DF7D-304B-9BD8-DEFB38036FFC" then actualGuid = "1498DFCB-525E-F74B-B986-1FFCDF5531AA" if type_gpo = 'Skirting Ht' then PARAMETERS skirting_ht = ZZYZX IF STRSUB(leg_nameTemp,STRLEN(leg_nameTemp)-6,7) = '250 AFL' then parameters skirting_ht = .3 parameters ZZYZX = .3 parameters std_leg_name = 1 endif endif ! ============================================================================== ! Set migration GUID ! ============================================================================== SETMIGRATIONGUID actualGUID MIGRATIONWARNING 'note this is migrated forward'
-
October 30, 2015 at 03:58 #1856Barry KellyParticipant
Thanks Ben.
I’ll have to sit down and give it a shot.Barry.
Versions 6.5 to 22
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit
-
-
-
October 26, 2015 at 23:29 #1821Kristian BursellParticipant
I tend to agree with Kristian and Barry. I am fortunate that I have not used the process Barry describes but it is quite clever and I definitely see the need for it. There are certain modifications i just don’t make because of the damage they would cause to placed objects. It is such a shame that GS has removed this possibility.
I was a bit concerned about the functions I do use glob_context for but fortunately you have replaced them with the Glob Execution Contexts. I think you should add the Glob_Context = 1 into this new listCADSWIFT
Australia -
November 5, 2015 at 17:10 #1902James MurrayParticipant
Here’s one from working on curved windows:
!otherwise you get div0 IF GLOB_CONTEXT=1 OR GLOB_CONTEXT=5 THEN WOD=-4' ELSE WOD=WIDO_ORIG_DIST ENDIF hA=A/2 !half of included angle hNg=ATN(hA/ABS(WOD))
James M
-
November 6, 2015 at 06:34 #1903Gergely FehérKeymaster
Try this way:
EPS = 0.0001 .... ha = A/s ! if it is needed later in the script - if not, then move in the "if" below bCurvedWall = abs(WIDO_ORIG_DIST) > EPS ! later it can be used to determine if bCurvedWall then hNg = ATN (hA / abs(WIDO_ORIG_DIST)) endif
Later in the script you can easily separate the parts corresponding to curved walls with the bCurvedWall variable. It’s much better separating working methods by their original purpose, than mixing up context with them.
Gergely Fehér
Team Leader, Library Team
GRAPHISOFT SE -
July 4, 2016 at 03:47 #2601Barry KellyParticipant
This has just cropped up again in ArchicadTalk … https://archicad-talk.graphisoft.com/viewtopic.php?t=53078
I was having a bit of a play again and noticed if ‘GLOB_VIEW_TYPE = 2’ is used (in master or parameter script) then whatever script is run after that command will run while in the library part editor.
For example …
IF GLOB_VIEW_TYPE = 2 THEN !do only in 2D
IF firstRun = 0 THEN !parameter that allow to run code only once
parameters firstRun = 1 !prevents running code again
ENDIF
ENDIFSo if there is a boolean parameter in the parameter list called ‘firstRun’ then it is automatically set to ‘1’ and you can’t manually change it.
If you alter the script to … IF GLOB_VIEW_TYPE = 3
or any other value then it is not run and you can manually change the parameter.Is this a bug that GLOB_VIEW_TYPE = 2 is ignored while in the library part editor? – seeing as technically it is not a 2D view and this part of the script should be ignored.
Just as it is ignored if GLOB_VIEW_TYPE = 3 (or any other value) is used.
Just finding it hard to see any logic here.To test this I used this code in the master script.
IF GLOB_VIEW_TYPE = 2 THEN !do only in 2D IF firstRun = 0 THEN !parameter that allow to run code only once parameters firstRun = 1 !prevents running code again ENDIF !SET STYLE "switch" !!! ---------- show Selector hotspot---------- HSID=HSID+1 hotspot2 0, 0 , HSID, firstRun, 1 ! base HSID=HSID+1 hotspot2 0,0-1 , HSID, firstRun, 3 ! ref HSID=HSID+1 hotspot2 0, firstRun, HSID, firstRun, 2 ! moving HSID=HSID+1 TEXT2 0,0,firstRun ENDIF IF GLOB_VIEW_TYPE = 3 THEN !do only in 2D IF firstRun = 0 THEN !parameter that allow to run code only once parameters firstRun = 1 !prevents running code again ENDIF !SET STYLE "switch" !!! ---------- show Selector hotspot---------- HSID=HSID+1 hotspot 0, 0,0 , HSID, firstRun, 1 ! base HSID=HSID+1 hotspot 0,0-1,0 , HSID, firstRun, 3 ! ref HSID=HSID+1 hotspot 0, firstRun,0, HSID, firstRun, 2 ! moving HSID=HSID+1 DEFINE STYLE "text" "Arial", 150, 5, 0 SET STYLE "text" TEXT 0.001,0,firstRun ENDIF
The hotspots in 2D and 3D views allow me to adjust the value.
So that is working fine.
However in the object settings dialogue the parameter can not be altered and it the script editor it can not be altered either unless I comment out the section for ‘GLOB_VIEW_TYPE = 2’I hope I have explained this problem OK.
Barry.
Versions 6.5 to 22
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit -
July 8, 2016 at 13:10 #2606Gergely FehérKeymaster
GLOB_VIEW_TYPE should not be used in parameter script (and in master when it runs as paramscript) – as it is a view dependent variable.
Gergely Fehér
Team Leader, Library Team
GRAPHISOFT SE -
July 11, 2016 at 04:33 #2607Barry KellyParticipant
Thanks Gergely.
I think it is finally sinking in that GLOB_VIEW_TYPE will have a default of ‘2’ which is why the ‘if GLOB_VIEW_TYPE = 2 then …’ set ‘firstRun = 1’ but the ‘if GLOB_VIEW_TYPE = 3 then …’ doesn’t (because it actually equals’2′ not 3).I think that is what keeps confusing me – not that the command no longer works but that it has a default value that can make it appear that it is working in some circumstances.
But I guess I am desperately after a way to have a parameter not be set while in the library part editor – i.e. the old ‘GLOB_CONTEXT = 5’ which now of course doesn’t work.
So I am looking for anything that will work and am clutching at straws.
I thought I might be on a winner her but no I wasn’t.There is a solution for me and it requires migration of the objects.
It works fine, just more involved to get it working.Barry.
Versions 6.5 to 22
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit-
July 11, 2016 at 07:31 #2608Barry KellyParticipant
I meant to say ‘GLOB_CONTEXT = 1’ not 5…
But I guess I am desperately after a way to have a parameter not be set while in the library part editor – i.e. the old ‘GLOB_CONTEXT = 1’ which now of course doesn’t work.
Versions 6.5 to 22
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit
-
-
December 14, 2016 at 01:15 #2921Christopher SheehyParticipant
Hi Barry,
I am also facing your issue, I have been speaking with Gergely re: this issue and the thought is maybe in version 21. Graphisoft will create a do not run parameters option for a GDL object.
Until then though I am using a workaround which may work for you:
in the parameters place “AC_ProgramVersion” integer; set to “0”. then in the parameters script you can put
if AC_ProgramVersion > 0 thenendif
ArchiCAD places the current version number of the software in the parameters when it has been placed.
Hope this helps.
-
December 14, 2016 at 04:37 #2923Barry KellyParticipant
Thanks Christoper,
So the value will always be ‘0’ in the GDL editor and an actual value when the object is placed in the model.
This would work and I will keep it in mind if I need it in future.
For now I have solved most of my issues by migrating to newer objects and swapping the parameters as necessary that way.We have GLOB_VIEW_TYPE values of 2 to 9 – why couldn’t we have a value of ‘1’ I wonder for the library part editor?
There must be a reason why not.GLOB_CONTEXT while deprecated (and no longer listed in the GDL reference) still seems to work (in 2D and 3D scripts) and in Master script as long as it is not trying to set as a parameter.
I hope this will still be the case as I have many hundreds of objects that use it many times in 2D & 3D scripts.
Maybe Gergely can confirm if this OK or will GLOB_CONTEXT just not work at all in future versions?
I have managed to eliminate it from all of my Master scripts but would hate having to go through all the 2D & 3D scripts to fix the problems.
I notice there are still version 20 objects using it so I am hoping it is safe to continue with it.Barry.
Versions 6.5 to 22
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit
-
-
AuthorPosts
- The forum ‘Informations from the environment’ is closed to new topics and replies.