本帖最后由 greg.battin 于 2018-2-14 04:40 编辑
here is one that lets you define a line that points are to be projected upon.
- ;project lines - GREAT FOR CREATING ELEVATIONS
- (defun pt? (pt)
- (and (vl-consp pt)
- (= (length pt) 3)
- (vl-every (function (lambda (coord) (= (type coord) 'real)))
- pt)))
- (defun C:PROJECT (/ osm cmd orth p1 p2 p3 p4 Lb sslp lth cont cont1)
- (setq osm (getvar "OSMODE")
- cmd (getvar "CMDECHO")
- orth (getvar "ORTHOMODE")
- sslp (ssadd))
- (setvar "CMDECHO" 0)
- (setvar "ORTHOMODE" 1)
- (setvar "OSMODE" 0)
- (if (and (setq p1 (getpoint "\nFirst point: "))
- (setq p2 (getpoint "\nSecond point: " p1)))
- (progn
- (command "_.LINE" p1 p2 "")
- (setq L (entlast))
- (redraw (entlast) 3)
- (setvar "OSMODE" 33)
- (initget "Erase")
- (setq p3 (getpoint "\n<Enter to exit>/Select point [Erase]: "))
- (if (pt? p3)
- (progn
- (setvar "OSMODE" 0)
- (setq p4 (polar p3 (+ (angle p1 p2) (/ pi 2)) 1))
- (command "_.LINE" p3 (inters p1 p2 p3 p4 nil) "")
- (redraw (entlast) 3)
- (setq sslp (ssadd (entlast) sslp))
- (setvar "OSMODE" 33)))
- (while (or (pt? p3) (= p3 "Erase"))
- (initget "Erase")
- (setq p3
- (getpoint "\n<Enter to exit>/Select point [Erase]: "))
- (if (pt? p3)
- (progn
- (setvar "OSMODE" 0)
- (setq p4 (polar p3 (+ (angle p1 p2) (/ pi 2)) 1))
- (command "_.LINE" p3 (inters p1 p2 p3 p4 nil) "")
- (redraw (entlast) 3)
- (setq sslp (ssadd (entlast) sslp))
- (setvar "OSMODE" 33)))
- (if (and (= p3 "Erase") (ssname sslp 0))
- (progn
- (prompt "\nSelect projection line(s)")
- (setq cont1 0
- lb (ssget))
- (setq cont 0
- lth (sslength lb))
- (while (<= cont (- lth 1))
- (if (ssmemb (ssname Lb cont) sslp)
- (progn
- (ssdel (ssname Lb cont) sslp)
- (command "_.ERASE" (ssname Lb cont) "") (setq account (1+ cont)))
- (setq cont1 (1+ cont1)))))
- (prompt (strcat (itoa lth)
- " Selected object(s)), "
- (itoa cont1)
- " Projection line(s) erased"))))
- (if (and (= p3 "Erase") (null (ssname sslp 0)))
- (prompt "\nProjection line(s) not found to erase")))
- (setvar "OSMODE" osm)
- (setvar "ORTHOMODE" orth)
- (if (ssname sslp 0)
- nil
- (command "_.ERASE" L ""))))
- (setvar "CMDECHO" cmd)
- (princ))
- (princ)
|