Load two or more DXF files into one View and do layout

Discussion forum for contributors and developers who are using the QCAD version 3 ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

wang
Registered Member
Posts: 2
Joined: Tue Jun 10, 2014 6:47 pm

Load two or more DXF files into one View and do layout

Postby wang » Wed Jun 11, 2014 8:46 am

I am a new one to QCAD. And I am trying to do some work about load and display DXF file.
This post about "Loading and Displaying DXF file" helps a lot.

But what I need is to load two or more dxf files into one view and do layout work automatically, after that save the result as a new dxf file.
I have checked the API documents, but because I am newer here , I found nothing.
Is there someone kind enough to give me some script sample about that?
Thanks a lot!

User avatar
andrew
Site Admin
Posts: 4637
Joined: Fri Mar 30, 2007 6:07 am

Re: Load two or more DXF files into one View and do layout

Postby andrew » Wed Jun 11, 2014 9:16 am

Hello Wang,

Please have a look at this script command line tool which merges multiple DXF/DWG files based on a simple XML input file:

https://github.com/qcad/qcad/blob/maste ... rawings.js

Actually, if you only need to merge drawings without displaying, etc, you might be able to use this tool out of the box. The XML format is:

input.xml:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<merge xmlns="http://qcad.org/merge/elements/1.0/" unit="Millimeter">
    <item src="myfile001.dxf">
        <insert x="0" y="0" angle="15" scale="1.2" flipx="true" flipy="false" />
        <insert x="50" y="0" />
    </item>
    <item src="myfile002.dxf">
        <insert x="100" y="50" angle="30" />
    </item>
</merge>


This would merge the files myfile001.dxf and myfile002.dxf into output.dxf:

Code: Select all

./merge -o output.dxf -f input.xml


The tool is currently available in our git repository only, but will be included in the next QCAD release.

wang
Registered Member
Posts: 2
Joined: Tue Jun 10, 2014 6:47 pm

Re: Load two or more DXF files into one View and do layout

Postby wang » Thu Jun 12, 2014 3:04 am

The source is great.
I found that the source you gave, the paste operation do the work to merge two dxf files, that is good sample of know-how.
The positions and angles was pre-defined in XML file.
Should the position and angle be determined by user interactive operation or layout automatically positions calculated.

Another question is if two files were merged, could I still operate the dxf individually, such as drag to move or rotate the objects in one dxf file together to do layout work manully.

User avatar
andrew
Site Admin
Posts: 4637
Joined: Fri Mar 30, 2007 6:07 am

Re: Load two or more DXF files into one View and do layout

Postby andrew » Thu Jun 12, 2014 8:25 am

wang wrote:Should the position and angle be determined by user interactive operation or layout automatically positions calculated.


You could simply use the QCAD Library Browser for this (View > Library Browser). It allows you to drag items form the part library into an empty drawing to merge them.

Another question is if two files were merged, could I still operate the dxf individually, such as drag to move or rotate the objects in one dxf file together to do layout work manully.


Yes, the items are inserted as block references ('grouped') with block name = file name (myitem001.dxf creates block 'myitem001').

User avatar
dfriasb
Active Member
Posts: 31
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Re: Load two or more DXF files into one View and do layout

Postby dfriasb » Wed Aug 24, 2016 2:39 pm

Hello,

I'm using QCAD-Pro 3.15.3.0 in Mac OS X. I'm trying to use merge command but I had no success. I guess I have to activate some additional module or configuration in order to use "Command Line Tools", is it? And, has the XML file to be placed in some specific folder?
I would like also to ask why QCAD is using xml file format instead of csv, for example. It looks it should be easier to manage with merge kind of data (more like a table than like a tree, I think).

Thanks a lot. Best regards!

David
David Frías Barranco | architect
dfriasb@gmail.com | davidfriasarquitecto.es

BoKai
Registered Member
Posts: 2
Joined: Mon Nov 21, 2016 12:49 pm

Re: Load two or more DXF files into one View and do layout

Postby BoKai » Mon Nov 21, 2016 1:06 pm

Hallo Andrew,
Hallo QCAD Experts,

at the time beeing i am struggling with the MERGE COMMAND LINE TOOL of QCAD. Is it possible to merge dxf files as single blocks (Layer) into one dxf file together?

Andrews answer gave me a bit of hope back : "Yes, the items are inserted as block references ('grouped') with block name = file name (myitem001.dxf creates block 'myitem001')." or did i understood something wrong? :)

Can i have a little example for the XML-Code with respect to my problem? How does it work? :)

I would be very grateful for a quick response.

Wish you all a nice and successful day!

Best,

Bo

User avatar
andrew
Site Admin
Posts: 4637
Joined: Fri Mar 30, 2007 6:07 am

Re: Load two or more DXF files into one View and do layout

Postby andrew » Mon Nov 21, 2016 1:39 pm

BoKai wrote:at the time beeing i am struggling with the MERGE COMMAND LINE TOOL of QCAD. Is it possible to merge dxf files as single blocks (Layer) into one dxf file together?


Yes, that's the idea behind merge. See my post above for a complete example (XML file and command line parameters).

BoKai
Registered Member
Posts: 2
Joined: Mon Nov 21, 2016 12:49 pm

Re: Load two or more DXF files into one View and do layout

Postby BoKai » Mon Nov 21, 2016 4:05 pm

Yes, that's the idea behind merge. See my post above for a complete example (XML file and command line parameters).


Hallo Andrew,
thank you for your fast response. Maybe i wasn't able to describe my problem good enough. As you already recognized - i am not a CAD pro.
What i try to achieve with respect to the XML-Manipulation are the following points:

Workflow description:

1) "Explode" the blocks into single objects
2) sort the entities into seperate layers like you mentioned Block name = file name. (Most important part)
3) Eleminate all block definitions

If there is a way to maipulate the xml file for this purpose, would be nice to get a hint or an XML-Example. Would definitely help me a lot. :)

Thank you in advance.

Best regards,

Bo

User avatar
andrew
Site Admin
Posts: 4637
Joined: Fri Mar 30, 2007 6:07 am

Re: Load two or more DXF files into one View and do layout

Postby andrew » Mon Nov 21, 2016 8:04 pm

BoKai wrote:1) "Explode" the blocks into single objects


No, merge does not do that.

BoKai wrote:2) sort the entities into seperate layers like you mentioned Block name = file name. (Most important part)


Note that layers and blocks are two different concepts not to be confused:
viewtopic.php?f=47&t=3736

BoKai wrote:3) Eleminate all block definitions


Again, not a part of the merge tool. merge only creates a new drawing file with blocks for the various 'merged' drawings in it. Everything else would have to be done in a separate (command line) tool.


Return to “QCAD 3 Developers and Contributors”

Who is online

Users browsing this forum: No registered users and 1 guest