Jump to content

Recommended Posts

Posted (edited)

Hi everyone! Could somebody modify this lisp for me so I could repeat the command multiple times? This code is not mine and I don't know the author.

I have base knowledge about lisp and I've tried something to make it work using MULTIPLE command or WHILE function - but I'm not good at coding (when I try to run MULTIPLE command from lisp - it does not recognize my lisp command "BA" - I don't know why, and I have no idea how to set this code up with WHILE function)

Thanks.

 

;--------------------------------------------------------------------------
;The AutoCAD built-in Break at Point does not work well because of AutoSnap. AutoSnap has to be temporarily turned off (important!!). I've written the following Lisp which allows user to select and object, and followed by picking a break point, command will be sent out with AutoSnap turned off temporarily.

(defun c:ba (/ obj pt1 osmode cmdecho)

 (setq obj (car (entsel)))
 (setq pt1 (getpoint "\nSpecify break point: "))

 (setq osmode (getvar "osmode"))
 (setq cmdecho (getvar "cmdecho"))
 (setvar "osmode" 0)
 (setvar "cmdecho" 0)

 (command "break" obj pt1 pt1)

 (setvar "osmode" osmode)
 (setvar "cmdecho" cmdecho)

 (princ)

)
;-------------------------------------------------------------------------

Edited by SLW210
Posted

(defun c:ba (/ obj pt1 osmode cmdecho)
  (setq osmode (getvar "osmode"))
  (setq cmdecho (getvar "cmdecho"))
  (setvar "osmode" 512) ; nearest  
  (setvar "cmdecho" 0)
  (while (setq pt1 (getpoint "\nSpecify break point: "))
    (command "break" pt1 pt1 pt1)
  )
  (setvar "osmode" osmode)
  (setvar "cmdecho" cmdecho)
  (princ)
)

 

Set your osmode to 512 which is nearest.

 

Your point can be used to select the entity.

 

ymg

Posted

A quick-and-dirty adjustment:

(defun c:ba(/ obj pt1 osmode cmdecho)
(setq osmode (getvar "osmode"))
(setq cmdecho (getvar "cmdecho"))
(setq obj (car (entsel)))
(while (and (setq pt1 (getpoint "\nSpecify break point: "))
            (setq obj (ssget pt1)))
 (setq obj (ssname obj 0))
 (setvar "osmode" 0)
 (setvar "cmdecho" 0)

 (command "break" obj pt1 pt1)
 (setvar "osmode" osmode)
)
(setvar "cmdecho" cmdecho)
(princ)
)

 

Please edit your post and add required code tags.

Posted

Thank you so much, guys! it works perfectly with osmode set to 544 (intersection and nearest) :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...