1
初来乍到
使用道具 举报
91
389
12
中流砥柱
;;; HATCHB.LSP ver 2.0 ;;; Recreates hatch boundary by selecting a hatch ;;; Boundary is created in current layer/color/linetype in WCS ;;; By Jimmy Bergmark ;;; Copyright (C) 1997-2003 JTB World, All Rights Reserved ;;; Website: [url]www.jtbworld.com[/url] ;;; E-mail: [email]info@jtbworld.com[/email] ;;; 2000-02-12 - First release ;;; 2000-03-27 - Counterclockwise arc's and ellipse's fixed ;;; Objects created joined to lwpolyline if possible ;;; Error-handling, undo of command ;;; Can handle PLINETYPE = 0,1,2 ;;; 2000-03-30 - Integrating hatchb and hatchb14 ;;; Selection of many hatches ;;; Splines supported if closed. ;;; 2001-04-02 - Fixed bug with entmake of line with no Z for r14 ;;; 2001-07-31 - Removed an irritating semicolon to enable polylines to be created. ;;; 2001-10-04 - Changed mail and homepage so it's easy to find when new versions comes up. ;;; 2003-02-06 - Minor fix ;;; 2003-02-17 - Area returned if no islands is found since it's not consistant ;;; 2003-05-19 - Fix to take PEDITACCEPT variable used in AutoCAD 2004 into account ;;; Tested on AutoCAD r14, 2000, 2000i, 2002, 2004 ;;; should be working on older versions too. (defun c:rebuild_hatch_border () (c:hb)) ; this line can be commented out if there is an existing command called hb (defun c:hb (/ es blay ed1 ed2 loops1 bptf part et noe plist ic bul nr ang1 ang2 obj *ModelSpace* *PaperSpace* space cw errexit undox olderr oldcmdecho ss1 lastent en1 en2 ss lwp list->variantArray 3dPoint->2dPoint A2k ent i ss2 knot-list controlpoint-list kn cn pos xv bot area hst ) (setq A2k (>= (substr (getvar "ACADVER") 1 2) "15")) (if A2k (progn (defun list->variantArray (ptsList / arraySpace sArray) (setq arraySpace (vlax-make-safearray vlax-vbdouble (cons 0 (- (length ptsList) 1)) ) ) (setq sArray (vlax-safearray-fill arraySpace ptsList)) (vlax-make-variant sArray) ) (defun areaOfObject (en / curve area) (if en (if A2k (progn (setq curve (vlax-ename->vla-object en)) (if (vl-catch-all-error-p (setq area (vl-catch-all-apply 'vlax-curve-getArea (list curve)) ) ) nil area ) ) (progn (command "._area" "_O" en) (getvar "area") ) ) ) ) ) ) (if A2k (defun 3dPoint->2dPoint (3dpt) (list (float (car 3dpt)) (float (cadr 3dpt))) ) ) (defun errexit (s) (princ "\nError: ") (princ s) (restore) ) (defun undox () (command "._ucs" "_p") (command "._undo" "_E") (setvar "cmdecho" oldcmdecho) (setq *error* olderr) (princ) ) (setq olderr *error* restore undox *error* errexit ) (setq oldcmdecho (getvar "cmdecho")) (setvar "cmdecho" 0) (command "._UNDO" "_BE") (if A2k (progn (vl-load-com) (setq *ModelSpace* (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)) ) *PaperSpace* (vla-get-PaperSpace (vla-get-ActiveDocument (vlax-get-acad-object)) ) )) ) ; For testing purpose ; (setq A2k nil) (if (/= (setq ss2 (ssget '((0 . "HATCH")))) nil) (progn (setq i 0) (setq area 0) (setq bMoreLoops nil) (while (setq ent (ssname ss2 i)) (setq ed1 (entget ent)) (if (not (equal (assoc 210 ed1) '(210 0.0 0.0 1.0))) (princ "\nHatch not in WCS!")) (setq xv (cdr (assoc 210 ed1))) (command "._ucs" "_w") (setq loops1 (cdr (assoc 91 ed1))) ; number of boundary paths (loops) (if (and A2k (= (strcase (cdr (assoc 410 ed1))) "MODEL"))