This function is written for versions of Autocad that understand special objects like Ducts, Slabs, Walls, Autocad Mass elements etc ( f.e Autocad MEP, Autocad Architecture..)
Command:ES
Makes section using 3 points (start, end, depth), selects all mep adn architectual objects in entire drawing. If the user wishes he may include layers fe. with 3d electrical or architecure plan to be automatically selected. In this particular example "_XREF_ARCH_3D" and "_XREF_ELE" .Command:ES2
Works simillarly as ES command but selects only objects enclosed in rectangle between start-ed-depth point Its recommended to use that command rather than ES when working on large drawings - works faster than ES but requires doubleclick at depth-point.Command:SE
Secion end (quits view session).
Code:
;;; ================================================ ;;; EDITINSECTION_v5.LSP ;;; ;;; Written by Andrzej Kalinowski, www.autolisps.blogspot.com ;;; v5.00- 24.04.2016 ;;; ;;; Command ES ;;; Makes section using 3 points (start, end, depth), selects all mep adn architectual objects in entire drawing. ;;; If the user wishes he may include layers fe. with 3d electrical or architecure plan to be automatically selected. ;;; In this particular example "_XREF_ARCH_3D" and "_XREF_ELE" ;;; ;;; Command: ES2 ;;; Works simillarly as ES command but selects only objects enclosed in rectangle between start-ed-depth point ;;; Its recommended to use that command rather than ES when working on large drawings - works faster than ES but requires doubleclick at depth-point. ;;; ;;; Command SE - secion end (quits view session) ;;; ======================================================= ;;; ES_EDITINSECTION ;;; ======================================================= (vl-load-com) (defun C:ES (/ sset1 sset2 sset3 pt1 pt2 i1) (setq pt1 (getpoint "\nSelect start point: ") pt2 (getpoint pt1 "\nSelect second point: ") );setq (command "_-layer" "_unlock" "_XREF_ARCH_3D,_XREF_ELE" "") (setq sset1 (ssget "_A" '((0 . "AECB_MVPART,AECB_PIPEFITTING,AECB_PIPE,AECB_DUCT,AECB_DUCTFITTING,AECB_PIPECUSTOMFITTING,AECB_DUCTCUSTOMFITTING,AEC_COLUMN_GRID,AEC_CEILING_GRID,AEC_CURTAIN_WALL_UNIT,AEC_CURTAIN_WALL_LAYOUT,AEC_ROOFSLAB,AEC_ROOF,AEC_SLAB,AEC_WALL,AEC_DOOR,AEC_OPENING,AEC_WINDOW_ASSEMBLY,AEC_WINDOW,AEC_STAIR,AEC_RAILING,AEC_SPACE,AECS_MEMBER,AEC_ZONE,AEC_MASS_ELEM,AECB_DEVICE,AECB_PANEL,AECB_CABLETRAYFITTING,AECB_CABLETRAY,AECB_CONDUIT,AECB_CONDUITFITTING,AECB_WIRE,AECB_CABLETRAY")))) (setq sset2 (ssget "_X" '((8 . "_XREF_ARCH_3D,_XREF_ELE")))); HERE YOU PUT LAYERS OF XREFS YOU WANT TO INCLUDE (cond ((= sset1 nil)(setq sset3 sset2)) ((= sset2 nil)(setq sset3 sset1)) );cond (if (and (/= sset1 nil) (/= sset2 nil)) (progn;then (setq sset3 sset1 i1 (sslength sset2) );setq (while (> i1 0) (setq i1 (1- i1)) ;(setq sset3 (ssadd (ssname sset2 i1) sset1));setq (ssadd (ssname sset2 i1) sset3) );while );progn );if (if (/= sset3 nil) (command "_editinsection" sset3 "" pt1 pt2 "");then ();else );end if (princ) );defun ;;; ======================================================= ;;; ES2_EDITINSECTION2 ;;; ======================================================= (vl-load-com) (defun C:ES2 (/ sset1a sset1b sset2 sset3 pt1 pt2 pt3 pt4 i1 MymodelSpace) ;----------------------------------------- ; sekcja bledu / error section ;----------------------------------------- (defun *error* (msg) (princ "error: ") (princ msg) (princ) );zresetowanie errora do fabycznej wartosci (defun errtrap1 (errormsg1) (entdel (vlax-vla-object->ename TmpLine1)) (entdel (vlax-vla-object->ename TmpLine2)) (setq *error* temperr); (if (and errormsg1 (not (wcmatch (strcase errormsg1) "*BREAK*,*CANCEL*,*QUIT*") ) ) (prompt (strcat "BLAD / Error: " errormsg1) );then );if (princ) );defun err ;----------------------------------------- (setq temperr *error*) (setq *error* errtrap1) ;----------------------------------------- (setq MymodelSpace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object) ) ) pt1 (getpoint "\nSelect start point: ") pt2 (getpoint pt1 "\nSelect second point: ") TmpLine1 (vla-addline MymodelSpace (vlax-3D-point pt1)(vlax-3D-point pt2)) );setq (command "_chprop" (entlast) "" "_color" 1 "") (setq pt3 (list (/ (+ (car pt1) (car pt2)) 2) (/ (+ (cadr pt1) (cadr pt2)) 2) (/ (+ (caddr pt1) (caddr pt2)) 2) );list pt4 (getpoint pt3 "\nSet depth of section: ") TmpLine2 (vla-addline MymodelSpace (vlax-3D-point pt3)(vlax-3D-point pt4)) );setq (command "_chprop" (entlast) "" "_color" 1 "") (command "_-layer" "_unlock" "_XREF_ARCH_3D,_XREF_ELE" "") ;(setq ss25 (ssget "_W" pt1 pt2 '((0 . "LINE,LWPOLYLINE,POLYLINE")(6 . "DN025")) )) (setq sset1a (ssget "_c" pt1 pt4 '((0 . "AECB_MVPART,AECB_DUCTFLEX,AECB_PIPEFITTING,AECB_PIPE,AECB_DUCT,AECB_DUCTFITTING,AECB_PIPECUSTOMFITTING,AECB_DUCTCUSTOMFITTING,AEC_COLUMN_GRID,AEC_CEILING_GRID,AEC_CURTAIN_WALL_UNIT,AEC_CURTAIN_WALL_LAYOUT,AEC_ROOFSLAB,AEC_ROOF,AEC_SLAB,AEC_WALL,AEC_DOOR,AEC_OPENING,AEC_WINDOW_ASSEMBLY,AEC_WINDOW,AEC_STAIR,AEC_RAILING,AEC_SPACE,AECS_MEMBER,AEC_ZONE,AEC_MASS_ELEM,AECB_DEVICE,AECB_PANEL,AECB_CABLETRAYFITTING,AECB_CABLETRAY,AECB_CONDUIT,AECB_CONDUITFITTING,AECB_WIRE")))) (setq sset1b (ssget "_c" pt4 pt2 '((0 . "AECB_MVPART,AECB_DUCTFLEX,AECB_PIPEFITTING,AECB_PIPE,AECB_DUCT,AECB_DUCTFITTING,AECB_PIPECUSTOMFITTING,AECB_DUCTCUSTOMFITTING,AEC_COLUMN_GRID,AEC_CEILING_GRID,AEC_CURTAIN_WALL_UNIT,AEC_CURTAIN_WALL_LAYOUT,AEC_ROOFSLAB,AEC_ROOF,AEC_SLAB,AEC_WALL,AEC_DOOR,AEC_OPENING,AEC_WINDOW_ASSEMBLY,AEC_WINDOW,AEC_STAIR,AEC_RAILING,AEC_SPACE,AECS_MEMBER,AEC_ZONE,AEC_MASS_ELEM,AECB_DEVICE,AECB_PANEL,AECB_CABLETRAYFITTING,AECB_CABLETRAY,AECB_CONDUIT,AECB_CONDUITFITTING,AECB_WIRE")))) (setq sset2 (ssget "_X" '((8 . "_XREF_ARCH_3D,_XREF_ELE")))); HERE YOU PUT LAYERS OF XREFS YOU WANT TO INCLUDE (setq sset3 nil) (if (= sset1a nil) (princ "\nsset1a=nil") (princ "\nsset1a /= nil")) (if (= sset1b nil) (princ "\nsset1b=nil") (princ "\nsset1b /= nil")) (if (= sset2 nil) (princ "\nsset2=nil") (princ "\nsset2 /= nil")) (cond ( (and (= sset1a nil) (= sset1b nil) (/= sset2 nil)) (setq sset3 sset2) ) ( (and (= sset1a nil) (/= sset1b nil) (= sset2 nil)) (setq sset3 sset1b) ) ( (and (/= sset1a nil) (= sset1b nil) (= sset2 nil)) (setq sset3 sset1a) ) ( (and (= sset1a nil) (= sset1b nil) (= sset2 nil)) (exit) ) ( (and (= sset1a nil) (/= sset1b nil) (/= sset2 nil)) (progn (setq sset3 sset1b) (setq i1 (sslength sset2));setq (while (> i1 0) (setq i1 (1- i1)) (ssadd (ssname sset2 i1) sset3) );while );progn ) ( (and (/= sset1a nil) (= sset1b nil) (/= sset2 nil)) (progn (setq sset3 sset1a) (setq i1 (sslength sset2));setq (while (> i1 0) (setq i1 (1- i1)) (ssadd (ssname sset2 i1) sset3) );while );progn ) ( (and (/= sset1a nil) (/= sset1b nil) (= sset2 nil)) (progn (setq sset3 sset1a) (setq i1 (sslength sset1b));setq (while (> i1 0) (setq i1 (1- i1)) (ssadd (ssname sset1b i1) sset3) );while );progn ) ( (and (/= sset1a nil) (/= sset1b nil) (/= sset2 nil)) (progn (setq sset3 sset1a) (setq i1 (sslength sset1b));setq (while (> i1 0) (setq i1 (1- i1)) (ssadd (ssname sset1b i1) sset3) );while (setq i1 (sslength sset2));setq (while (> i1 0) (setq i1 (1- i1)) (ssadd (ssname sset2 i1) sset3) );while );progn ) );cond (command "_editinsection" sset3 "" pt1 pt2 "" pause);then (setq *error* temperr) (entdel (vlax-vla-object->ename TmpLine1)) (entdel (vlax-vla-object->ename TmpLine2)) (princ) );defun ;;; ======================================================= ;;; SECTIONEND ;;; ======================================================= (defun C:SE (/ sset1 pt1 pt2) ;(command "_layerp" ) (command "_AecExitEditInView") ;(command "_-layer" "_Thaw" "_XREF_ARCH,_XREF_V,_XREF_KLAPY_PPOZ,_XREF_HC,_XREF_S,_XREF_RAUMSTEMPEL" "") (command "_regenall") ;(COMMAND "_LAYER" "LOCK" "_XREF_ARCH_3D" "") ;(COMMAND "_LAYER" "LOCK" "_XREF_ELE" "") (princ) );defun
Example:
Download file: EDITINSECTION_v5.LSP
No comments:
Post a Comment