Results 1 to 3 of 3

Thread: OrthoXline V2.0

  1. #1
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Too far from the beach
    Posts
    1,054
    Login to Give a bone
    0

    Default OrthoXline V2.0

    This is a staple of my toolbox and I just rewrote the error code.
    I hadn't updated it since Command-S came out (I took a break from CAD for 5 years and hadn't gotten around to it in the last two years until today)

    So...
    Can this be made better?
    A better way of doing any of the functions?
    Show me the light...

    Code:
    ;;; Written by Jim Fisher on 02/03/00.
    ;;; Modified by Tod Winn on 01/22/01 to grab the CMDECHO and set the layer to "No Plot".
    ;;; Modified by Tod Winn on 01/26/01 to define an error function.
    ;;; Modified by Tod Winn on 02/12/03 to add current linetype and current color settings.
    ;;; Modified By Tod Winn on 03/15/05 to add an ORTHORAY version.
    ;;; Modified by Tod Winn on 05/09/2019 to remove ORTHORAY, rewrite error code, use of Command-S, and *PUSH-ERROR-USING-STACK*
    
    (DEFUN c:xlh () (orthoxline "hor"))
    (DEFUN c:xlv () (orthoxline "ver"))
    
    (DEFUN orthoxline (orientation / *error* |clayer| |cmdecho| |cecolor|
    		   |celtype|)
    
      (DEFUN *error* (msg)
        (COMMAND-S "celtype" |celtype|)
        (COMMAND-S "cecolor" |cecolor|)
        (SETVAR "clayer" |clayer|)
        (SETVAR "cmdecho" |cmdecho|)
        (COND ((NOT msg))			; Normal exit
    	  ((MEMBER msg '("Function cancelled" "quit / exit abort")))
    					; <esc> or (quit)
    	  ((PRINC (STRCAT "\n** Error: " msg " ** ")))
    					; Fatal error, display it
        )
        (PRINC)
      )
    
      (*PUSH-ERROR-USING-STACK*)
    
      (SETQ	|cmdecho| (GETVAR "cmdecho")
    	|celtype| (GETVAR "celtype")
    	|cecolor| (GETVAR "cecolor")
    	|clayer|  (GETVAR "clayer")
    
      )
      (SETVAR "cmdecho" 0)
      (COMMAND "celtype" "bylayer")		; setting to BYLAYER
      (COMMAND "cecolor" "256")		; setting to BYLAYER
      
      (IF (NOT (TBLSEARCH "layer" "G-ANNO-NPLT"))
        (COMMAND "_.-layer"	   "_make"	 "G-ANNO-NPLT" "_color"
    	     "133"	   "G-ANNO-NPLT" "plot"	       "no"
    	     "G-ANNO-NPLT" ""
    	    )
        (COMMAND "_.-layer"	   "_thaw"	 "G-ANNO-NPLT" "_on"
    	     "G-ANNO-NPLT" "plot"	 "no"	       "G-ANNO-NPLT"
    	     "_set"	   "G-ANNO-NPLT" ""
    	    )
      )
    
      (PRINC "\nPick Point(s): ")
      (COMMAND "_.xline" orientation)
      (WHILE (> (GETVAR "cmdactive") 0)
        (COMMAND pause)
      )
      
      (COMMAND-S "celtype" |celtype|)
      (COMMAND-S "cecolor" |cecolor|)
      (SETVAR "clayer" |clayer|)
      (SETVAR "cmdecho" |cmdecho|)
      (*error* nil)
      (*POP-ERROR-MODE*)
      (PRINC)
    )

  2. #2
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    0

    Default Re: OrthoXline V2.0

    An another way with no (command), if you want try!...
    Code:
    (defun orthoxline (orientation / key pt)
      (if (not (tblsearch "LAYER" "G-ANNO-NPLT"))
        (entmake
          '(
            (0 . "LAYER")
            (100 . "AcDbSymbolTableRecord")
            (100 . "AcDbLayerTableRecord")
            (2 . "G-ANNO-NPLT")
            (70 . 0)
            (62 . 133)
            (290 . 0)
            (370 . -3)
            (6 . "Continuous")
          )
        )
      )
      (princ "\nPick Point(s): ")
      (setq key '(0 (0.0 0.0 0.0)))
      (while (/= (car key) 25)
        (while (and (setq key (grread T 8 2)) (/= (car key) 3) (/= (car key) 25))
          (cond
            ((eq (car key) 5)
              (redraw)
              (grdraw (cadr key) (polar (cadr key) (angle (trans '(0.0 0.0 0.0) 0 1) (trans (cdr orientation) 0 1)) (* 10 (getvar "VIEWSIZE"))) 133)
              (grdraw (cadr key) (polar (cadr key) (angle (trans (cdr orientation) 0 1) (trans '(0.0 0.0 0.0) 0 1)) (* 10 (getvar "VIEWSIZE"))) 133)
            )
          )
        )
        (cond
          ((/= (car key) 25)
            (setq pt
              (osnap
                (cadr key) 
                (if (zerop (logand 16384 (getvar "OSMODE")))
                  (apply 'strcat
                    (vl-remove-if 'null
                      (mapcar
                        '(lambda ( a / )
                          (if (= (car a) (logand (car a) (getvar "osmode")))
                            (cdr a)
                          )
                        )
                       '(
                          (1 . "_end,")
                          (2 . "_mid,")
                          (4 . "_cen,")
                          (8 . "_nod,")
                          (16 . "_qua,")
                          (32 . "_int,")
                          (64 . "_ins,")
                          (128 . "_per,")
                          (256 . "_tan,")
                          (512 . "_nea,")
                          (1024 . "_gce,")
                          (2048 . "_app,")
                          (8192 . "_par,")
                        )
                      )
                    )
                  )
                  "_none"
                )
              )
            )
            (entmake
              (list
                '(0 . "XLINE")
                '(100 . "AcDbEntity")
                '(67 . 0)
                '(410 . "Model")
                '(8 . "G-ANNO-NPLT")
                '(100 . "AcDbXline")
                (cons 10 (if pt (trans pt 1 0) (trans (cadr key) 1 0)))
                orientation
              )
            )
          )
          (T (setq key '(25 (0.0 0.0 0.0))))
        )
        (redraw)
      )
      (prin1)
    )
    (defun C:xlh () (orthoxline (cons 11 (getvar "UCSXDIR"))))
    (defun C:xlv () (orthoxline (cons 11 (getvar "UCSYDIR"))))

  3. #3
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Too far from the beach
    Posts
    1,054
    Login to Give a bone
    0

    Default Re: OrthoXline V2.0

    Quote Originally Posted by Bruno.Valsecchi View Post
    An another way with no (command), if you want try!...
    You went old school on that one

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •