How do I write DXF text to stdout?

Use this forum to ask questions about how to do things in dxflib.

Moderator: andrew

Post Reply
chainichek
Newbie Member
Posts: 3
Joined: Sat Mar 24, 2012 5:14 pm

How do I write DXF text to stdout?

Post by chainichek » Sat Mar 24, 2012 5:24 pm

I use DL_WriterA to write DXF text to some.dxf file. Is there any way to redirect DXF text to stdout?

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

Re: How do I write DXF text to stdout?

Post by andrew » Thu Mar 29, 2012 11:04 pm

Not directly from dxflib. You'd have to generate a temporary file and then stream it to stdout.

chainichek
Newbie Member
Posts: 3
Joined: Sat Mar 24, 2012 5:14 pm

Re: How do I write DXF text to stdout?

Post by chainichek » Fri Mar 30, 2012 8:32 am

I use 'tmpnam' to generate temporary file name although the manual page on 'tmpnam' does not recommend to use this function:

#man 3 tmpnam
...
BUGS
Never use this function. Use mkstemp(3) or tmpfile(3) instead.
...

Could you recommend more coorect way to generate temporary file for writing DXF data?

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

Re: How do I write DXF text to stdout?

Post by andrew » Mon Apr 02, 2012 2:41 pm

The man page seems to suggest 'Use mkstemp(3) or tmpfile(3) instead.'

I haven't used these lately, but according to their man pages they might provide what you are looking for.

chainichek
Newbie Member
Posts: 3
Joined: Sat Mar 24, 2012 5:14 pm

Re: How do I write DXF text to stdout?

Post by chainichek » Mon Apr 02, 2012 3:19 pm

DL_WriterA requires file name as parameter while these (safe) functions return file descriptor or stream -- not file name.

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

Re: How do I write DXF text to stdout?

Post by andrew » Tue Apr 03, 2012 10:54 am

You are right. dxflib would have to be adjusted to work with those functions.

A possible solution might be to create a temporary directory instead of a file using mkdtemp.
You could then create file(s) inside that directory with any fixed or dynamic name(s).

Post Reply

Return to “dxflib 'How Do I' Questions”