CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products []
CZ | EN | DE
Login or
  Visitors: 5610

CAD tip CAD tip # 7812:

Question CAD 
 %  platform  category 
Q - question

How to write line-feed to a text file in AutoLISP.

A - answer The AutoLISP functions (write-line) and (write-char) automatically add the full CR/LF sequence (carriage return, line feed) when trying to output just the LF (line-feed, chr 10).

There is a trick of forcing AutoCAD to output really just the line-feed. Use the (write-char) function and add 256 to the character code. So instead of (write-char 10 f), use (write-char 266 f). An example:

(setq f (open "C:/TEMP/TESTFILE.TXT" "w"))
(write-char 266 f)
(close f)
writes a file testfile.txt containing just the LF character.
100% *  CAD 
23.2.2011    11206×  
Prices - CAD eShop:
applies to: AutoCAD 2011 ·

See also:
Tip 14017:Voronoi diagrams in AutoCAD.
Tip 13938:ModDXF - utility for bulk modification/display of internal DXF properties in DWG entities.
Tip 13887:ClosestPt - the nearest point on another curve
Tip 13868:XrefStamp - create a dynamic list of xrefs in your DWG drawing.
Tip 13855:DBXscanLayers and DBXscanBlocks - bulk report content of DWG files in a folder.

Back   All CAD Tips

Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD:    OS:    Categ: 
Text:  FAQ glossary   

Use Google Earth images in your AutoCAD projects with the Plex.Earth Tools More info

Please use these tips at your own risk.
Arkance Systems is not responsible for possible problems that may occur as a result of using any of these tips.