Find the next step in your career as a Graphisoft Certified BIM Manager!

GDL
About building parametric objects with GDL.
SOLVED!

PEN Colour

GDL Enthusiast
Enthusiast

Hi GDL Experts,

 

Pens that change depending on the users pen pallet. It is a real hassle to have to create new favorites for different templates. One can define most other things, lines, fills etc.

 

Is there anyway after 30+ years of Archicad that one can define a pen RGB in gdl syntax that is independent of the final users pen pallet?

 

What about somehow using material RGB's to define a pen colour:

 

n = REQUEST{2} ("Material_info", 1, "gs_mat_surface_rgb", r, g, b)
PRINT r, g, b

 

Can that be used to drive the RGB of the pen?

 

I am hoping someone somewhere has found a way...

 

Many thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Podolsky
Ace

I don't really understand how to relate pen RGB and material... GDL does not support pen RGB. In general pen RGB appeared only after Archicad introduced conversion of PDF into drawing primitives - in that case you have additional pen type (number 256 I think), that contains RGB values from PDF. But this variable is not accessible for user. And it also does not transfer into GDL (only if converted primitives are copied into binary drawing section in GDL). In script itself pen is defined as a number from -1 to 255. -1 means transparent, 0 - background colour (both work for fills only), rest - number from current pen set. You can extract RGB value of the pen to GDL script, but cannot do opposite - define pen colour. 

View solution in original post

9 REPLIES 9
Solution
Podolsky
Ace

I don't really understand how to relate pen RGB and material... GDL does not support pen RGB. In general pen RGB appeared only after Archicad introduced conversion of PDF into drawing primitives - in that case you have additional pen type (number 256 I think), that contains RGB values from PDF. But this variable is not accessible for user. And it also does not transfer into GDL (only if converted primitives are copied into binary drawing section in GDL). In script itself pen is defined as a number from -1 to 255. -1 means transparent, 0 - background colour (both work for fills only), rest - number from current pen set. You can extract RGB value of the pen to GDL script, but cannot do opposite - define pen colour. 

GDL Enthusiast
Enthusiast

Hi Podolsky,

 

Thank you for taking the time to write and help me understand more about the pen. You are so knowledgeable! I will keep playing away...

 

Best regards!

REQ
REQ (parameter_string)

"Pen_of_RGB r g b": Defines the index of the pen closest to the given color. The r, g and b constants’ values are between 0 and 1.

 

so :

Pen_Grey = REQ("Pen_of_RGB 0.5 0.5 0.5")

Pen_White = REQ("Pen_of_RGB 1 1 1")

Pen_Black = REQ("Pen_of_RGB 0 0 0")

Pen_Red = REQ("Pen_of_RGB 1 0 0")

 

other REQ are:

REQ (parameter_string)

Asks the current state of the program. Its parameter - the question - is a string. The GDL interpreter answers with a numeric value. If it does
not understand the question, the answer is negative.
parameter_string: question string, one of the following:
"GDL_version": version number of the GDL compiler/interpreter. Warning: it is not the same as the Archicad version.
"Program": code of the program (e.g., 1: Archicad),
"Serial_number": the serial number of the keyplug,
"Model_size": size of the current 3D data structure in bytes,
"Red_of_material name"
"Green_of_material name"
"Blue_of_material name": Defines the given material’s color components in RGB values between 0 and 1,
"Red_of_pen index"
"Green_of_pen index"
"Blue_of_pen index": Defines the given pen’s color components in RGB values between 0 and 1,
"Pen_of_RGB r g b": Defines the index of the pen closest to the given color. The r, g and b constants’ values are between 0 and 1.

 

I go back to GDL Manual every day...there is always a solution in there

I have been using ArchiCAD continually since ArchiCAD 4.5, 4.5.5, 5, 5.1, 6, 6.5, 7, 8, 8.1, 9, 10, 11, 12, 13, 15, 18, 21, 22, 25, now testing 27
Member of Architalk since 2003, but missed the migration to Graphisoft.
(where have all my original posts gone?)

As you mention, this will give you the pen index number in your current pen set that is closest to the RGB value that you want.

It will not however, allow you to set the actual pen colour.

 

Archicad 25 build 4013 will now allow you to set an RGB colour to the background of a fill using a Graphic Override.

But I don't think you can set an RGB value to a fill background itself without the Graphic Override (I haven't looked into this yet).

You certainly can't use RGB for the foreground (hatch) pen - and that includes the pen used for perimeters and lines.

 

So unfortunately I believe we are stuck with the standard 255 pens in GDL.

 

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

Thanks Allan, that is really helpful too!

Thank you Barry, that is very helpful knowing about AC build 4013 allowing one to set an RGB colour to the background of a fill using a Graphic Override. Wishing you the best in GDL!

Peter Baksa
Graphisoft
Graphisoft

Pen sets can be moved between different files with the attribute manager, would that be easier?

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

Hi Peter, that is an option, however in my case, the team that works on civil design has several different pen sets that they don't want to change, while the architectural team has a further separate sets of pens they don't want to change.

 

If I want to set GDL the pens to the architectural pen set, then it doesn't work for the Civil Team. I have to set up an object favorites for them or make the GDL object twice to save them having to change pen colours.

 

This is a common problem for most GDL objects around the world it seems from what I can see, as one cannot control the end users pen pallet. Using the RGB closest match only works if a close target colour can be found in the pen pallet.

 

I wonder why Archicad doesn't allow the Pen to be defined. Searching online I have found a lot of other people who express interest in controlling the pen RGB & weight through GDL. I wonder if it is something hard coded in the software that is to complex to change which is why GS has yet to add that feature after all these years. 

 

Thank you for responding Peter, all the best to you!

If you don't want to unify the pen sets, which wouldn't be a bad idea in the long run, you can go through a different route: Make yourself a MVO tab (LibraryGlobal) for the office and then define a couple of pens there, which are set differently depending on whom is working on the view.

Your objects can then receive these pens.

Lucas Becker | AC 27 on Mac | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»