PDA

View Full Version : Break at Routine Help


Gigliano70
2008-07-07, 06:06 PM
I have two different break at intersection routines and they both clear my osnaps once they have completed. can someone take a look and see what the problem is?

;Description: This lisp routine breaks at intersection
;****************************************************************************

(defun c:bi ()
(setvar "cmdecho" 0)(command "coords" "0")
(graphscr)
(setq lay (getvar "clayer"))
(setq txt (strcat "Layer " lay " - Tweaqed Concepts '96"))
(grtext -1 txt)
(grtext -2 "Another Bryen Product")
(setvar "cmdecho" 0)
(command "osnap" "nea")
(setq a (getpoint "\nEntity to break: "))
(command "osnap" "none")
(command "osnap" "int")
(setq b (getpoint "\nIntersection to break at: "))
(command "osnap" "none")
(command "break" a "f" b b)
(setvar "cmdecho" 1)
(princ)
)

(defun c:il ()
(setq a (entget (car (entsel "Select target:"))))
(setq a (cdr (assoc 8 a)))
(command "layer" "s" a "")
(command "layer" "f" "*" "")
)

;Description: This lisp routine breaks at intersection
;****************************************************************************
;USE THIS IF OSNAPS GET RESET BY BI

;WILL BREAK A LINE AT AN INTERSECTION WITH ANOTHER LINE. AUTOMATICALLY SETS
;OSNAP TO "INTERSECT". *[LL]
;
(defun C:BK (/ ln bkpt)
(setq om (getvar "osmode"))
(setvar "cmdecho" 0)
(setvar "osmode" 32)
(setq ln (entsel "\nChoose Line to Break..."))
(setq bkpt (getpoint "\nPick Break Point.. "))
(command "break" ln "f" bkpt "@")
(setvar "osmode" om)
(setvar "cmdecho" 1)
(prin1)
)


Thanks in advance all.

Moderator Note:
Please use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)

Opie
2008-07-07, 06:17 PM
You are not saving and restoring your osmode during the first routine.

jmcshane
2008-07-07, 06:32 PM
I have two different break at intersection routines and they both clear my osnaps once they have completed. can someone take a look and see what the problem is?


Looking at your code I can see that you are making extensive use of the command function to set your object snaps.
And in the first routine you actually set Object snap to "none":

(command "osnap" "none")

which is the reason why it clears any object snap settings you do have.

There are two ways of doing it. You can save the current object snaps

(setq OM (getvar "OSMODE"))

and reset them whenever you are finished

(setvar "OSMODE" OM)

or you can just specify the object snap like the code below that calls the intersection
osnap "int" and which doesn't affect any of your other settings.


(defun C:BI ()
(SETVAR "CMDECHO" 0)
(princ "\n\n ***** Break at Intersection *****")
(princ "\n")
(princ "\nSelect line to break: ")
(command "break" pause "f" "int" pause "@")
(SETVAR "CMDECHO" 1)
(princ)
)



HTH

Gigliano70
2008-07-07, 07:20 PM
Thanks guys,

Nothing like confusing a simple process.