M76 Posted March 1, 2010 Posted March 1, 2010 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. Quote
MSasu Posted March 1, 2010 Posted March 1, 2010 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. Quote
M76 Posted March 1, 2010 Author Posted March 1, 2010 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 Quote
MSasu Posted March 2, 2010 Posted March 2, 2010 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. Quote
M76 Posted March 2, 2010 Author Posted March 2, 2010 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"))))) Quote
MSasu Posted March 2, 2010 Posted March 2, 2010 You’re welcomed @M76! I’m glad that was able to help you! Regards, Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.