How to use libdxfrw?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use libdxfrw?

mandeep7
This post was updated on .
Hi all,

I am working to use libdxfrw library. I have gone through files
involving writing of a line to DXF file. I created an instance of
DRW_Line and set the values of the base point and second point of the
line.

DRW_Line line;
line.basePoint.x = 10;
line.basePoint.y = 20;
line.secPoint.x = 30;
line.secPoint.y = 30;
qDebug() << line.basePoint.x;
dxf->writeLine(&line);

However, I could not achieve it. I have also referred the "testcp"
the example given at SourceForge but it did not work either. The first
thing I want to achieve is to write a line to DXF file. Please help me
achieving this.
Mandeep Singh
Reply | Threaded
Open this post in threaded view
|

Re: How to use libdxfrw?

R. van Twisk
Administrator
Mandeep,

here is an example https://github.com/rvt/dxfrwtest (we spoke on the LibreCAD IRC channel).
modify CMakeLists.txt because I quickly hacked it together.

For your sample you gave me,
I would advice against trying to modify existing code when you are traying to understand something. It's usually better to start from 0 and learn from their then modifying existing code, change a lib and hope for the best...



Reply | Threaded
Open this post in threaded view
|

Re: How to use libdxfrw?

mandeep7
R. van Twisk wrote
Mandeep,

here is an example https://github.com/rvt/dxfrwtest (we spoke on the LibreCAD IRC channel).
modify CMakeLists.txt because I quickly hacked it together.
Thanks ries,

I got this working.

R. van Twisk wrote
For your sample you gave me,
I would advice against trying to modify existing code when you are traying to understand something. It's usually better to start from 0 and learn from their then modifying existing code, change a lib and hope for the best...
Thank you for the advice. :)
Mandeep Singh
Reply | Threaded
Open this post in threaded view
|

Re: How to use libdxfrw?

Kamalpreet
In reply to this post by R. van Twisk
R. van Twisk wrote
here is an example https://github.com/rvt/dxfrwtest (we spoke on the LibreCAD IRC channel).
modify CMakeLists.txt because I quickly hacked it together.

For your sample you gave me,
I would advice against trying to modify existing code when you are traying to understand something. It's usually better to start from 0 and learn from their then modifying existing code, change a lib and hope for the best...
Various virtual functions have been included in  'ExampleWriter.h'. For an instance,  

virtual void addLType(const DRW_LType &data) override {
}

Why do one need to include the functions that are not even considered to be used in a project?


Reply | Threaded
Open this post in threaded view
|

Re: How to use libdxfrw?

R. van Twisk
Administrator
Mandeep,

As you can see here : https://github.com/LibreCAD/LibreCAD/blob/master/libraries/libdxfrw/src/drw_interface.h DRW_Interface is an abstract class. I this was was a design decision from Rallaz to ensure that when you overwrite DRW_Interface it ensures that the developer realises what methods are available for overriding.
Don't forget that making a DXF also requires a special order of operation. You cannot 'just' write a line to DXF and forget about the rest, some specific items in the dxf need to come in a specific order. Using this abstract class ensures this order can be maintained and at the some time you can modify the DXF.
There are other ways to accomplish the same, this is just one of the ways.

Ries

 
Reply | Threaded
Open this post in threaded view
|

Re: How to use libdxfrw?

Kamalpreet
Following the same example, I am trying to set the attributes of entities using variables.

Code for the same can be referred to at:
https://github.com/kamalpreetgrewal/textToDrawing/tree/test

In the file ExampleWriter.cpp,
On calling writeLine function (dxfW.writeLine(&b);) in addLine, it crashes (seg fault).

Can you help by pointing out my mistake.
Reply | Threaded
Open this post in threaded view
|

Re: How to use libdxfrw?

R. van Twisk
Administrator
What are you trying to accomplish?

I would suggest to start reading the code a bit better then trying thing's out.
Also, as the readme of libdxfrw suggest in LibreCAD we do have an examples how to read/write DXF.

essentially, you are using the library incorrectly.
Reply | Threaded
Open this post in threaded view
|

Re: How to use libdxfrw?

Jasleen
In reply to this post by mandeep7
On 4 April 2016 at 17:16, mandeep7 [via LibreCAD]
<[hidden email]> wrote:
> Hi all,
@ mandeep, kamal
can you come tomorrow? I want to know the work you are doing. May I
involve in it?

--
Jasleen Kaur
jasleen7956.wordpress.com
Reply | Threaded
Open this post in threaded view
|

Re: How to use libdxfrw?

mandeep7
In reply to this post by R. van Twisk
R. van Twisk wrote
What are you trying to accomplish?
Thank you. Now got it working.
Please see if I am doing it right.

https://gitlab.com/greatdeveloper/BuildD/blob/master/EntityWriter.cpp

Couldn't make Polyline work for me. Can you please tell what parameters I am missing for this entity that need to be set.
Mandeep Singh