Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

graphic error created when using lisp code

2 REPLIES 2
Reply
Message 1 of 3
JFLoomis_2014
429 Views, 2 Replies

graphic error created when using lisp code

HI All,

We’re having trouble with graphical errors trying to draw a line from within a lisp program. The A.txt file must be located in the "C:\logs" directory, as it's hard coded within the lisp file.

 

Attached is the program and a text file, designed to create a continuous line sting using horizontal and vertical lines that index 0.5” fixed X direction by while obtaining the new “Y” value by reading the a.txt file.

 

This program has been tested on (2) computes an HPZ400 3.2Ghz Zeon CPU (ACAD v2010) and a HP Z820 with dual E5-2687w 0 3.1Ghz CPU’s (ACAD v2010 v2013 & v2014). Both operating on Windows 7 64bit with each CAD packages SP’s current.

 

When this code is run, the drawing file will contain some diagonal lines along the stepped profile that is created. We added the code to write the line number & X,Y point value to an output file within the loop. The graphic errors remain, while the output file is accurate with the read file.

 

The error appear to be random and can start and stop anywhere along the line and then begin to run correctly again. Sometimes it executes without error, sometimes we’ve seen that the 0.5” fixed “X” increment is doubled and tripled to 1.0 (v2013) and 1.5” (v2014) long.

 

Has anyone experienced anything similar? Is there an error in the code that I’m not seeing or something missing? Is there a better way to accomplish what we’re trying to achieve? Any and all help will be greatly appreciated, thank in advance! John

 

(defun c:a(/ l x0 y0 x y xshift g g1)

;;main program

;;Sets initial variables.

 (setq l(getvar"luprec"))
 (setvar"luprec"3)
 (setq x0 0)
 (setq y0 0)
 (setq x x0)
 (setq y 0)
 (setq xshift 0.5)

;;Opens a.txt file, for reading y distances data.
;;Opens a_out.txt file, for writing out x,y point for inspection.

 (setq g(open"c:/Logs/ar.txt""r"))
 (setq g1(open"c:/Logs/a_out.txt""w"))
 (setq line# 0)
 (write-line(strcat(rtos x)" , "(rtos y))g1)

;;Loop 445 times = to line count in A.txt

 (repeat 445
  (command"_.line"(list x y))
  (setq line# (+ line# 1))
  (setq y(atof(read-line g)))
  (command(list x y))
  (write-line(strcat(itoa line#)": "(rtos x)" , "(rtos y))g1)
  (setq x(+ x xshift))
  (command(list x y)"")
  (write-line(strcat(itoa line#)": "(rtos x)" , "(rtos y))g1)
 )
 (close g)
 (close g1)

;;Closes profile from last point to 0 y and then to 0,0.

 (command"_.line"(list x y)(list x y0)(list x0 y0) "")
 (command"zoom""all")

;;resets variables to nil

 (setvar"luprec"l)
 (setq l nil x0 nil y0 nil x nil y nil xshift nil g nil g1 nil)
 (setq c:a nil)
)

2 REPLIES 2
Message 2 of 3
Kent1Cooper
in reply to: JFLoomis_2014

Do you have running Object Snap modes on?

Kent Cooper, AIA
Message 3 of 3
stevor
in reply to: JFLoomis_2014

In addition to the Object Snap,

it is safer to disable any 'modes'

that can effect the value

that is used by a Command function.

 

Ie,(setvar 'osmode 0) (setvar 'snapmode 0)(setvar 'orthomode 0)

Maybe even the Elevation.

They can be saved and restored after your procedure.

 

S

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost