1
5
4
初来乍到
(textscr)(princ(strcat "\n\n=========================WEED.LSP===========================" "\n\nWEED removes extranious verticies from LINEs or a POLYLINE." "\nShort segments less than the specified leg length ...AND..." "\nhaving an offset distance less than the minimum distance" "\nare removed. Try different combinations to get the result" "\ndesired. Changes can be undone by entering the U command" "\ntwice. The routine will convert LINEs to a POLYLINE providing" "\nthat all line segments endpoints match exactly. Additional" "\nverticies that have been added by a Spline or Fit curve can" "\nbe treated like "real" verticies, or can be ignored." "\n\nExample: " "\nEnter offset distance: 10 <Enter number or pick 2 pts>" "\nEnter leg length: 100 <Enter number or pick 2 pts>" "\n\nAll included verticies having the longest leg less than 100" "\nAND being less than 10 from the original line will be removed." "\nIf you wish offset to control select a large leg length." "\nIf you wish leg length to control select a large offset." "\nJerry Workman CIS 70717,3564" "\nLoading..."));*----- Debugging stuff, load this file by entering LD<RETURN>;(defun c:ld() (load "weed"));(defun c:ed() (command "q" "d:\\acad\\support\\weed.lsp"));*----- Error Routine(defun w-error (s) (redraw) (grtext) (princ "\nWeed Error: ") (princ s) (exit));*----- Exit Routine(defun exit() (if (boundp 'f) (setq f (close f))) (setvar "cmdecho" cmdecho) (setvar "blipmode" blipmode) (setq *error* olderr) (princ));*----- Extract a field from a list(defun fld (num lst) (cdr (assoc num lst)));*----- Plot a temporary X(defun blip (blpoint / s x1 y1 x2 y2 p1 p2 p3 p4) (setq s (/ (getvar "viewsize") 100) ; 1/100 of viewsize x1 (+ (car blpoint) s) y1 (- (cadr blpoint) s) x2 (- (car blpoint) s) y2 (+ (cadr blpoint) s) p1 (list x1 y1) p2 (list x2 y2) p3 (list x2 y1) p4 (list x1 y2)) (grdraw p1 p2 -1) (grdraw p3 p4 -1));*----- Convert a line to a polyline entity(defun line2pline(ent / dat etype epnt ss1 ss2) (if ent (progn (setq dat (entget ent) etype (fld 0 dat)) (if (= etype "LINE") (progn (princ "\nConverting LINE to PLINE") (setq epnt (fld 10 dat) ss1 (ssadd ent) ss2 (ssget "C" (getvar "EXTMIN") (getvar "EXTMAX"))) (ssdel ent ss2) (command "pedit" ss1 "y" "j" ss2 "" "x") (ssname (ssget epnt) 0) ; return the new entity name ) ;else return nil (progn (princ "\nNot a Line") nil) ) );else (progn (princ "\nNothing selected") nil) ));*----- Get a polyline or line entity(defun fetch(/ pl etyp flgs ans) (setq etyp nil) (while (not (or (= etyp "LINE") (= etyp "POLYLINE"))) (progn (setq ename nil) (setq e (car (entsel "\nSelect a PolyLine or Line: "))) (if e (progn (setq pl (entget e) etyp (fld 0 pl) ename e) (if (or (= etyp "LINE") (= etyp "POLYLINE")) (progn (princ (strcat "\n" etyp " selected")) (if (= etyp "LINE") (setq e (line2pline e) ename e pl (entget e)) )) ;else (progn (princ "\nThat's not a LINE or POLYLINE, it's a ") (princ etyp)) ); end if ); end progn ; else (princ "\nNothing Selected") ); end if )); end while (setq flgs (fld 70 pl)) (setq closed (=(boole 1 flgs 1) 1))