AutoCAD Visual LISP / AutoLISP :: Write Several Lines Of Text To TXT File?
Apr 13, 2012I know how to write a single line of text to a txt file with LISP, but how do i write two or more lines of text to a txt file ussing lisp?
View 4 RepliesI know how to write a single line of text to a txt file with LISP, but how do i write two or more lines of text to a txt file ussing lisp?
View 4 RepliesI want to write content of variables to a text file but I should have conversion function for variables.
for example
(setq a 123); a is an integer type, contetnt of a is 123
so I should use (itoa a) to get "123" as a string and then I can write it to text file.
but what about another type of variables?
(defun ToString ( a / result)(setq result "")(cond((= (type a) 'ENAME) (progn (setq result "Entity names")))((= (type a) 'EXRXSUBR) (progn (setq result "External ObjectARX applications")))((= (type a) 'FILE) (progn (setq result "File descriptors")))((= (type a) 'INT) (progn (setq result (itoa
[Code].....
I can't write unicode characters to a text file.
as you know, you can write chars on text screen easily: (write-line (strcat "\U+" "2122"))
but if you want to write chars to a text file, this command does not work: (write-line (strcat "\U+" "2122") TxtFileVar)
Here is a part of my code to test:
(defun C:HexGen ( / d f S w x y z h c)(setq d '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F") f (open "c:\0000-FFFF.txt" "w"))(foreach w d (foreach x d (foreach y d (progn (setq S "") (foreach z d (progn (setq h (strcat w x y z)) (setq c (strcat "\U+" h));;;<===character (setq S (strcat S " " (strcat h " = " c ))) ) ) (write-line S f) ) ) )) (close f)(startapp "notepad" "c:\0000-FFFF.txt"))
I'm trying to open a file to write to on my external drive, I get this message "bad argument type: stringp nil".
View 8 Replies View RelatedI'm trying to write a lisp routine that, when I invoke the mleader command, osmode is set to "nearest" & orthomode is set off. I then would like the original settings to be returned.
attached is what I have written so far:-
3rd party tool which didn't match our scaling needs the file is a fas so I have tried to reverse engineer the whole function using trial and error. The following code works perfect except we need multiple (x amount) lines of text I have at current the M txt function which mimics and is effective for today however we need all lines to be individual.
I’m playing round with a loop but how to achieve my need..He had a 3rd party tool which didn't match our scaling needs the file is a fas so I have tried to reverse engineer the whole function using trial and error.
The following code works perfect except we need multiple (x amount) lines of text I have at current the M txt function which mimics and is effective for today however we need all lines to be individual.
;Starting lisp program...(defun C:REDtext ();Creating Layers (if non existant)...(command "layer" "m" "TEKST-1.5mm" "lt" "continuous" "" "c" "1" "" "");Memorising previous layer...(setq MYOLDLAYER (getvar "clayer"));Setting requierd layer...(COMMAND "LAYER" "SET" "TEKST-1.5mm" "");Setting variable "MYHEIGHT" to "DIMSCALE" x 2...(setq myheight (* 2 (getvar "DIMSCALE" )));Requesting and storing usser defind point...(setq MYPOINT (getpoint "Start punt :")); Requesting and storing user defind text...(setq MYTEXT (getstring T "Nieuw tekst :"));Placing text...(command "text" MYPOINT MYHEIGHT "0" MYTEXT); Restoring previous layer...(setvar "clayer" MYOLDLAYER);Closing lisp program...)
The PARTS LISTS on our old drawings are simply text entities and lines. Some are MTEXT. But our new drawing template has us creating our parts list using the actual AutoCAD TABLES entity.
I'm looking for the best method to go from lines and text in AutoCAD, to an AutoCAD table. As of now, I have to retype everything since I can't select a column/row or group of text entities, copy/paste into a table.
Any LISP function that will allow me to go from TEXT and LINES to a TABLE? I've tried B2E (lisp name) but it's not working - found that on a lisp site somewhere.
Is it possible to have Multi lines of text in a .dcl edit_box or such?
View 4 Replies View RelatedI am able to insert multi line text into the Drawing Properties Summaryinfo standard field "comments" by using string concatenation in VBA by using "mytext" & vbLF & vbCR "mytext".
But I can't find a way that works in autolisp. This code does not work.
(defun c:FillComments (/) (vl-load-com) (setq acadObj (vlax-get-acad-object)) (setq acDoc (vlax-get-property acadObj 'ActiveDocument)) (setq acDocSumInfo (vlax-get-property acDoc 'SummaryInfo)) (setq *customer* "MyCustomerName") (setq *location* "MyLocation") (setq *project* "MyProject") (setq*comments* (strcat *customer* ", " (chr 10) (chr 13) *location* ", " (chr 10) (chr 13) *project* ) ;_ end of strcat ) ;_ end of setq (vlax-put-property acDocSumInfo "Comments" *comments*) (princ)) ;_ end of defun
The text comes in but all on one line.
I am writing a program to grab a bunch of layers from a list, check a drawing to see if the layers are on the list, and if not save to an external file. I have the second part of the program done, but I can't get the first part to work.
I am trying to open a file read the contents and save it to a list.
Here is the code I have so far, but it doesn't even get into the foreach statement.
(setq layerslist (list '"0list" '"detaillist" '"clearancelist" '"clearanceelist" '"doorsdrawerslist" '"hiddenlist" '"hiddenelist" '"deletelist"))(setq count 0)(foreach thislayer layerslist (setq f (open (strcat "C:\filterlists\" thislayer ".txt") "r")) (while (/= (setq text (read-line f)) nil) (setq (read thislayer) (cond ( (= 0 count) (cons (cons 8 text) (read thislayer)))( (append (read thislayer) (list (cons 8 text))) ) );cond );setq (setq count (+ count 1)) );while (close f) );foreach
I've also attached one of the text files. Im doing something in the wrong order, or I have something inside the wrong set of parenthesis.
Write the elevation text in a cad file from attached text file.
In this text file Easting Northing and Elevations are given. We have hundreds of that text files.
I have some numeric data like 1, 2, 3, 4, 5 in mtext format in autocad drawing file and some numeric data like 1,2, 3 in notepad.
How can i get the remaining numeric data of autocad dwg into another notepad using autolisp or visual lisp
Is it possible to write an event handler for an autocad event/ command like insert new block? I want the event to trigger the execution of an update routine . something like this post
[URL]
how do I access the autocad object in autolisp?
I am trying to write a lisp routine that will make a layer called hatch, set it as current and then run the hatch command.
BUT the hatch command is not bring up the hatch dialogue box, it just puts things on the command line.
The layer is being made & set current.
The lisp is as follows:
(defun c:hh (/ ec)
(setq ec (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "-layer" "m" "hatch" "c" "8" "" "l" "continuous" "" "s" "hatch" "")
(command "hatch")
(setvar "cmdecho" ec)
)
On another matter, I have just found the bevel lisp routine by Terry Miller which works great BUT only for imperial measurements. How to make Terry's metric, that will work for metric measurements.
Is it possible to write a Macro in the CUI that opens a drawing in Read-Only mode? Limitation : AutoCAD LT.
View 7 Replies View RelatedIs there a way to import layers from a text file?
View 9 Replies View RelatedReplacing characters in a text file.
I solved the following Lisp routine chore. I have this csv file of coordinates (and many more) that comes from a total station:1,100,100,10,50
2,100,200,12,50
3,200,200,12,50
4,200,100,10,51
and should replace the code after the last comma like this:1,100,100,10,.50
2,100,200,12,.50
3,200,200,12,.50
4,200,100,10,..50
To be able to generate the topographic map. And I have this code but does not work properly:
(defun c:cod (/ filename fileopenr readline)
(if (setq filename (getfiled "!!! SELECT *.csv FILE COORDINATE:... ¡¡¡" "c:/" "csv" 0 ))
(progn (setq fileopenr (open filename "w"))
(while (setq readline (read-line fileopenr))
[[code].......
I have the following code which isnt quite working, it reads a text file which has a list of Names of images and their bottom left coordinates i.e. name x y etc. I want it to check for a name equal to that input then in this case alert the user it is found, eventually I want it to load the tile but for the moment where am I going wrong, also the lisp wont close the file and I dont know why.
(defun c:imi ()
(setq IM (getstring "
Input name of 2010 tile"))
(while (not (= "" IM))
(setq TILE (strcat "BM" IM))
[Code] ......
I have spent the last three days writing a lisp program that will copy a text string from one text file and paste it into another. I have tried using the write-string, getstring, prin1, princ and print functions with no success.
View 6 Replies View RelatedI'm looking for a way to find out what all plot styles are set in drawings in a sheet set.
We are transitioning from color based pen settings to style based and would like to be able to export a log that shows the variable PSTYLEMODE for each drawing in a sheet set. I plan on using ScriptPro to run it on the full sheet set.
Civil 3D 2013
Windows 7 64-bit
Xeon W3550 3.07 GHz
Nvidia Quadro 4000
12.0 GB RAM
Im trying to come up with a lisp that will export x and y coords to a txt or cvs file. However, I need the lisp to export in this format
Units Inch
WPT 1 0 0 ( X=0 Y=0)
WPT 2 1 1 (X=1 Y=1)
WPT 3 2 2
I need to be able to set my zero with move origin and the export the points.
With all of you fine teachers, I have the know-how to get the start and end values of a line.
Do you think there is a way to get a point returned that represents the true intersection of the two lines, without having to involke a user defined "getpoint" function using "intersect" osnap?
Run TIME command and then take the resulting text and save it to a file.
Ideally, the text file should be named based on the drawing name. I know there's ways to write text to a file but I haven't had any luck taking the output of a command and exporting it.
how to append I’m assuming its not write-line but append line. And also I’m having trouble recording the date variable… I keep getting error bad argument type stringp nil
; Appends usage count by DATE long variable...(setq g(open "C:/ICT/AutoCAD_Architecture_suite_2012/CUSTOM/WOOD Clones/PEN/USSAGELOG.PEN" "w"))(setq MYDATE DATE)(write-line MYDATE g); AS ABSOLUTE LAST WE NEED TO CLOSE THE TEXTFILE...(close g)
I have the following code snippet I’m trying to append the file named USAGELOG.TXT to record the date of executions
I have a text file with a list of image tile names with their bottom left hand easting and northing see attached. I have a lisp that asks for the name of the image then should insert the image at its coordinate with a predefined scale and rotation but it isn't working so I would like an alternative method to test.
View 4 Replies View RelatedNeed a lisp that could dump the values of a list command in a text file placed in a folder C:user121list.txt.
View 9 Replies View RelatedI have a project in 3D that I would like to export to Stadd. This requires lines rather than blocks. Is is possible to convert the blocks in the attached dwg file to to lines that are centered on those blocks?
View 9 Replies View RelatedI want to construct lines between every two line ending point by multi selectio window instead of drawing it manually between lines ending point ?
View 3 Replies View RelatedI got a new work and get it done in the next 2 days, but first I need to do this... from a text file (or excel file, I got both) I got 3 columns, 1 one for node number, and 2 other for X and Y coordinates for each node.
So from that file I need to insert into autocad the node numbers as text (using the current style and height) at the point specified by the other two columns, that are the X,Y coordinates which will be the insertion point of text..
I’m trying to create a plot command that reads settings in from a variable stored in a text file but its becoming muddled up somewhere.
(defun c:MYPLOT ();Setting nessesary variables...(setq fname "C:/ICT/AutoCAD_Architecture_Suite_2012/CUSTOM/TREADSTONE/PEN/MYOUTPUTDEVICE.PEN")(if(setq f(open fname "r"))(while (setq MYOUTPUTDEVICE (read-line f))(close)))(setq fname "C:/ICT/AutoCAD_Architecture_Suite_2012/CUSTOM/TREADSTONE/PEN/MYPAPERSIZE.PEN")
[code].......
I am trying to draw a line between two lines and I put together the following. It works great if the start/end points are perpendicular to each other. How do I solve if line one start point is in a positive direction and line two is in a negative direction?
(defun c:test ()
(setq L1 (car (entsel "
Select the first line: "))
L2 (car (entsel "
Select the second line: "))
)
[code]....