Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

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
Newcomer
Solve it differently. Place your object (I guess title block) to layout and leave master layout empty. This way user can access to title block settings and change settings - for example title block style, show/hide north symbol and scale and similar. This method also potentially reduces amount of master layouts to paper sizes (because usually people have huge list of masters: A1 horizontal - presentation, A1 vertical - construction, A1 horizontal - planning application etc).

jan_filipec
Booster
Yeah, well this is what I am doing now. The problem is, that this is a typical masterlayout problem - I need the properties of the blocks to be exactly same on all layouts, only the content to change. (for example: I have a house with 200 flats. I have one layout for each flat and they all have to be identical. I need to place one of two logos on the layout according to a list. Normaly you would make two master layouts and manually pick the 100 flats and change to the masterlayout with the right logo - I want this to happen automatically)
So what I am doing is defining these parts of layout through gdl (position, size of the logo) which is fine for me, but doesn't really work as a user solution - I can't expect everyone in the office to be able to open the gdl script of the object to change the font size or position everytime they want to change the layout.

Peter Baksa
Graphisoft
Graphisoft
It is possible to code parameters that control the font size or position with a simple UI. The position could even be a moveable hotspot.
Péter Baksa
Software Engineer, Library as a Platform
GRAPHISOFT SE, Budapest

jan_filipec
Booster
Yeah, but the original problem still remains:
I can program these things in GDL and place the object on a master layout, but then I can't have the object change according to the layout number, because I can't access it from master layout.
Or I can place the object on each layout, but then I can't change the position on all layouts at once, as the parameters are saved per object.
I just tried using MVO but that obviously also doesn't work in layouts.

A slightly different example of what I want: the object opens a file and displays data read from the file. I need a different part of the file on each layout, but I want to be able to set the path to the file in one place, not per layout.

Podolsky
Newcomer
What do you mean by changing position of layout?

In my research I finally came to conclusion, that placing title block as an object on each layout and keep master empty more beneficial in any case - it just gives more options to control. Also you can program the title block the way that user would not able move, rotate or mirror the object, only place or delete. Well, you actually do move the object, but GDL returns position of the object back.
Also you can use txt files (or files with GDL extension, that is txt file but can be a macro), or XML, placed into embedded library as small data base and point if exchanging information between library parts. This way you can control change of several objects by changing only one of them.

And don't forget - you can develop a tool, that is working, but not completely perfect because of GDL limitations - but later you can infill the gaps with new GDL commands and possibilities, when they will be introduced in the future or using C++ or Python.

runxel
Mentor
What I do myself is, that I neither have my title blocks on the layout or the master layout.
Instead I have them in worksheets and I place them.
Mostly on the master layouts, still. But on the other hand I really don't need to have every layout be different.
Maybe this is an XY Problem?
AC 24 [ger] | Win 10 | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»

jan_filipec
Booster
runxel wrote:
What I do myself is, that I neither have my title blocks on the layout or the master layout.
Instead I have them in worksheets and I place them.
Mostly on the master layouts, still. But on the other hand I really don't need to have every layout be different.
Maybe this is an XY Problem?
I apreciate your comments, but have you read my description of the problem? I need every layout to be different, that is the task, that is what I am paid to do. I want to automate this, because it seems simple enough - I have a database mit data and a large number of layouts with unique IDs. I need to show different data from the database on each layout - depending on the layout ID. (Layout 1 - row 1 from the database, Layout 2 - row 2 from the database and so on.)
I know how to do this, but here comes the real issue: I need the displayed information to be configured in a user friendly way, because it changes from project to project. The suggestion from @podolsky with the configuration file is the closest thing to what I am trying to achieve. I will try it out and see how the users in our office ract to this.

runxel
Mentor
jan.filipec wrote:
I apreciate your comments, but have you read my description of the problem?
I did, but it was not comprehensible. 🙂
See, I think you have a bunch of different problems there which you're conflating into one.

Of course you know your problem best. But we can't this easily see all the possible caveats. So sometimes the forum is more of a collective "brainstorming" to get you to have the right idea. 😉

Back to the multiple problems:
So, you need something, that is the same, except for the parts that aren't. Also it needs to be flexible.

You already discovered that there is no easy solution.
And you really want this to be one object? Otherwise a first step before a final solution would obviously to split the dynamic part from the static part and put that on every layout.

One clean solution, until the Python connection can place elements, I can see is a custom made add-on.
AC 24 [ger] | Win 10 | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»

jan_filipec
Booster
Podolsky wrote:
Also you can use txt files (or files with GDL extension, that is txt file but can be a macro), or XML, placed into embedded library as small data base and point if exchanging information between library parts. This way you can control change of several objects by changing only one of them.
(I said position ON the layout-sometimes we have to add some information to the layout and move the block a bit-that means clicking through hundreds of layouts and moving them manually right now)

I tried to work with your solution and it seems to be pretty much exactly what I need, but I would appreciate some help still.
  • I can imagine building this in a one of two ways:
    Either one master object, placed somewhere being invisible, in which I set the variables, it writes them to the config file and a different object placed on every layout, reading the config file. I tried this and it seems to work ok.
    Or only one object, placed on all layouts, always writing any change to the variable to config first and then changing everywhere. I tried this but it seems to lead to conflicts and crashing archicad.
    Can the single object version work?
  • I tried the text and data add-ons, the both remove \t from any text, even if I set the separator to ";" is there a way around this? (I need to pass directory path i.e. "C:\temp")
  • I created an empty config file and manually added it to the library first, is there a way to check if the config file exist in the library and create it if it doesn't?

Podolsky
Newcomer
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
Newcomer
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
Newcomer
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?

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!