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

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!
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 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:
<?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:
./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.
User avatar
andrew
Site Admin
 
Posts: 4064
Joined: Fri Mar 30, 2007 6:07 am

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.
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 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
andrew
Site Admin
 
Posts: 4064
Joined: Fri Mar 30, 2007 6:07 am

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
User avatar
dfriasb
Newbie Member
 
Posts: 9
Joined: Thu Mar 10, 2016 1:08 pm


Return to QCAD 3 Developers and Contributors

Who is online

Users browsing this forum: No registered users and 1 guest