My lisp not work 2

My lisp not work 2

saitoib
Advocate Advocate
642 Views
3 Replies
Message 1 of 4

My lisp not work 2

saitoib
Advocate
Advocate

Once again, let me ask you a question.

 

line 0,0 to 100,0
offset 2 Y+.

 

If I create two lines, and then execute the following Lisp with the created lines almost filling the screen
It works normally.
Next, if I run the Lisp with the line zoomed out to about half of the screen, it will write on the second line.

However, the command line display is the same for both
Start= (0.0 1.0 0.0) End= (100.0 1.0 0.0)

 

Is this a problem with Lisp?

 

;;;*************************************************
(defun c:CTest
  (
  / en1 en2 p1s p1e p2s p2e p3s p3e
    ip dv1 dv2 tmp ed1 ed2 ed3
;    ss nn i count
  )
    (if (setq en1 (car (entsel "\nSelect first line")))
        (progn
            (redraw en1 3)
            (if (setq en2 (car (entsel "\nSelect second line")))
                (redraw en2 3)
                (progn (redraw en1 4) (quit))
            )
        )
        (quit)
    )
    ;直線の開始点、終了点を取得
    (setq p1s (cdr (assoc 10 (entget en1)))) ;Start point of first line
    (setq p1e (cdr (assoc 11 (entget en1)))) ;End point of first line
    (setq p2s (cdr (assoc 10 (entget en2)))) ;Start point of second line
    (setq p2e (cdr (assoc 11 (entget en2)))) ;End point of second line

    ;Align direction of the line
;    (setq dv1 (mapcar '- p1e p1s))
;    (setq dv2 (mapcar '- p2e p2s))
;    (setq ip (apply '+ (mapcar '* dv1 dv2)))
;    (if (< ip 0.0) (setq tmp p2s p2s p2e p2e tmp));Swap start and end points

    ;Get start and end points of center line
    (setq p3s (mapcar '+ p1s p2s))
    (setq p3s (mapcar '/ p3s '(2.0 2.0 2.0))) 
    (setq p3e (mapcar '+ p1e p2e))
    (setq p3e (mapcar '/ p3e '(2.0 2.0 2.0)))
  
    (command "LINE" p3s p3e "")

	(princ "Start= ") (princ p3s)
	(princ " End= ") (princ p3e)
	(princ)
) 
Saitoib
0 Likes
Accepted solutions (1)
643 Views
3 Replies
Replies (3)
Message 2 of 4

Moshe-A
Mentor
Mentor

@saitoib 

 

However, the command line display is the same for both
Start= (0.0 1.0 0.0) End= (100.0 1.0 0.0)

so what is wrong here?

 

zoom out (or in) does not change the coordinates of a lines (nor any other existing objects) it only change the view.

 

Moshe

 

 

 

0 Likes
Message 3 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

If you mean that it has those correct values in the p3s and p3e variables, and fed them into the Line command as expected, but the Line is not between those but overlays the second of the original Lines, I think you have some running Object Snap mode(s) on.  That's the most common cause for things being drawn somewhere other than where you expect.

 

Try invoking NONE object snap for each point in drawing the Line, like this:

 

(command "LINE" "_non" p3s "_non" p3e "")

 

 Or you can save the OSMODE System Variable setting at the beginning, set it to 0 to turn off Osnap while you do stuff, and reset it afterwards.

Or you can use (entmake), which is not subject to Object Snap, to make the Line, instead of using a (command) function.

Kent Cooper, AIA
0 Likes
Message 4 of 4

saitoib
Advocate
Advocate

I was able to solve the problem.
Thank you very much.

Saitoib
0 Likes