An inkscape script to translate svg classes to svg layers, for ultimate dxf export with these layers
Would anyone else be interested in the following?
Thinking if this is a good workflow, would start a funding campaign to drum up funding to write this script in Inkscape.
Maybe inkscape can process a json (or markdown, or csv) like the following
[
{
"IfcClass": "IfcWall",
"PredefinedType": "ELEMENTEDWALL",
"Layer_Name": "A-WALL",
"Layer_Color": "2",
"Layer_Lineweight": ".25 mm",
"Layer_LineType": "Continuous"
},
{
"IfcClass": "IfcWindow",
"PredefinedType": "SKYLIGHT",
"Layer_Name": "A-WINDOW",
"Layer_Color": "3",
"Layer_Lineweight": ".15 mm",
"Layer_LineType": "Continuous"
}
]
or...
| IfcClass | PredefinedType | Layer_Name | Layer_Color | Layer_Lineweight | Layer_LineType |
| -------- | -------------- | ---------- | ----------- | ---------------- | -------------- |
| IfcWall | ELEMENTEDWALL | A-WALL | 2 | .25 mm | Continuous |
| IfcWindow | SKYLIGHT | A-WINDOW | 3 | .15 mm | Continuous |
Thoughts? additions? modifications?
Comments
I’m not sure I understand how this would be helpful? Can you explain what problem you are trying solve. Once in 2D space isn’t it more useful to have things grouped by plane (foreground, cut, background, annotations). What do you use dxf for?
Thanks for the question.
Basically trying to realize a workflow to attain a relatively intelligent dxf from BB.
Reason being, consultants need background CAD files quite often.
So this is a proposal to basically convert an SVG, with SVG classes like
IfcWall
, and convert them to dxf layers.I see. The consultants I work with just grey the plans as provided. I am pretty sure they don’t make any effort to manage the classes/layers.
I would definitely be interested
For the purpose of backgrounds for consultants, it might be necessary to define multiple graphical properties for each class (cut lines, cut hatch lines, and projected lines, etc.). Otherwise the drawings might look flat.
@theoryshaw I would throw a 'few beers' of investment to a workflow (script in Inkscape) solution. Maybe related, maybe not, I am also interested in how/if 2D drawings generated in BBIM are saved in the IFC as Annotation, I have been trying to achieve it in a simple way, probably missing the obvious... story of my life!
I am also interested in exporting DXF files with layer information from SVG, whether authored with BB, Inkscape, or other software, and beers of course.
Upon examining the dxf_outlines Inkscape extension, I found an option to export Inkscape SVG layers to DXF layers. Therefore, I created an initial extension prototype to generate Inkscape layers from SVG groups containing classes with 'Ifc'. Depending on the workflow, this could pose a problem if you are already using layers inside Inkscape to organize your SVG elements, as it will move elements to new layers with the Ifc class names. However, it can also be a quick way to organize the SVG according to IfcClasses, while maintaining the layer structure when exporting to DXF.
The prototype is functioning well for small test files but inconsistently crashing for large OpeniningDesign demos, as shown in the video.
https://www.dropbox.com/scl/fi/m8xqxei1q3925w4kxwdgt/2024-02-01_21-23-35.mp4?rlkey=37v99m39eehchzdweuwvf29ia&dl=0
This is my first time developing Inkscape extensions, so I will investigate further and seek help in the forum, or file a bug report, etc. The pre-release version of the extension is available here for testing in its current state; any help or feedback is appreciated.
The goal is to stabilize this layer creation process and then expand the dxf output script to configure each layer attribute (such as color, line weight, etc.).
@elschilling I watched the video, this is a cool idea. Is it possible to run extensions in Inkscape without opening the Inkscape GUI?
That's awesome @elschilling!
If game, per this post, I'll put together a little osarch open collective funding campaign to help raise funds for your work. That way, OSArch can match any funds that come in.
Sound good?
@theoryshaw Sounds like a win-win situation for everyone! How can I assist you in creating this campaign?
@Nigel Yes! As the Inkscape wiki states, it supports three types of extensions:
Inkscape wiki
The extension prototype I made is an effect, as it changes the SVG loaded by the program and returns the altered SVG to the editor. Trying to run it from the terminal, I encountered a crash, which seems to be a known issue.
However, I have good news! Please take a look here.
I created a modified version of the DXF 14 export extension incorporating the layer from the Ifc classes creation process, and it worked without any crashes, both from the GUI and CLI, with both simple and complex demo files!
The next step is to start implementing the layer attribute options! :)
That's awesome. Actually do you want to take the lead on writing up a blurb per what's suggested here? I think it's better coming from you, as you have a roadmap in your mind, and the one doing the work. Also, it would be nice to get other OSarch members posting these funding projects, other than me.
I pushed a suggested sandbox for testing. :)
https://github.com/elschilling/class2layer/pull/1
1st dxf I sent to a consultant, from BB!
https://hub.openingdesign.com/OpeningDesign/Restaurant_Sun_Prairie/src/commit/319fb68b54aae782a99009e2f634547079f099e1/Models/BlenderBIM/drawings/FLOOR PLAN - 1ST-cad background-X.dxf