GDL
About building parametric objects with GDL.

Access Layout Properties from Master Lyout

jan_filipec
Booster
Is there a way to access layout data in an object placed in a master layout? I need to create an object that looks different on each layout, depending on the layout's id.

Autotexts - work from masterlayout but can't be used to drive a script
n = request ("HomeDB_info", "", n, LayoutNumber, LayoutName, n) works only when placed directly on the layout, but not from masterlayout
LAYOUT_CHANGE_HISTORY works from masterlayout but does not contain layout id.

Thanks
17 REPLIES 17
Podolsky
Ace
All what you writing here make sense. With text add-on everything is working. You just need to be patient with the code or pass it to do to someone more experienced in programming. For me was the moment of 'milestone' - after writing some amount of library parts (that was hard, I had a lot of battles with the code), I understood how easy actually it is and nothing impossible there.
The problem with slash in path name and similar I usually solving by replacing problematic symbol with something else (like &slash&) and creating coder (when it writes to the file) and decoder (when reads).
jan_filipec
Booster
One more question: Is there a way to force the drawing titles to redraw? I have the master object, it writes to a config file and the title blocks read from the config file, but the placed ones do not update when I change the master. I tried
n = request ("HomeDB_info",  "", n, LayoutId, LayoutName, n)
in the 2d script so they are forced to redraw when I change the layout id, but that is not very elegant.
Podolsky
Ace
This is typical problem when you are using external file to exchange data between objects - it's not updating by itself when some data is changing. To solve this, I'm using command Update&Regenerate, that I'm placing as a button somewhere in UI of ArchiCAD.
Are you using auto text for layout ID? I think if you are using auto text - auto update then happens instantly (it happens because GDL is not processing content of auto text - so it's actually not needed to run GDL script to see updated auto text). I'm not 100% sure about it, but try.
Auto text in GDL will look like that: <LAYOUTID> <LAYOUTNAME>
jan_filipec
Booster
No I am not using autotexts as I need to use the data in the script.

Update&Regenerate seems interesting, but I can't make it work the way I'd like - when I select my masterobject and press U&R it updates all the objects on the layout, but nowhere else. If I don't select anything, it resets all the values to the defaults I defined in the parameter list.
Podolsky
Ace
Maybe you need to change architecture of your objects. Schematic algorithm really helps to design better structure.
jan_filipec
Booster
Somehow it only works when I use a file written to the local drive. If I do something like this
strConfigFilePath = "GDL I-O config.dat"
ch=OPEN ("DATA", strConfigFilePath, "MODE = WO, LIBRARY")
	OUTPUT ch, "strPath", 1, strPath
	OUTPUT ch, "strNorthArrowName", 1, strNorthArrowName
	OUTPUT ch, "corner_y", 1, corner_y
	OUTPUT ch, "corner_x", 1, corner_x
	OUTPUT ch, "TextX", 1, reaTextX
	OUTPUT ch, "TextY", 1, reaTextY
	OUTPUT ch, "AC_TextFont_1", 1, AC_TextFont_1
	OUTPUT ch, "AC_TextStyle_1", 1, AC_TextStyle_1
	OUTPUT ch, "AC_TextStyle_2", 1, AC_TextStyle_2
	OUTPUT ch, "iLineSpacing", 1, iLineSpacing
	OUTPUT ch, "AC_TextPen_1", 1, AC_TextPen_1
	OUTPUT ch, "AC_TextSize_1", 1, AC_TextSize_1
CLOSE ch
The file always contains the default values from the Parameters list, not the ones I set in the object. To me it seems as if the file was write protected (open?) - sometimes it randomly started working when I changed the name of the channel variable.
Peter Baksa
Graphisoft
Graphisoft
Hi,

When a library part gets executed is not predictable. There are cache mechanisms to re-execute only when necessary, and there is the info box which executes with the default parameters if no element is selected. The execution order can also change. Thus it is not recommended to write files relying on the rebuild of a library part.
You could add a button on the UI and write the file only when the user presses it.
Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest
jan_filipec
Booster
Peter wrote:
Hi,

When a library part gets executed is not predictable. There are cache mechanisms to re-execute only when necessary, and there is the info box which executes with the default parameters if no element is selected. The execution order can also change. Thus it is not recommended to write files relying on the rebuild of a library part.
You could add a button on the UI and write the file only when the user presses it.
Ok, so that also solved the problem with writing in a file placed in the library, great.
But now I have to do two steps when upadting my objects: go to settings and press the ui button to write to the file and then press the archicad button update & regenerate to see the changes. Is there a way to do this in one step?

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!