AutoCAD Visual LISP / AutoLISP :: Write Content Of Variables To Text File?
Feb 17, 2013
I 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].....
View 5 Replies
ADVERTISEMENT
Apr 13, 2012
I 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 Replies
View Related
Jun 27, 2013
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"))
View 9 Replies
View Related
Jun 5, 2013
How can I read the content/ string in the *.dwg file through autolisp?
Suppose I have used any word multiple times in a sheet. How can I count it through lisp programme?
View 9 Replies
View Related
Aug 1, 2013
I have this lisp that grabs all the text(the value and the location) in my drawings and I put them into a list. Here is what I have so far:
(defun c:loop ()
(setq numbers (ssget "_X" (list (cons 0 "TEXT") (cons 1 "##*")) ))
(setq newlist '())
(setq IN 0);set index
(setq SLGTH (sslength numbers))
[code].......
What i need to happen is this: When "whatever" returns "value0" i need to set "value0" to the first item in list "newlist". Then when "whatever" returns "value1" i need to set "value1" to the second item. Now I can do it the long hand way, but i am trying to simplify this step, and shorten up my overall program.
View 4 Replies
View Related
Jun 5, 2012
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 Related
Oct 23, 2012
How can I pass the contents of a cell value (text string) to Acad? I want the user to click on a cell, then have lisp use the string as the name of a block to insert.
View 4 Replies
View Related
Apr 2, 2012
So what I'm trying to do is make a selection set that will only select a specific dimension, as I don't know the exact placement as it varies depending on the size of the part. I know what the value will be, but again the value depends on the size of the part, but one of the items earlier in my program is I get the Hole Spacing, which the dimension I need to select is Half of the Hole Spacing. Here is what I'm trying:
(setq HALFBOLTSPCDXF '((1 . HALFBOLTSPC)))
where HALFBOLTSPC is a variable that takes the Bolt Spacing and divides it by 2.
When I do a run selection in Visual LISP, I get the following:
((1 . HALFBOLTSPC))
But what I was expecting to get was:
((1 . "10.00""))
As my test case is using 20" Hole Spacing which means half the hole spacing is 10.00". So is there another way to do this? OR what do I need to do to get it to recognize the Variable and give the value instead of the Variable name?
If needed: AutoCAD 2013 User using Visual LISP for editing LISP and DCL files Also I have AutoCAD 2011 currently still available for us, but we are using AutoCAD 2013 for 99.9% of AutoCAD use
View 6 Replies
View Related
Feb 23, 2012
a simple lisp file?
I want to set "hideprecision" to 1. This variable can not be saved - I looked it up in Express Tools.
So I thought a lisp file to load at start up would do the trick.
View 3 Replies
View Related
Oct 11, 2012
How I can reset all system variables. I refer to the variables that affect the program globally. I want all remain at the default value. One lisp?
View 2 Replies
View Related
Oct 31, 2013
I am unsure why my Lisp does not work.
(DEFUN C:Clear_values (/ GLBLS) (SETQGLBLS '(*DATEDRAWN* *DRAFTNAME* *JOBNUMBER* *OWNERNAME**JOBCOE* *PERMITREVDATE* *PERMITCONTACT* *HOMEBUILDER**SUBDIVISION* *ADDRESS**CITY* *STATE* *ZIP* *LOT#**PARCEL#* *NSCOORD* *EWCOORD* *STANDARDDETAIL#**SUPERNAME* *SALESMAN**GATECODE* *HOMEPHONE* *WORKPHONE* *ALTPHONE1**ALTPHONE2* *EMAIL1* *EMAIL2* *ACCESS**EXCAVATIONTYP* *EXCATDEMO1**EXCATDEMO2* *SKIMRUN* *AWLRUN*
[code]....
I've tried several options such as (mapcar 'set GLBLS "%%") but nothing happens, and with the above code nothing happens; the code only returns nil.
View 8 Replies
View Related
Aug 14, 2012
Writing a routine that stores a file name as a string in variable FILE.I check the variable and it returns a nice quoted string: "filename-123.dwg"
I would like AutoCAD to open the file w/out user input.With FILEDIA set to 0, I've tried passing the variable to the command line:
(command "open" FILE)
or in a script as:
open
(FILE)
...
or,
open
!FILE
...
I get the same error. The string dumps to the command line and I get 'Unknown command "DWG" .'
View 9 Replies
View Related
Jan 11, 2012
I have a custom variable id like to have displayed in my princ section I have the following however it keeps returning ; error: bad argument type: file
(princ MYVAR " file found..."))
How can I fix this?
View 1 Replies
View Related
Oct 11, 2012
I'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:-
View 4 Replies
View Related
Jun 10, 2013
My company is in the process of upgrading to AutoCAD 2013 (yes, I know 2014 is out, but IT won’t let us get the most recent because of fear of “new release bugs”). My company is small and our CAD Standards/Management is less than desirable. Over the past few years I have become the unofficial company CAD Manager and have slowly been getting us up to speed with using the latest capabilities and following best practices.
An issue that I deal with constantly is a new user not having the correct registry-saved system variables set up. This also happens a lot because our IT guy frequently reinstalls AutoCAD to fix issues. Every time AutoCAD is installed/reinstalled, all the registry-saved system variables are set to their default values. We have several that need to be set a certain way to match our current drafting standards (a few examples: .bak files turned off, plot.log files turned off, advanced attribute editor turned on, plot area relative to edge of paper, etc, etc.). Typically, I will get complaints from users about something not working correctly, and then I will troubleshoot the issue and eventually find out that they just had their AutoCAD reinstalled and their system variables are not set how they should be. Then I will get out my list and have them set all the variable s properly via the AutoCAD command line.
I have read up on creating AutoCAD Deployments (and we will be using these Deployments for this upgrade), but there does not seem to be a way to set variables when creating the Deployment.
Finally, to complicate things a little more, most of our users actually use AutoCAD LT (so no Lisp), and only a select few (like me) have full AutoCAD. So, we will be creating two separate Deployment files as it stands (which is not a big deal).
Some of my preferred criteria for the solution:
-Solution can be used for both AutoCAD & AutoCAD LT (I’m okay with there being two separate system variable “deployment” files since we will already have two different AutoCAD Deployments. I would just like the procedure for deploying both packages to be the same regardless of whether it’s for LT or full version).
- Solution would be able to be applied to each workstation without opening AutoCAD on each machine (and ideally, it would all happen when the AutoCAD Deployment installer was run!)
Is there any current best practices for accomplishing this? (maybe by changing the registry through batch files, VBscript files, etc? Or using AutoCAD script files – however, this requires the program to be open to run, which I was trying to avoid).
View 7 Replies
View Related
May 27, 2013
How can specific attribute values be extracted from a drawing and assigned to a variable in lisp.
The existing title block is having attributes : Area, Sub area, Description, Drawing type. I want to extract this values and assign it to some variable which I have already listed and then it shall be assigned to some other attributes in the same drawing with Area1, Subarea1, Description1, Drawing type1... and so on.. Both the attributes shall be in the same drawing file.
View 3 Replies
View Related
Apr 9, 2012
Looking for Lisp command to show (read/assign variables) to normal or custom properties in an object?
View 7 Replies
View Related
Jun 27, 2012
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.
View 9 Replies
View Related
Mar 21, 2012
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
View 6 Replies
View Related
Jul 19, 2012
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?
View 4 Replies
View Related
Aug 1, 2012
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.
View 6 Replies
View Related
Sep 18, 2012
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 Related
Mar 12, 2012
Is there a way to import layers from a text file?
View 9 Replies
View Related
Sep 13, 2012
Replacing 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].......
View 1 Replies
View Related
Sep 27, 2011
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] ......
View 4 Replies
View Related
May 2, 2012
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 Related
Apr 5, 2013
I'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
View 2 Replies
View Related
Jun 8, 2012
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.
View 9 Replies
View Related
May 14, 2012
I have a table, in cell D3 I have inserted a field containing a system variable. The contents of the cell looks like this,
%<AcVar dimadec>%
I want to put in cell D2 the name of the vairable that is in cell D3 - I have tried the following,
%<AcExpr (D3).ObjectName>%
%<AcExpr (D3).textstring>%
Is there any way to reference the name of that system variable contained in cell D3? I want to do this to prevent errors by curious new users that may edit the table, I want the table to reference itself so that the system variable being read is always related to the correct system variable name.
View 6 Replies
View Related
Oct 22, 2011
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.
View 9 Replies
View Related
Feb 22, 2012
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
View 2 Replies
View Related