Objects in GDL are usually created and used as binary objects with .gsm extension.
This is very convenient when you, as a developer, only want to create a few objects at a time, and you are not planning on updating or developing them any further for upcoming versions.
This can be sufficient in a lot of cases.
However, once you start developing bigtime, working with complete libraries of objects, storing and modifying your files may be more convenient using xml source format.
ARCHICAD is shipped with a built-in tool for converting between .gsm (binary) and .xml (text) formats:
the LP_XMLConverter tool does the trick both ways, and can do a lot more than that as well.
Every binary library part can be broken down into a text file containing all the information and scripts necessary to rebuild them as binary objects. Each bit of this information is represented between nametags. Very easy to identify the parts, once you examine it a bit more closely.
Opposite to binary, the text format can be used in any code editor:
- easy find and replace functions for multiple elements
- easy to change the default of a parameter
- easy to add/remove parameters (without using a custom subtype)
- developing similar elements is a lot faster (copy-paste magic)
- built-in images for UI, preview are available
- version update may be easier
- script highlighting may be available
- localization can be automated using dictionaries
Accessing the LP_XMLConverter
This is platform dependent.
the tool is located in the main installation folder of ARCHICAD: LP_XMLConverter.exe.
Open a command prompt, and drag&drop the executable file into it.
In Finder, right click on ARCHICAD.app, “Show Package Contents”. The LP_XMLConverter.app is located in Contents/MacOS.
Look into the Contents of the converter app as well, and look for the executable version of the app in Contents/MacOS.
Open a Terminal window, and drag the executable file there.
The next step is to give some input parameters for the converter. This is the same on both platforms.
To get all the available options, type
help after the command and hit ENTER.
Lets take a look at the most commonly used functions.
Converting a single file
The command for this is libpart2xml.
Usually you start with a .gsm saved from ARCHICAD to a custom folder. The path of this saved binary is the “binaryFilePath”.
Then, create an empty file with .xml enxtension. The path of this file is going to be the “xmlFilePath”. If you do not want to create it in advance, make sure you type the destination path correctly.
Give the necessary parameters to the converter:
"pathOfLP_XMLConverterExecuteable" libpart2xml "binaryFilePath" "xmlFilePath"
The easiest way is to drag and drop the source and destination files into the command prompt, so the operation system takes care of special character escaping and such.
After running the converter with these parameters, the resulting file should be a text file containing scripts, parameter sections, etc. Built-in pictures are not extracted in this case, they will appear in your xml files as binary data.
If you want the pictures (UI and Preview) extacted, add the -img “imageFolderPath” extension of the command:
"pathOfLP_XMLConverterExecuteable" libpart2xml -img "imageFolderPath" "binaryFilePath" "xmlFilePath"
This way all built-in images will be extracted to the given folder.
To turn it back, change the order of the input parameters and use this command: xml2libpart:
"pathOfLP_XMLConverterExecuteable" xml2libpart -img "imageFolderPath" "xmlFilePath" "binaryFilePath"
This turns your .xml file and images into a complete .gsm binary again.
Converting a complete folder with built-in images
If you have multiple binaries in a folder, you can turn the complete folder into texts and pictures with some modification of the above.
First, use the command l2x to convert folders, and use corresponding folder paths instead of file paths:
"pathOfLP_XMLConverterExecuteable" l2x -img "imageFolderPath" "binaryFolderPath" "xmlFolderPath"
The result will be structured in the destination folder similar to source folder. Images will be extracted to subfolders named after the corresponding library parts in imageFolderPath.
To create binaries again, use x2l:
"pathOfLP_XMLConverterExecuteable" x2l -img "imageFolderPath" "xmlFolderPath" "binaryFolderPath"
use the following folder system to store all your libparts and data:
- Library_src: a folder for your .xml source files
- Library_images: for image files. This should be located in the same folder as your folder containing the .xml files, for convenience (the path of corresponding images is stored in the xml)
- Lirary: a folder for your binaries