The Global ARCHICAD Community

Stay informed. Get help. Share your knowledge.

Discussions about managing ARCHICAD in architectural practices (Project Setup, Templates, Attributes, Migration, Compatibility with Previous Versions, Preferences/Work Environment, User/Project/Application Administration/Management etc.)

Moderators: ejrolon, Barry Kelly, Karl Ottenstein, LaszloNagy, gkmethy

Hi everyone,

I just wanted to share a small python script I just made. It lets you scan through XML files and edit every pen color parameters according to a correspondance file.

I did this because we use a custom pen set in our office and I was sick of changing the pen colors of every objects every time just because they are programmed to work specifically for the base pen set (yes, favorites are a great help and we intensively use GOs, but it is not a complete and satisfying answer to this specific problem).

Here's the process :
  1. Extract the content of your Archicad LCF and convert the GSM files into XML files using the LP_XMLConverter (How to use the LP_​XMLConverter tool).
  2. Create a spreadsheet with 2 columns. The first one represents the pen number value to be replaced (the base pen set value) and the second one the new value (the corresponding value of you custom pen set). The first column will simply be a listing of numbers from 1 to 255 (you don't need to replace the -1 and 0). The script will then replace every pen color parameter it finds on the left column by the corresponding number to its right.
  3. Save this file as a CSV file. You then need to open it and replace the column separator (";" or ",") by a simple space.
  4. Edit the paths in the python script so that it can find the files on your computer.
  5. Launch the script ant let it do its magic.
  6. Using the LP_​XMLConverter, transform the patched XML files back to GSM files and then pack them back to an LCF.
  7. You can now safely archive the old LCF file and replace it by your patched one.

I successfully used this technique and I can tell you it was welcomed with a lot of enthusiasm by my colleagues who were used to always edit the pen colors of every objects, but with the new stair and railing tool and their huge number of graphical options, it had become a real pain in the a##.

I can give a more thorough explanation if needed.
I only have a very small experience in python scripting so if someone finds a way to optimise or make this script better in any way, please let me know. If you want to make it better by yourself, feel free but share it with us please.

Hope it will help some of you.
Let me know what you think!


P.S. To run the python script, you can use pyCHARM, it's free and open source (but not the only solution). You will need to run it with python 3.6 and it needs the lmxml library to work. Once again, I can help you if needed.

(1.16 KiB) Downloaded 9 times

(1.39 KiB) Downloaded 13 times

I already made a few modifications to the script. It is now more stable and more versatile.
You can change pen numbers, line types and fill colors.

I also added a small explanation on how to use it.

(1.23 KiB) Downloaded 11 times

Last edited by Johan Cosandey on Wed May 16, 2018 10:40 am, edited 1 time in total.