Jump to content

Recommended Posts

Posted

I'm in the process of going through our company's old LISP routines. While most lisps were loaded as separate files through a single lisp load command, this code was just plopped into the lisp load command, with no comments. Can someone tell me what this code does and how to use it so I can decide if it's worth keeping? Thank you!

 

(defun C:WC  (/ INGET FPT GETD GETDTEMP ENAME ENAME1 ENT1 ENT2 SS1 SS2 SS3 SS4)
 (setq V1 (getvar "osmode"))
 (setq V2 (getvar "cmdecho"))
 (setvar "osmode" 0)
 (setvar "cmdecho" 0)
 (initget "Horizontal Vertical")
 (setq INGET (getkword "\nType of break [Horizontal/Vertical]: "))
 (if (= GETDTEMP1 nil)
   (setq GETDTEMP1 (getreal "\nBreak Length: "))
   (setq GETDTEMP1 (getreal (strcat "\nBreak Length <" (rtos GETDTEMP2) ">: ")))
 )
 (if (or (= GETDTEMP1 "")(= GETDTEMP1 nil))(setq GETDTEMP1 GETDTEMP2))
 (setq GETDTEMP2 GETDTEMP1)
 (setq GETD GETDTEMP1)
 (prompt "\nNow move Crosshairs near each intersection to break <press Enter to stop> :")
 (setq ENAME "LINE")
 (setq ENAME1 "LINE")
 (while GETD
   (setq FPT (osnap (cadr (grread 1)) "int"))
   (if (/= FPT NIL)
     (progn
       (setq SS1 (nentselp (polar FPT 0.00 GETD)))
       (setq SS2 (nentselp (polar FPT 3.14 GETD)))
       (setq SS3 (nentselp (polar FPT 1.57 GETD)))
       (setq SS4 (nentselp (polar FPT 4.71 GETD)))
       (setq ENT1 (ssget (polar FPT 0.00 GETD)))
       (setq ENT2 (ssget (polar FPT 1.57 GETD)))
     )
   )
   (if (and (/= ENT1 NIL)(/= ENT2 NIL))
     (progn
       (setq ENAME (cdr (assoc 0 (entget (ssname ENT1 0)))))
       (setq ENAME1 (cdr (assoc 0 (entget (ssname ENT2 0)))))
     )
   )
   (if (and (/= ENAME "LINE")(/= ENAME "LWPOLYLINE")(or (= INGET "Horizontal")(= INGET NIL)))
     (progn
       (print "Entity is not a Line or Polyline")
       (setq FPT NIL)
     )
   )
   (if (and (/= ENAME1 "LINE")(/= ENAME1 "LWPOLYLINE")(= INGET "Vertical"))
     (progn
       (print "Entity is not a Line or Polyline")
       (setq FPT NIL)
     )
   )
   (if (and (/= FPT NIL)(/= SS1 NIL)(/= SS2 NIL)(/= SS3 NIL)(/= SS4 NIL)(or (= INGET "Horizontal")(= INGET NIL)))
     (command ".BREAK" (cadr SS1)(cadr SS2))
   )
   (if (and (/= FPT NIL)(= INGET "Vertical")(/= SS1 NIL)(/= SS2 NIL)(/= SS3 NIL)(/= SS4 NIL))
     (command ".BREAK" (cadr SS3)(cadr SS4))
   )
 )

 (setvar "osmode" V1)
 (setvar "cmdecho" V2)
 (princ)
) ;wc

Posted

Sometimes, where lines cross, we don't want them to touch, and typically we use jumps or gaps to denote this.

This program makes gaps, and the user chooses either horizontal or vertical line gap and gap length.

After the choices are input, the user is then instructed to "move Crosshairs near each intersection to break," and the gap is made automatically.

I found the command line prompts to be quite adequate.

Neat program. Thanks for posting it.

 

Steve

Posted

Add this to start of code thanks to stevJ good idea to add a few lines at start of code if the file name is not obvious. A lot of old lisps were restricted to 8 Character names.

 

; This program makes gaps
; The user chooses either horizontal or vertical line gap and gap length.
; After the choices are input move Crosshairs near each intersection to break
; Gap is made automatically.

Posted

Thanks both of you! I had tried to run it yesterday assuming it did something along those lines, but it didn't work because I set an arbitrary break line length that happened to be longer than the lines I was breaking. doh!

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...