GDL
About building parametric objects with GDL.

Macros vs Subroutines - resource optimization

AlexV
Booster

Hi,

which one is better

- 1 object with 10 subroutines x 500 lines of code or

- 1 object + 10 macros x 500 lines of code

?

 

I'm working on an object that will have a dropdown list of several choices - let's say 10 types of chairs, so you place the object chair.gsm and then choose type 1, type 2 ... No 3d script- it will only be 2d shapes.

Now I can store each respective 2d script as sub's and get a very long 2d script for the object or I can have macro calls  and have each respective 2d script as a separate macro.

 

Wonder if anyone knows how it would be better from a resource managemet perspective - thinking that this object will be placed on multiple instances with different types, I would try to avoid weighing down the file if possible.

 

The 500 lines of code per type is a bit of exaggeration, but is one of the choices better than the other in this case?

 

 

 

 

2 ACCEPTED SOLUTIONS
3 REPLIES 3
Solution
scottjm
Expert

The majority of the standard archicad libraries that have varying options utilise macros, but I suspect this is primarily from a code and version management point of view. 

 

Realistically it’s the same amount of code in both situations. So the size of the macro option would only be a smidgen larger than a single object.  The only factor I could see that would make the macros option drastically larger is if you had a huge amount of params for the object, you would ideally need to have all the same params in each macro too. 

A single object may be easier to maintain though, but less scalable to future option additions. 

Archicad is also quite efficient at dealing with multiple instances of the same library part. Just make sure your 2D representation is super efficient. Do not use Project2 and see if you can avoid Fragment2 and code the 2D in native GDL

 

 

If the size of the library does get big, I’m talking in the 100’s MB, packaging the library into an lcf has huge performance improvements over loading from a folder.

Scott J. Moore | Fulton Trotter Architects | BIM Manager, Associate, Architect
Since AC13 | Current versions AC23.7000 & AC26.5002 | BIMCloud Basic | Python, GDL, VBA, PHP, SQL, CSS
Certified Graphisoft BIM Manger (2022)
Win 10, i9-9900K, 32GB, Quadro P2200, 500GB NVMe
Solution
Barry Kelly
Moderator

Sub-routines or macros probably don't make a big difference either way.

 

The advantage of macros are you can call them into multiple objects that need to do the same thing.

Change/update the macro if necessary and all objects that call it will update - saves having to change the sub-routine in multiple objects.

 

But if you want it unique for just that one master object, then sub-routines are fine.

 

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
AlexV
Booster

@scottjm @Barry Kelly 

thank you for the answers.

That's what I suspected as well, checking AC library parts with multiple option functionality I saw the same- the gsm is nearly empty with a macro call, sometimes even that macro is nearly empty with another macro call, and the last macro has all the code with subroutines and everything.

I understood that's bc. they are reusing the same macro to several objects so it's an advantage in that case , not in mine, but still it's good to check beforehand.

@scottjm- interesting about Fragment2 - I knew about Project2, but didn't think Fragment2 can add to complexity in a noticeable way

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!