View Full Version : vla-get-resource
M76
1st Mar 2010, 10:21 am
I'm trying to package a dxf file into a vlx, but I'm having problems with it. The extracted dxf is rejected by autocad.
I'm using it to add a block to the drawing if it doesn't exist.
(if (= (tblsearch "BLOCK" "jkdatb04") nil)
(progn
(setq dxf (vl-get-resource "kapcsjel"))
(setq tempf (vl-filename-mktemp nil nil ".dxf"))
(setq f (open tempf "w"))
(write-line dxf f)
(close f)
(command "_-insert" tempf "0,0" "" "" "")
(vl-file-delete tempf)
));
Any suggestions?
If I compare the original dxf and the new one, there is indeed a 6 byte size difference, but the contents seems to be the same regardless.
MSasu
1st Mar 2010, 11:33 am
Can be something related to formatting controls used in original and respectively new DXF files - I mean Carriage Return / Line Feed. Did you tried to open the new file with Notepad or other simple text editor? May find that all lines are condensed into single one and therefore the file rendered unusable by AutoCAD. Just a suggestion.
M76
1st Mar 2010, 12:44 pm
Can be something related to formatting controls used in original and respectively new DXF files - I mean Carriage Return / Line Feed. Did you tried to open the new file with Notepad or other simple text editor? May find that all lines are condensed into single one and therefore the file rendered unusable by AutoCAD. Just a suggestion.
Yes I opened it, and it seems identical, except the 6 byte size difference.
I've checked with a compare tool and it seems that some line feed characters are missing, but I have no idea why. And why only a few? I counted 4 missing.
http://mumia.uw.hu/compare.PNG
MSasu
2nd Mar 2010, 08:39 am
One workaround can be to try to convert the stored file into a single string by concatenating the lines with a separator – I suggest TAB (code ASCII 9). If the file size exceeds 32767 characters will require splitting into more than one string.
When need to record the target DXF file just replace the TAB-s with new line character – this way will avoid unwanted (not-supported) controls.
M76
2nd Mar 2010, 09:42 am
Thanks, it worked. I replaced the CR+LF with one TAB in the file. And then I switched the tabs to lf in the code.
(setq kapcsolojeldxf (vl-list->string (subst (ascii "\n") (ascii "\t") (vl-string->list (vl-get-resource "kapcsjel")))))
MSasu
2nd Mar 2010, 09:48 am
You’re welcomed @M76! I’m glad that was able to help you!
Regards,
Powered by vBulletin™ Version 4.1.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.