Lisp excute inconsisted result

Lisp excute inconsisted result

nam.lethai1995
Enthusiast Enthusiast
580 Views
3 Replies
Message 1 of 4

Lisp excute inconsisted result

nam.lethai1995
Enthusiast
Enthusiast

I dont even know to describe this. I am trying to write a lisp for auto dim, in which i will pre define a variable for dimesion line location but the defined variable is not always be consider when the lisp is excuted
(defun c:D2 ()
(while (not (equal (setq ent (entsel)) nil))
(progn
(setq dxf (entget (car ent)))
(setq start (cdr (assoc 10 dxf)))
(setq end (cdr (assoc 11 dxf)))
(command "dimaligned" start end)
(princ)
)
)
)
--------------------------------------------
(defun c:d11 ()
(setq d11 (getreal "nhap khoang cach"))
)
--------------------------------------------
(defun c:d1 ()
(setq ss (ssget)
len (sslength ss)
i 0
)
(if (not (boundp 'd11))
(setq D11 40)
)
(repeat len
(progn
(setq ent (ssname ss i)
entd (entget ent)
i (+ 1 i)
)
(if (eq (cdr (assoc 0 entd)) ' "LINE")
(progn
(setq start (cdr (assoc 10 entd))
end (cdr (assoc 11 entd))
)

(command "dimaligned"
start
end
(trans (polar start (+ (angle start end) (/ pi 2)) d11) 0 1)
""
))
)
(command "mirror" ent "" (cdr (assoc 13 entd)) (cdr (assoc 14 entd)) "Y")
)
)
)

0 Likes
Accepted solutions (3)
581 Views
3 Replies
Replies (3)
Message 2 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

Turn off running Object Snap.

Kent1Cooper_0-1689337134206.png

Kent Cooper, AIA
0 Likes
Message 3 of 4

nam.lethai1995
Enthusiast
Enthusiast
Accepted solution

Wow, thanks you Kent, i had seen some one mentioned about turning off object snap when running lisp before but i never actually belive that it will be affective until now. 

0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

@nam.lethai1995 wrote:

Wow, thanks you Kent, i had seen some one mentioned about turning off object snap when running lisp before but i never actually belive that it will be affective until now. 


It matters only when the code includes drawing or editing commands in (command) functions that involve specifying locations -- they will be subject to Osnap settings.  This is nearly always the cause of the trouble when things are drawn but end up in different locations than expected, somehow.

 

For a lot of things, making them with (entmake) instead of with (command) functions gets around the issue, because it is not subject to Osnap settings.  But making Dimensions that way is very complex.

 

You will find many routines in the Forums with that built in, to do the same in yours, including saving the current setting first and restoring it afterwards.

Kent Cooper, AIA