autocad crashes when running routine

autocad crashes when running routine

diegolopezsilanes
Advocate Advocate
1,015 Views
4 Replies
Message 1 of 5

autocad crashes when running routine

diegolopezsilanes
Advocate
Advocate

Hi, i'm on a code for rotating entities to some  especified angles whith a preview of the result and autocad crashes while running the command.

any idea to improve the code?

 

; http://www.theswamp.org/index.php?topic=12813.90
(defun fe-follow-mouse (_sset / pos_mouse pt_mouse pt)
  ;;(command "_.copy" _sset "" (list 0 0 0) (list 0 0 0))
  (setvar "OSMODE" 0)
  (command)
  (setq pt (cadr (grread t 1 0)))
  (while (= (car (setq pos_mouse (grread t 1 0))) 5)
    (setq pt_mouse (cadr pos_mouse))
	(command "_.erase" ss1 "")
	(command "_.erase" ss2 "")
	(command "_.erase" ss3 "")
	(if sect1 (progn
	(command "_.copy" _sset "" "0,0" "0,0")
	(setq ss1 (ssadd (entlast)))))
	(if sect2 (progn
	(command "_.copy" _sset "" "0,0" "0,0")
	(setq ss2 (ssadd (entlast)))))
	(if sect1 (progn (progn
	(command "_.copy" _sset "" "0,0" "0,0")
	(setq ss3 (ssadd (entlast))))))


		(if sect1 (command "_.ROTATE" ss1 "" pt_mouse  SECT1))
		(if sect2 (command "_.ROTATE" ss2 "" pt_mouse  SECT2))
		(if sect3 (command "_.ROTATE" ss3 "" pt_mouse  SECT3))
(grdraw pt pt_mouse 3 1)

    (setq pt pt_mouse)
  )
)
(defun c:rot ()
(setq SECT1 (getINT "SECT1 "))
(setq SECT2 (getINT "SECT2 "))
(setq SECT3 (getINT "SECT3 "))
(setq _sset (ssget))
(fe-follow-mouse _sset )
)
0 Likes
Accepted solutions (1)
1,016 Views
4 Replies
Replies (4)
Message 2 of 5

diegolopezsilanes
Advocate
Advocate

does anyone know how to implement osnap functionality on it?

0 Likes
Message 3 of 5

ВeekeeCZ
Consultant
Consultant

Sure we know. Or at least we know where to look. HERE

 

About your code. Would you post some example dwg and record video about what it should do? Not really clear to me. 

You know, autocad commands are not best to use withing grread, they are too slow... 

 

This will probably not fix the lisp, but (command "erase" ss1 ss2 ss3 "") is also possible. Why do you even use ss? Just an ename would work too. (setq en1 (entlast)) -> (command "rotate" en1 "" ...)

 

0 Likes
Message 4 of 5

diegolopezsilanes
Advocate
Advocate

basically it makes a polar matrix of th eseleccted entity setting the center of the matrix in the cursor position and making a preview of the result

0 Likes
Message 5 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

Tried make it a little faster.

 

(defun fe-follow-mouse (ent / pos_mouse pt_mouse pt_last enl ent)
  
  (command)

  (setq pt_last (cadr (grread t 1 0)))
 
  (while (= (car (setq pos_mouse (grread t 1 0))) 5)

    (setq pt_mouse (cadr pos_mouse))

    (if enl (while (setq enl (entnext enl)) (entdel enl)))

    (setq enl (entlast))
    (if sect1 (command "_.ROTATE" ent "" pt_mouse "_copy" SECT1))
    (if sect2 (command "_.ROTATE" ent "" pt_mouse "_copy" SECT2))
    (if sect3 (command "_.ROTATE" ent "" pt_mouse "_copy" SECT3))

    (grdraw pt_last (setq pt_last pt_mouse) 3 1)
    
    )
  )

(defun c:rot ()
  (setvar "CMDECHO" 0)
  (setq SECT1 (getINT "SECT1 "))
  (setq SECT2 (getINT "SECT2 "))
  (setq SECT3 (getINT "SECT3 "))
  
  (fe-follow-mouse (car (entsel)))
  (setvar "CMDECHO" 1)
  )

Or a version with osnaps attached... which made it slow again.

0 Likes