exchange format

30
pmk (DEFUN C:2() (COMMAND "DIMLINEAR" PAUSE PAUSE) ) _________________________________________________________________________________________ ____________________________________________________________ (DEFUN C:3() (COMMAND "DIMCONTINUE" PAUSE) ) _________________________________________________________________________________________ ___________________________________________________________ (DEFUN C:4() (COMMAND "QLEADER" PAUSE PAUSE "" "" "" "" ) ) _________________________________________________________________________________________ ___________________________________________________________ (DEFUN C:5() (COMMAND "aidimtextmove" 1 pause) ) _________________________________________________________________________________________ ___________________________________________________________ (DEFUN C:SHO() (SETQ SO(SSGET) SO1(SSGET) ) (COMMAND "COPY" SO "" 12 16 "")(SETQ OBJ1 ENTLAST) (COMMAND "hatchsetboundary" "L" SO1 "" "N") ;(COMMAND "ERASE" OBJ1 "") ) _________________________________________________________________________________________ ____________________________________________________________ (DEFUN C:DF() (SETQ P1(GETPOINT "\n PICK FIRST POINT :") P2(GETPOINT P1 "\n PICK SECOND POINT :") Page 1

Upload: muthu-kumar

Post on 25-Dec-2015

235 views

Category:

Documents


1 download

DESCRIPTION

bfffg

TRANSCRIPT

Page 1: Exchange format

pmk(DEFUN C:2()

(COMMAND "DIMLINEAR" PAUSE PAUSE)

)

_____________________________________________________________________________________________________________________________________________________

(DEFUN C:3()

(COMMAND "DIMCONTINUE" PAUSE)

)

____________________________________________________________________________________________________________________________________________________

(DEFUN C:4()

(COMMAND "QLEADER" PAUSE PAUSE "" "" "" "" )

)

____________________________________________________________________________________________________________________________________________________

(DEFUN C:5()

(COMMAND "aidimtextmove" 1 pause)

)

____________________________________________________________________________________________________________________________________________________(DEFUN C:SHO()

(SETQ

SO(SSGET) SO1(SSGET) )

(COMMAND "COPY" SO "" 12 16 "")(SETQ OBJ1 ENTLAST) (COMMAND "hatchsetboundary" "L" SO1 "" "N") ;(COMMAND "ERASE" OBJ1 "") )

_____________________________________________________________________________________________________________________________________________________

(DEFUN C:DF()

(SETQ

P1(GETPOINT "\n PICK FIRST POINT :")

P2(GETPOINT P1 "\n PICK SECOND POINT :")

Page 1

Page 2: Exchange format

pmk

DI(DISTANCE P1 P2 )

; fi(fix di)

CV(CVUNIT DI "MILLIMETER" "FOOT")

TE(/ DI 10)

)(ALERT (strcat (rtos DI ) " MM = " (RTOS TE ) " CM = "(RTOS (* 12 CV) 3 1)))

(PRINT TE)

)

__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________(DEFUN C:CC() (SETQ

CNU(GETINT "\n ENTER COLOR NUMBER:") CCL(GETINT "\n ENTER CHANGE COLOR NUMER :") HO(SSGET (LIST(CONS 62 CNU))) ) (COMMAND "CHANGE" HO "" "P" "CO" CCL "") )_________________________________________________________________________________________________________________________________(DEFUN C:HD() (SETQ DO(SSGET "X" (LIST(CONS 0 "dimension"))) ) (command "hideobjects" DO "") (ALERT "ALL DIMENSION ARE HIDDEN") (VL−VBALOAD "D:/pro/HIDEOBJ.DVB") (VL−VBARUN "HIDEOBJ") )_________________________________________________________________________________________________________________________________(DEFUN C:HT() (command "−layer" "n" "TEXT" "co" 61 "TEXT" "") (SETQ TO(SSGET "X" (LIST(CONS 0 "TEXT"))) MO(SSGET "X" (LIST(CONS 0 "MTEXT"))) ) (command "hideobjects" TO MO "") (ALERT "ALL TEXT ARE HIDDEN")

Page 2

Page 3: Exchange format

pmk )__________________________________________________________________________________________________________________________________

(DEFUN C:HB() (SETQ bO(SSGET "X" (LIST(CONS 0 "INSERT"))) ) (command "hideobjects" bO "") (ALERT "ALL BLOCK ARE HIDDEN") )

____________________________________________________________________________________________________

(DEFUN C:HH() (command "−layer" "n" "DIMENSION" "co" "RED" "DIMENSION" "")

(SETQ

DO(SSGET "X" (LIST(CONS 0 "HATCH"))) ) (command "hideobjects" DO "") (ALERT "ALL HATCH ARE HIDDEN") )_________________________________________________________________(defun c:SD()

(setq a1 (ssget ’((0 . "DIMENSION"))))

(command "stretch" a1 pause)

)

___________________________________________________________________________________________________________________________________________________________________________________

(defun c:MD() (setq a1 (ssget ’((0 . "DIMENSION"))))(command "MOVE" a1 pause)

)

___________________________________________________________________________________________________________________________________________________________________________________

Page 3

Page 4: Exchange format

pmk(DEFUN C:AS()

(setq

obj(entsel)

)

(COMMAND "−HATCHEDIT" obj "B" "" "" )

(REPEAT 1500

(PRINT "B.MUTHUKUMAR")(TERPRI)

)

(ALERT "THE SELECTED HATCH ARE STRETCHABLE")

)_______________________________________________________________________________________________________________________________________________________

(defun c:bl()

(setq

st(getstring "\n enter block name:")

po(getpoint "\n pick a insertion point:")

ob(entsel "\n select object:")

obj1(entlast)

xv(getdist "\n pick x direction:")

yv(getdist "\n pick y direction:")

fx(/ 1 xv)

fy(/ 1 yv)

)

(command "−block" st po obj1 "")

(print fx)

(print fy)

(command "−insert" st po fx fy "")

(COMMAND "ZOOM" "E")

)

Page 4

Page 5: Exchange format

pmk_________________________________________________________________________________________________________________________________________________

;;−−−−−−−−−−−−−−−−−−−−−=={ Automatic Block Break }==−−−−−−−−−−−−−−−−−−−−;;;; ;;;; This program enables the user to insert a block at a specified ;;;; point, with surrounding geometry trimmed to the rectangular outline ;;;; of the block. Optionally, the program will automatically rotate ;;;; the block to align with a curve object passing through the block ;;;; insertion point. ;;;; ;;;; The program first prompts the user to select a block to insert. At ;;;; this prompt the user may select a block from the drawing, or type ;;;; ’Browse’ to browse for a drawing file to insert. The user may also ;;;; alter the program rotation setting by typing ’Rotation’ at the ;;;; prompt. ;;;; ;;;; Following a valid response, the program prompts the user to specify ;;;; an insertion point for the block. ;;;; ;;;; If a curve object (Arc, Elliptical Arc, Ellipse, Circle, Line, ;;;; XLine, Spline, LWPolyline or Polyline) is detected at the block ;;;; insertion point and the program rotation setting is enabled, the ;;;; inserted block is automatically rotated to align with the curve. ;;;; ;;;; All surrounding compatible objects found to intersect with the ;;;; inserted block are then trimmed to the rectangular block outline. ;;;; ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Author: Lee Mac, Copyright © 2010 − www.lee−mac.com ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Version 1.0 − 22−11−2010 ;;;; ;;;; First Release. ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Version 1.1 − 07−02−2011 ;;;; ;;;; Entire program rewritten to allow subfunction to be called with ;;;; block object argument. ;;;; ;;;; Multiple intersecting objects are now trimmed. ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Version 1.2 − 08−02−2011 ;;;; ;;;; Changed block insertion to Visual LISP InsertBlock method. ;;;; ;;;; Added calling functions to trim blocks in−situ (ABBE / ABBS). ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Version 1.3 − 03−08−2011 ;;;; ;;;; Altered method used to create bounding polyline to exclude ;;;; attributes when trimming objects surrounding block. ;;;; ;;;; Objects surrounding blocks whose insertion point does not lie on a ;;;; curve are now also trimmed. ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Version 1.4 − 30−09−2011 ;;;; ;;

Page 5

Page 6: Exchange format

pmk;; Added option to enable/disable automatic block rotation. ;;;; ;;;; Updated code formatting. ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Version 1.5 − 04−03−2013 ;;;; ;;;; Fixed bug causing program to attempt to break MLines. ;;;; ;;;; Added new LM:blockboundingbox function to correctly calculate the ;;;; bounding box of Dynamic Block references. ;;;; ;;;; Entire program rewritten. ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Version 1.6 − 01−10−2013 ;;;; ;;;; Fixed a bug causing the program to return an error if an object ;;;; intersects the block bounding box at only one point. ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;

(defun c:abb ( / *error* blk obj ins sel )

(defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) )

(cond ( (= 4 (logand 4 (cdr (assoc 70 (tblsearch "layer" (getvar ’clayer)))))) (princ "\nCurrent layer locked.") ) ( (progn (while (progn (setvar ’errno 0) (initget "Browse Rotation") (princ (strcat "\nAutomatic Block Rotation: " (getenv "LMac\\ABBRotation"))) (setq sel (entsel (strcat "\nSelect Block [Browse/Rotation]" (if (= "" (setq blk (getvar ’insname))) ": " (strcat " <" blk "> : ") ) ) ) ) (cond ( (= 7 (getvar ’errno)) (princ "\nMissed, Try Again.") ) ( (null sel) (if (= "" blk) (setq blk nil) ) ) ( (= "Rotation" sel) (initget "ON OFF")

Page 6

Page 7: Exchange format

pmk (setenv "LMac\\ABBRotation" (cond ( (getkword (strcat "\nAutomatic Block Rotation [ON/OFF] <" (getenv "LMac\\ABBRotation") ">: " ) ) ) ( (getenv "LMac\\ABBRotation") ) ) ) ) ( (= "Browse" sel) (setq blk (getfiled "Select Block" "" "dwg" 16)) nil ) ( (listp sel) (if (/= "INSERT" (cdr (assoc 0 (entget (car sel))))) (princ "\nObject must be a block.") (setq obj (vla−copy (vlax−ename−>vla−object (car sel))) blk nil ) ) ) ) ) ) (not (or blk obj)) ) ) ( (setq ins (getpoint "\nSpecify Point for Block: ")) (LM:startundo (LM:acdoc)) (if (null obj) (setq obj (vla−insertblock (vlax−get−property (LM:acdoc) (if (= 1 (getvar ’cvport)) ’paperspace ’modelspace)) (vlax−3D−point (trans ins 1 0)) blk 1.0 1.0 1.0 (angle ’(0.0 0.0 0.0) (trans (getvar ’ucsxdir) 0 (trans ’(0.0 0.0 1.0) 1 0 t) t)) ) ) ) (if blk (setvar ’insname (vl−filename−base blk))) (vla−put−insertionpoint obj (vlax−3D−point (trans ins 1 0))) (LM:AutoBlockBreak (vlax−vla−object−>ename obj) (= "ON" (getenv "LMac\\ABBRotation"))) (LM:endundo (LM:acdoc)) ) ) (princ))

;;−−−−−−−−−−−−−−−−=={ Automatic Block Break Existing }==−−−−−−−−−−−−−−−−;;;; ;;;; This program enables the user to select an existing block and trim ;;;; all surrounding geometry to the rectangular outline of the block. ;;;; Optionally, the program will automatically rotate the selected ;;;; block to align with a curve object passing through the block ;;

Page 7

Page 8: Exchange format

pmk;; insertion point. ;;;; ;;;; At the block selection prompt, the user may also alter the program ;;;; rotation setting by typing ’Rotation’ when prompted. ;;;; ;;;; If a curve object (Arc, Elliptical Arc, Ellipse, Circle, Line, ;;;; XLine, Spline, LWPolyline or Polyline) is detected at the block ;;;; insertion point of the selected block and the program rotation ;;;; setting is enabled, the block is automatically rotated to align ;;;; with the curve. ;;;; ;;;; All surrounding compatible objects found to intersect with the ;;;; selected block are then trimmed to the rectangular block outline. ;;;; ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Author: Lee Mac, Copyright © 2010 − www.lee−mac.com ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;

(defun c:abbe ( / *error* enx sel )

(defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) ) (while (progn (setvar ’errno 0) (initget "Rotation") (princ (strcat "\nAutomatic Block Rotation: " (getenv "LMac\\ABBRotation"))) (setq sel (entsel "\nSelect Block to Trim [Rotation]: ")) (cond ( (= 7 (getvar ’errno)) (princ "\nMissed, Try Again.") ) ( (= "Rotation" sel) (initget "ON OFF") (setenv "LMac\\ABBRotation" (cond ( (getkword (strcat "\nAutomatic Block Rotation [ON/OFF] <" (getenv "LMac\\ABBRotation") ">: " ) ) ) ( (getenv "LMac\\ABBRotation") ) ) ) ) ( (= ’ename (type (car sel))) (cond ( (/= "INSERT" (cdr (assoc 0 (setq enx (entget (car sel)))))) (princ "\nObject must be a block.") ) ( (= 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (cdr (assoc 8 enx))))))) (princ "\nSelected block is on a locked layer.") )

Page 8

Page 9: Exchange format

pmk ( t (LM:startundo (LM:acdoc)) (LM:AutoBlockBreak (car sel) (= "ON" (getenv "LMac\\ABBRotation"))) (LM:endundo (LM:acdoc)) ) ) t ) ) ) ) (princ))

;;−−−−−−−−−−−−−−−=={ Automatic Block Break Selection }==−−−−−−−−−−−−−−−−;;;; ;;;; This program enables the user to select multiple existing blocks ;;;; and automatically trim all surrounding geometry to the rectangular ;;;; outline of each block. Optionally, the program will automatically ;;;; rotate each block in the selection to align with curve objects ;;;; detected to pass through the block insertion point. ;;;; ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Author: Lee Mac, Copyright © 2010 − www.lee−mac.com ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;

(defun c:abbs ( / *error* inc rot sel )

(defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) ) (setq rot (= "ON" (getenv "LMac\\ABBRotation"))) (if (setq sel (ssget "_:L" ’((0 . "INSERT")))) (progn (LM:startundo (LM:acdoc)) (repeat (setq inc (sslength sel)) (LM:AutoBlockBreak (ssname sel (setq inc (1− inc))) rot) ) (LM:endundo (LM:acdoc)) ) ) (princ))

;;−−−−−−−−−−−−−−−=={ Automatic Block Break SubFunction }==−−−−−−−−−−−−−−;;;; ;;;; Upon calling the function with a VLA Block Reference Object ;;;; argument, the function will trim all surrounding compatible ;;;; geometry found to intersect with the rectangular outline of the ;;;; supplied block reference. ;;;; ;;;; Furthermore, if a curve object is detected to pass through (or in ;;;; the vicinity of) the block insertion point and the rotation flag ;;;; argument holds a non−nil value, the supplied block reference is ;;;; rotated to align with the curve. ;;

Page 9

Page 10: Exchange format

pmk;; ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Author: Lee Mac, Copyright © 2010 − www.lee−mac.com ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Arguments: ;;;; ent − Block Reference Entity ;;;; rot − Rotation flag (if T, block is aligned to curve) ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;

(defun LM:AutoBlockBreak

( ent rot / *error* _getfurthestapart ang bbx brk cmd crv enx inc ins int lst ply sel )

(defun *error* ( msg ) (if (and (= ’vla−object (type ply)) (null (vlax−erased−p ply)) (vlax−write−enabled−p ply) ) (vla−delete ply) ) (if (= ’int (type cmd)) (setvar ’cmdecho cmd) ) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) )

(defun _getfurthestapart ( lst / dis mxd out pt1 pt2 ) (setq mxd 0.0) (while (setq pt1 (car lst)) (foreach pt2 (setq lst (cdr lst)) (if (< mxd (setq dis (distance pt1 pt2))) (setq mxd dis out (list pt1 pt2) ) ) ) ) out ) (if (and (= ’ename (type ent)) (setq enx (entget ent)) (= "INSERT" (cdr (assoc 0 enx))) ) (progn (if (and rot (setq ins (cdr (assoc 10 enx))) (setq crv (ssget "_C" (mapcar ’+ (trans ins ent 1) ’(1e−4 1e−4)) (mapcar ’− (trans ins ent 1) ’(1e−4 1e−4)) ’((0 . "ARC,ELLIPSE,CIRCLE,LINE,XLINE,SPLINE,*POLYLINE"))

Page 10

Page 11: Exchange format

pmk ) ) ) (progn (setq crv (ssname crv 0)) (setq ang (angle ’(0.0 0.0 0.0) (trans (vlax−curve−getfirstderiv crv (vlax−curve−getparamatpoint crv (vlax−curve−getclosestpointto crv (trans ins ent 0)) ) ) 0 (cdr (assoc 210 (entget crv))) ) ) ) (if (and (< (/ pi 2.0) ang) (<= ang (/ (* 3.0 pi) 2.0))) (setq ang (+ ang pi)) ) (vla−put−rotation (vlax−ename−>vla−object ent) ang) ;; VL used to account for attributes ) ) (if (and (setq bbx (LM:blockboundingbox (vlax−ename−>vla−object ent))) (setq sel (ssget "_C" (trans (car bbx) 0 1) (trans (caddr bbx) 0 1) ’((0 . "ARC,ELLIPSE,CIRCLE,LINE,XLINE,SPLINE,*POLYLINE")) ) ) ) (progn (setq ply (vlax−ename−>vla−object (entmakex (append (list ’(000 . "LWPOLYLINE") ’(100 . "AcDbEntity") ’(100 . "AcDbPolyline") ’(090 . 4) ’(070 . 1) (cons 38 (cadddr (assoc 10 enx))) ) (mapcar ’(lambda ( p ) (mapcar ’+ (cons 10 (trans p 0 ent)) ’(0 0 0))) bbx) (list (assoc 210 enx)) ) ) ) ) (repeat (setq inc (sslength sel)) (setq ent (ssname sel (setq inc (1− inc)))) (if (setq int (LM:Intersections (vlax−ename−>vla−object ent) ply acextendthisentity)) (setq lst (cons (cons ent int) lst)) ) ) (vla−delete ply)

Page 11

Page 12: Exchange format

pmk (setq cmd (getvar ’cmdecho)) (setvar ’cmdecho 0) (foreach int lst (if (setq brk (_getfurthestapart (cdr int))) (command "_.break" (list (car int) (trans (car brk) 0 1)) "_F" "_non" (trans (car brk) 0 1) "_non" (trans (cadr brk) 0 1) ) ) ) (setvar ’cmdecho cmd) ) ) ) ) (princ))

;; Intersections − Lee Mac;; Returns a list of all points of intersection between two objects.;; obj1,obj2 − [vla] VLA−Objects with intersectwith method applicable;; mode − [int] acextendoption enum of intersectwith method;; Returns: [lst] List of 3D WCS intersection points, else nil

(defun LM:Intersections ( obj1 obj2 mode / l r ) (setq l (vlax−invoke obj1 ’intersectwith obj2 mode)) (repeat (/ (length l) 3) (setq r (cons (list (car l) (cadr l) (caddr l)) r) l (cdddr l) ) ) (reverse r))

;;−−−−−−−−−−−−−−−−−−−=={ Block BoundingBox }==−−−−−−−−−−−−−−−−;;;; ;;;; Returns a point list describing a rectangular frame ;;;; bounding all geometry of a supplied block reference. ;;;; Excludes Text, MText & Attribute Definitions. ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Author: Lee Mac, Copyright © 2013 − www.lee−mac.com ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Arguments: ;;;; blk − VLA Block Reference Object ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Returns: WCS Point list describing boundingbox of block ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;

(defun LM:blockboundingbox ( blk / bnm llp lst urp ) (setq bnm (strcase (vla−get−name blk))) (cond ( (setq lst (cdr (assoc bnm *blockboundingboxes*)))) ( (progn (vlax−for obj (vla−item (LM:acblk) bnm) (cond ( (= "AcDbBlockReference" (vla−get−objectname obj)) (setq lst (append lst (LM:blockboundingbox obj))) ) ( (and

Page 12

Page 13: Exchange format

pmk (= :vlax−true (vla−get−visible obj)) (not (wcmatch (vla−get−objectname obj) "AcDbAttributeDefinition,AcDb*Text")) (vlax−method−applicable−p obj ’getboundingbox) (not (vl−catch−all−error−p (vl−catch−all−apply ’vla−getboundingbox (list obj ’llp ’urp)))) ) (setq lst (vl−list* (vlax−safearray−>list llp) (vlax−safearray−>list urp) lst)) ) ) ) (setq lst (mapcar ’(lambda ( fun ) (apply ’mapcar (cons fun lst))) ’(min max))) (setq lst (list (car lst) (list (caadr lst) (cadar lst)) (cadr lst) (list (caar lst) (cadadr lst)) ) ) (setq *blockboundingboxes* (cons (cons bnm lst) *blockboundingboxes*)) ) ) ) (apply (function (lambda ( m v ) (mapcar (function (lambda ( p ) (mapcar ’+ (mxv m p) v))) lst) ) ) (refgeom (vlax−vla−object−>ename blk)) ))

;; RefGeom (gile);; Returns a list which first item is a 3x3 transformation matrix (rotation,;; scales, normal) and second item the object insertion point in its parent;; (xref, block or space);;;; Argument : an ename

(defun refgeom ( ent / ang ang mat ocs ) (setq enx (entget ent) ang (cdr (assoc 050 enx)) ocs (cdr (assoc 210 enx)) ) (list (setq mat (mxm (mapcar ’(lambda ( v ) (trans v 0 ocs t)) ’( (1.0 0.0 0.0) (0.0 1.0 0.0) (0.0 0.0 1.0) ) ) (mxm (list (list (cos ang) (− (sin ang)) 0.0) (list (sin ang) (cos ang) 0.0) ’(0.0 0.0 1.0)

Page 13

Page 14: Exchange format

pmk ) (list (list (cdr (assoc 41 enx)) 0.0 0.0) (list 0.0 (cdr (assoc 42 enx)) 0.0) (list 0.0 0.0 (cdr (assoc 43 enx))) ) ) ) ) (mapcar ’− (trans (cdr (assoc 10 enx)) ocs 0) (mxv mat (cdr (assoc 10 (tblsearch "BLOCK" (cdr (assoc 2 enx)))))) ) ))

;; Matrix x Vector − Vladimir Nesterovsky;; Args: m − nxn matrix, v − vector in R^n

(defun mxv ( m v ) (mapcar ’(lambda ( r ) (apply ’+ (mapcar ’* r v))) m))

;; Matrix Transpose − Doug Wilson;; Args: m − nxn matrix

(defun trp ( m ) (apply ’mapcar (cons ’list m)))

;; Matrix x Matrix − Vladimir Nesterovsky;; Args: m,n − nxn matrices

(defun mxm ( m n ) ((lambda ( a ) (mapcar ’(lambda ( r ) (mxv a r)) m)) (trp n)))

;; Start Undo − Lee Mac;; Opens an Undo Group.

(defun LM:startundo ( doc ) (LM:endundo doc) (vla−startundomark doc))

;; End Undo − Lee Mac;; Closes an Undo Group.

(defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar ’undoctl))) (vla−endundomark doc) ))

;; Active Document − Lee Mac;; Returns the VLA Active Document Object

(defun LM:acdoc nil (eval (list ’defun ’LM:acdoc ’nil (vla−get−activedocument (vlax−get−acad−object)))) (LM:acdoc))

Page 14

Page 15: Exchange format

pmk

;; Block Collection − Lee Mac;; Returns the VLA Block Collection Object

(defun LM:acblk nil (eval (list ’defun ’LM:acblk ’nil (vla−get−blocks (LM:acdoc)))) (LM:acblk))

;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;

(if (null (getenv "LMac\\ABBRotation")) (setenv "LMac\\ABBRotation" "ON"))

;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;

(vl−load−com)(princ (strcat "\n:: AutoBlockBreak.lsp | Version 1.6 | \\U+00A9 Lee Mac " (menucmd "m=$(edtime,0,yyyy)") " www.lee−mac.com ::" "\n:: Type \"ABB\" to insert & break or \"ABBE\" / \"ABBS\" to break existing ::" ))(princ)

;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; End of File ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;

________________________________________________________________________________________________________________________________________________________________

(DEFUN C:1()

(COMMAND "LAYUNISO")

)

_________________________________________________________________________________________________________________________________________________________________________________________________________

(DEFUN C:0()

(COMMAND "LAYISO")

Page 15

Page 16: Exchange format

pmk

)

_________________________________________________________________________________________________________________________________________________________________________________________________________

(defun c:6()

(command "refedit")

)

_______________________________________________________________________________________________________________________________________________________

; ELECTRICAL PLAN POINTS

(defun c:NP(/ ss cnt blkname donelist Grp Update)

(command "−layer" "n" "NEW POINTS" "co" 3 "NEW POINTS" "")

(defun Grp (gc el) (cdr (assoc gc el))) (defun Update (bname / ename elist) (setq ename (tblobjname "BLOCK" bname)) (while ename (setq elist (entget ename ’("*")) elist (subst ’(8 . "0") (assoc 8 elist) elist) elist (if (assoc 62 elist) (subst ’(62 . 0) (assoc 62 elist) elist) (append elist ’((62 . 0))))) (entmake elist) (setq ename (entnext ename))) (if (/= "ENDBLK" (Grp 0 elist)) (entmake ’((0 . "ENDBLK") (8 . "0") (62 . 0)))) ) (if (> (logand (Grp 70 (tblsearch "layer" "0")) 1) 0) (princ "\nLayer 0 must be thawed before running FIXBLOCK!\n") (progn (if (progn (princ "\nPress <Enter> to fix all defined blocks\n") (setq ss (ssget ’((0 . "INSERT"))))) (progn (setq cnt (sslength ss)) (while (>= (setq cnt (1− cnt)) 0) (if (not (member (setq blkname (Grp 2 (entget (ssname ss cnt)))) donelist)) (progn (Update blkname) (setq donelist (cons blkname donelist))))) (setq cnt (sslength ss))) (progn (setq cnt 0) (while (setq blkname (Grp 2 (tblnext "BLOCK" (not blkname)))) (Update blkname) (setq cnt (1+ cnt))))) (princ (strcat "\n" (itoa cnt) " block" (if (= cnt 1) "" "s") " redefined\n"))))

Page 16

Page 17: Exchange format

pmk (COMMAND "CHANGE" SS "" "P" "LA" "NEW POINTS" "")

(COMMAND "CHANGE" SS "" "P" "CO" 3 "") (princ));End−of−file

________________________________________________________________________________________________________________________________________________________

(defun c:CP(/ ss cnt blkname donelist Grp Update)

(command "−layer" "n" "CHANGEPOINTS" "co" 1 "CHANGEPOINTS" "") (defun Grp (gc el) (cdr (assoc gc el))) (defun Update (bname / ename elist) (setq ename (tblobjname "BLOCK" bname)) (while ename (setq elist (entget ename ’("*")) elist (subst ’(8 . "0") (assoc 8 elist) elist) elist (if (assoc 62 elist) (subst ’(62 . 0) (assoc 62 elist) elist) (append elist ’((62 . 0))))) (entmake elist) (setq ename (entnext ename))) (if (/= "ENDBLK" (Grp 0 elist)) (entmake ’((0 . "ENDBLK") (8 . "0") (62 . 0)))) ) (if (> (logand (Grp 70 (tblsearch "layer" "0")) 1) 0) (princ "\nLayer 0 must be thawed before running FIXBLOCK!\n") (progn (if (progn (princ "\nPress <Enter> to fix all defined blocks\n") (setq ss (ssget ’((0 . "INSERT"))))) (progn (setq cnt (sslength ss)) (while (>= (setq cnt (1− cnt)) 0) (if (not (member (setq blkname (Grp 2 (entget (ssname ss cnt)))) donelist)) (progn (Update blkname) (setq donelist (cons blkname donelist))))) (setq cnt (sslength ss))) (progn (setq cnt 0) (while (setq blkname (Grp 2 (tblnext "BLOCK" (not blkname)))) (Update blkname) (setq cnt (1+ cnt))))) (princ (strcat "\n" (itoa cnt) " block" (if (= cnt 1) "" "s") " redefined\n"))))

(COMMAND "CHANGE" SS "" "P" "LA" "CHANGEPOINTS" "")

(COMMAND "CHANGE" SS "" "P" "CO" 1 "") (princ));End−of−file

________________________________________________________________________________________________________________________________________________________(defun c:SP(/ ss cnt blkname donelist Grp Update)

(command "−layer" "n" "STANDARDPOINTS" "co" 7 "STANDARDPOINTS" "")

Page 17

Page 18: Exchange format

pmk (defun Grp (gc el) (cdr (assoc gc el))) (defun Update (bname / ename elist) (setq ename (tblobjname "BLOCK" bname)) (while ename (setq elist (entget ename ’("*")) elist (subst ’(8 . "0") (assoc 8 elist) elist) elist (if (assoc 62 elist) (subst ’(62 . 0) (assoc 62 elist) elist) (append elist ’((62 . 0))))) (entmake elist) (setq ename (entnext ename))) (if (/= "ENDBLK" (Grp 0 elist)) (entmake ’((0 . "ENDBLK") (8 . "0") (62 . 0)))) ) (if (> (logand (Grp 70 (tblsearch "layer" "0")) 1) 0) (princ "\nLayer 0 must be thawed before running FIXBLOCK!\n") (progn (if (progn (princ "\nPress <Enter> to fix all defined blocks\n") (setq ss (ssget ’((0 . "INSERT"))))) (progn (setq cnt (sslength ss)) (while (>= (setq cnt (1− cnt)) 0) (if (not (member (setq blkname (Grp 2 (entget (ssname ss cnt)))) donelist)) (progn (Update blkname) (setq donelist (cons blkname donelist))))) (setq cnt (sslength ss))) (progn (setq cnt 0) (while (setq blkname (Grp 2 (tblnext "BLOCK" (not blkname)))) (Update blkname) (setq cnt (1+ cnt))))) (princ (strcat "\n" (itoa cnt) " block" (if (= cnt 1) "" "s") " redefined\n"))))

(COMMAND "CHANGE" SS "" "P" "LA" "STANDARDPOINTS" "")

(COMMAND "CHANGE" SS "" "P" "CO" 7 "") (princ));End−of−file

________________________________________________________________________________________________________________________________________________________

;;−−−−−−−−−−−−−−−−−=={ Copy/Rename Block Reference }==−−−−−−−−−−−−−−−−−−;;;; ;;;; This program allows a user to copy and/or rename a single block ;;;; reference in the working drawing. ;;;; ;;;; Many existing programs enable the user to rename the block ;;;; definition for a given block reference, with the new name ;;;; subsequently reflected across all references of the block ;;;; definition in the drawing. However, this program will allow a ;;;; single selected block reference to be renamed (or for the user to ;;;; create a renamed copy of the selected block reference), by ;;;; generating a duplicate renamed block definition for the selected ;;;; block. ;;;; ;;;; The program may be called from the command−line using either ’CB’ ;;;; to create a renamed copy of a selected block reference, or ’RB’ to ;;

Page 18

Page 19: Exchange format

pmk;; simply rename the selected block reference. ;;;; ;;;; Following selection of a block reference, the user is prompted to ;;;; specify a name for the selected/copied block reference; a default ;;;; block name composed of the original block name concatenated with ;;;; both an underscore and the minimum integer required for uniqueness ;;;; within the block collection of the active drawing is offered. ;;;; ;;;; The program will then proceed to duplicate the block definition ;;;; using the new block name. To accomplish this without resulting in ;;;; a duplicate key in the block collection of the active drawing, the ;;;; program utilises an ObjectDBX interface to which the block ;;;; definition of the selected block reference is deep−cloned, renamed, ;;;; and then deep−cloned back to the active drawing. This method also ;;;; enables Dynamic Block definitions to be successfully copied ;;;; & renamed. ;;;; ;;;; Finally, this program will perform successfully in all UCS/Views ;;;; and is compatible with Anonymous Blocks, Dynamic Blocks & XRefs. ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Author: Lee Mac, Copyright © 2013 − www.lee−mac.com ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; Version 1.5 − 05−07−2013 ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;

(defun c:cb nil (LM:RenameBlockReference t))(defun c:rb nil (LM:RenameBlockReference nil))

(defun LM:RenameBlockReference ( cpy / *error* abc app dbc dbx def doc dxf new old prp src tmp vrs )

(defun *error* ( msg ) (if (and (= ’vla−object (type dbx)) (not (vlax−object−released−p dbx))) (vlax−release−object dbx) ) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) ) (while (progn (setvar ’errno 0) (setq src (car (entsel (strcat "\nSelect block reference to " (if cpy "copy & " "") "rename: ")))) (cond ( (= 7 (getvar ’errno)) (princ "\nMissed, try again.") ) ( (= ’ename (type src)) (setq dxf (entget src)) (cond ( (/= "INSERT" (cdr (assoc 0 dxf))) (princ "\nPlease select a block reference.") ) ( (= 4 (logand 4 (cdr (assoc 70 (tblsearch "layer" (cdr (assoc 8 dxf))))))) (princ "\nSelected block is on a locked layer.") ) ) ) )

Page 19

Page 20: Exchange format

pmk ) ) (if (= ’ename (type src)) (progn (setq app (vlax−get−acad−object) doc (vla−get−activedocument app) src (vlax−ename−>vla−object src) old (vlax−get−property src (if (vlax−property−available−p src ’effectivename) ’effectivename’name)) tmp 0 ) (while (tblsearch "block" (setq def (strcat (vl−string−left−trim "*" old) "_" (itoa (setq tmp (1+ tmp))))))) (while (and (/= "" (setq new (getstring t (strcat "\nSpecify new block name <" def ">: ")))) (or (not (snvalid new)) (tblsearch "block" new) ) ) (princ "\nBlock name invalid or already exists.") ) (if (= "" new) (setq new def) ) (setq dbx (vl−catch−all−apply ’vla−getinterfaceobject (list app (if (< (setq vrs (atoi (getvar ’acadver))) 16) "objectdbx.axdbdocument" (strcat "objectdbx.axdbdocument." (itoa vrs)) ) ) ) ) (if (or (null dbx) (vl−catch−all−error−p dbx)) (princ "\nUnable to interface with ObjectDBX.") (progn (setq abc (vla−get−blocks doc) dbc (vla−get−blocks dbx) ) (vlax−invoke doc ’copyobjects (list (vla−item abc old)) dbc) (if (wcmatch old "‘**") (vla−put−name (vla−item dbc (1− (vla−get−count dbc))) new) (vla−put−name (vla−item dbc old) new) ) (vlax−invoke dbx ’copyobjects (list (vla−item dbc new)) abc) (vlax−release−object dbx) (if cpy (setq src (vla−copy src))) (if (and (vlax−property−available−p src ’isdynamicblock) (= :vlax−true (vla−get−isdynamicblock src)) ) (progn (setq prp (mapcar ’vla−get−value (vlax−invoke src ’getdynamicblockproperties))) (vla−put−name src new) (mapcar ’(lambda ( a b ) (if (/= "ORIGIN" (strcase (vla−get−propertyname a))) (vla−put−value a b)

Page 20

Page 21: Exchange format

pmk ) ) (vlax−invoke src ’getdynamicblockproperties) prp ) ) (vla−put−name src new) ) (if (= :vlax−true (vla−get−isxref (setq def (vla−item (vla−get−blocks doc) new)))) (vla−reload def) ) (if cpy (sssetfirst nil (ssadd (vlax−vla−object−>ename src)))) ) ) ) ) (princ))

;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;

(vl−load−com)(princ (strcat "\n:: CopyRenameBlock.lsp | Version 1.5 | \\U+00A9 Lee Mac " (menucmd "m=$(edtime,$(getvar,date),YYYY)") " www.lee−mac.com ::" "\n:: Available Commands:" "\n:: \"CB\" − Copy & Rename Block Reference." "\n:: \"RB\" − Rename Block Reference." ))(princ)

;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;;; End of File ;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−;;

_______________________________________________________________________________________________________________________________________________________________________________________________________________

(DEFUN C:OM();ENTER VALUE IN FEET CONVERT MM VALUE IN OFFSE

(COMMAND "LUNITS" 4)

(SETQ

ED(GETDIST "\n ENTER OFFSET DISTANCE :")

SS(ENTSEL)

ST(GETPOINT "\n SPECIFY POINT ON SIDE:")

FI(*(* 0.0833333333 ED)12)

Page 21

Page 22: Exchange format

pmk

MM(/ FI 0.04)

)

(COMMAND "OFFSET" MM SS ST "")

(COMMAND "LUNITS" 2) )

____________________________________________________________________________________________________________________________________________________________________________________________________________

(defun c:bm(/ s p ss i nm e dyn vl) ; ITS TO FIND DOOR (D2 D3 ETC..) AND WINDOW BLOCK MARK (if (and (setq s (ssget "_+.:S:E" ’((0 . "INSERT")))) (setq p (getpoint "\n Specify Point :")) (if (wcmatch (setq nm (cdr (assoc 2 (entget (setq e (ssname s 0)))))) "‘**" ) (setq nm (strcat "‘*U*," nm) dyn t vl (vlax−ename−>vla−object e) ) nm ) (setq ss (ssget "_X" (list ’(0 . "INSERT") (cons 410 (getvar ’CTAB)) (cons 2 nm) ) ) ) ) ((lambda (u / sn) (while (setq sn (ssname ss (setq u (1+ u)))) (if dyn (if (eq (vla−get−effectivename vl) (vla−get−effectivename (vlax−ename−>vla−object sn)) ) (entmakex (list ’(0 . "LINE") (cons 10 p) (cons 11 (cdr (assoc 10 (entget sn)))) ) ) ) (entmakex (list ’(0 . "LINE") (cons 10 p) (cons 11 (cdr (assoc 10 (entget sn)))) )

Page 22

Page 23: Exchange format

pmk ) ) ) ) −1 ) ) (princ))(vl−load−com)

_________________________________________________________________________________________________________________________________________________________________________________________________________;;;−−− Function to get the block data

(defun getAttData(/ eset hdrStr dataList blkCntr en enlist blkType blkName entName entPoint entRot entX entY entZ entLay attTag attVal entSty entClr dStr group66) ;;;−−− Set up an empty list (setq dataList(list))

;;;−−− If that type of entity exist in drawing (if (setq eset(ssget "X" (list (cons 0 "INSERT")))) (progn

;;;−−− Set up some counters (setq blkCntr 0 cntr 0) ;;;−−− Loop through each entity (while (< blkCntr (sslength eset)) ;;;−−− Get the entity’s name (setq en(ssname eset blkCntr)) ;;;−−− Get the DXF group codes of the entity (setq enlist(entget en))

;;;−−− Get the name of the block (setq blkName(cdr(assoc 2 enlist))) ;;;−−− Check to see if the block’s attribute flag is set (if(cdr(assoc 66 enlist)) (progn ;;;−−− Get the entity name (setq en(entnext en)) ;;;−−− Get the entity dxf group codes (setq enlist(entget en)) ;;;−−− Get the type of block (setq blkType (cdr(assoc 0 enlist))) ;;;−−− If group 66 then there are attributes nested inside this block (setq group66(cdr(assoc 66 enlist))) ;;;−−− Loop while the type is an attribute or a nested attribute exist (while(or (= blkType "ATTRIB")(= group66 1))

Page 23

Page 24: Exchange format

pmk ;;;−−− Get the block type (setq blkType (cdr(assoc 0 enlist))) ;;;−−− Get the block name (setq entName (cdr(assoc 2 enlist))) ;;;−−− Check to see if this is an attribute or a block (if(= blkType "ATTRIB") (progn ;;;−−− Save the name of the attribute (setq attTag(cdr(assoc 2 enlist))) ;;;−−− Get the value of the attribute (setq attVal(cdr(assoc 1 enlist))) ;;;−−− Save the data gathered (setq dataList(append dataList(list (list blkName attTag attVal)))) ;;;−−− Increment the counter (setq cntr (+ cntr 1)) ;;;−−− Get the next sub−entity or nested entity as you will (setq en(entnext en)) ;;;−−− Get the dxf group codes of the next sub−entity (setq enlist(entget en)) ;;;−−− Get the block type of the next sub−entity (setq blkType (cdr(assoc 0 enlist))) ;;;−−− See if the dxf group code 66 exist. if so, there are more nested attributes (setq group66(cdr(assoc 66 enlist))) ) ) ) ) ;;;−−− Else, the block does not contain attributes (progn ;;;−−− Setup a bogus tag and value (setq attTag "" attVal "")

;;;−−− Save the data gathered (setq dataList(append dataList(list (list blkName attTag attVal)))) ) ) (setq blkCntr (+ blkCntr 1)) ) ) ) dataList)

;;;−−− Function to count occurences within a list

Page 24

Page 25: Exchange format

pmk(defun goCountData(ele lst / cnt a) (setq cnt 0) (foreach a lst (if(equal a ele) (setq cnt(+ cnt 1)) ) ) cnt)

;;;−−− Function to update the data

(defun updateData()

� ;;;−−− Setup a list to hold the selected items� (setq blkDataList(list))

� ;;;−−− Save the list setting� (setq readlist(get_tile "blklist"))

� ;;;−−− Setup a variable to run through the list� (setq count 1)

� ;;;−−− cycle through the list getting all of the selected items� (while (setq item (read readlist))��� (setq blkDataList(append blkDataList (list (nth item blkList))))��� (while ����� (and������� (/= " " (substr readlist count 1))������� (/= "" � (substr readlist count 1))����� )����� (setq count (1+ count))��� )��� (setq readlist (substr readlist count))� )

� ;;;−−− Setup a list to hold the selected items� (setq tagDataList(list))

� ;;;−−− Save the list setting� (setq readlist(get_tile "taglist"))

� ;;;−−− Setup a variable to run through the list� (setq count 1)

� ;;;−−− cycle through the list getting all of the selected items� (while (setq item (read readlist))��� (setq tagDataList(append tagDataList (list (nth item tagList))))��� (while ����� (and������� (/= " " (substr readlist count 1))������� (/= "" � (substr readlist count 1))����� )����� (setq count (1+ count))��� )��� (setq readlist (substr readlist count))� )

Page 25

Page 26: Exchange format

pmk

� ;;;−−− Setup a list to hold the selected items� (setq valDataList(list))

� ;;;−−− Save the list setting� (setq readlist(get_tile "vallist"))

� ;;;−−− Setup a variable to run through the list� (setq count 1)

� ;;;−−− cycle through the list getting all of the selected items� (while (setq item (read readlist))��� (setq valDataList(append valDataList (list (nth item valList))))��� (while ����� (and������� (/= " " (substr readlist count 1))������� (/= "" � (substr readlist count 1))����� )����� (setq count (1+ count))��� )��� (setq readlist (substr readlist count))� )

;;;−−− Set up a list to hold all data that matches the block name (setq myData(list)) ;;;−−− Cycle through all data and find block name matches (foreach a dataList (if(or(member "All" blkDataList)(member (car a) blkDataList)) (setq myData(append myData (list a))) ) )

;;;−−− Set up a list to hold the data that matches the tag name (setq myData2(list))

;;;−−− Filter through all previous matches to find tag matches (foreach a myData (if(or(member "All" tagDataList)(member (cadr a) tagDataList)) (setq myData2(append myData2 (list a))) ) )

;;;−−− Filter the previous matches for attribute value matches (setq myData3(list)) (foreach a myData2 (if(or(member "All" valDataList)(member (caddr a) valDataList)) (setq myData3(append myData3 (list a))) ) )

;;;−−− Set up a list to hold the used data [old data] (setq usedData(list))

;;;−−− Reset the orignal list to hold the new data (setq myData(list))

;;;−−− Cycle through each match (foreach a myData3

Page 26

Page 27: Exchange format

pmk

;;;−−− Make sure we haven’t counted it already (if(not(member a usedData)) (progn

;;;−−− Count the number of times the match appears in the list (setq cnt(goCountData a myData3))

;;;−−− Add the data and the count to the new list (setq myData(append myData (list(list cnt a))))

;;;−−− Add the data to the used list so we don’t count it twice (setq usedData(append usedData (list a))) ) ) )

;;;−−− Set up a list to hold the formatted data for the dialog box (setq newData(list))

;;;−−− If new data was found (if myData (progn

;;;−−− Format the data (foreach a myData (setq qty(substr (strcat (itoa (car a))" ") 1 6)) (setq bna(substr (strcat (car (cadr a)) " ") 1 20)) (setq tgn(substr (strcat (cadr (cadr a)) " ") 1 20)) (setq van(substr (strcat (caddr(cadr a)) " ") 1 20))

;;;−−− Add it to the new data list (setq newData(append newData (list (strcat qty bna tgn van)))) ) ;;;−−− Add a horizontal line (setq newData (append (list "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−" ) newData ) )

;;;−−− Add a header (setq newData (append (list "Qty. Block Name Tag Value" ) newData ) ) ;;;−−− Add the list to the dialog box (start_list "totallist" 3) (mapcar ’add_list newData) (end_list) )

Page 27

Page 28: Exchange format

pmk (progn ;;;−−− Clear the list in the dialog box (start_list "totallist" 3) (mapcar ’add_list newData) (end_list) ) ))

;;;−−− Function to sort a list;;;;;;−−− Usage (sort (list "F" "A" "B"));;;(defun sort(alist / n)(setq lcup nil rcup nil) (defun cts(a b) (cond ((> a b)t) ((= a b )t) (t nil) )) (foreach n alist (while (and rcup(cts n(car rcup)))(setq lcup(cons(car rcup)lcup)rcup(cdr rcup))) (while (and lcup(cts(car lcup)n))(setq rcup(cons(car lcup)rcup)lcup(cdr lcup))) (setq rcup(cons n rcup)) ) (append(reverse lcup)rcup))

;;;−−− Function to write the data to a file

(defun writeData()

;;;−−− Set up a counter (setq lineCntr 0)

;;;−−− Get a file name from the user (if(setq filName(getfiled "Select File Name" "" "csv" 1)) (progn ;;;−−− Open the file to write (if(setq fil(open filName "w")) (progn ;;;−−− Print a header string (princ "QTY.,Block Name,Tag,Value\n" fil) (foreach a myData (princ (strcat (itoa(car a)) "," (car(cadr a))","(cadr(cadr a))","(caddr(cadr a))"\n") fil) (setq lineCntr(+ lineCntr 1)) )

;;;−−− Close the file (close fil)

Page 28

Page 29: Exchange format

pmk (alert (strcat "Finished Sending " (itoa lineCntr) " lines to the CSV file!\n\nNote: Double click the CSV file and Excel will open it." ) ) ) (princ "\n ERROR − Could not open CSV file!") ) ) (princ "\n ERROR − Invalid file name!") ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; 888 888 888 8888888 8888 888 ;;;;;; 8888 8888 88888 888 88888 888 ;;;;;; 88888 88888 888 888 888 888888 888 ;;;;;; 888888 888888 888 888 888 888 888888 ;;;;;; 888 88888 888 88888888888 888 888 88888 ;;;;;; 888 888 888 888 888 8888888 888 8888 ;;;;;; ;;;;;; ;;;;;; 888 888888888 888888888 ;;;;;; 88888 888 888 888 888 ;;;;;; 888 888 888 888 888 888 ;;;;;; 888 888 888888888 888888888 ;;;;;; 88888888888 888 888 ;;;;;; 888 888 888 888 ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun C:BLOCKS()

;;;−−− Setup an empty list to hold all of the data (setq myData(list))

;;;−−− Get a the data from the blocks (if(setq dataList(getattData)) (progn ;;;−−− Setup list to hold the block names, tag names, and values (setq blkList(list) tagList(list) valList(list))

;;;−−− Seperate the data (foreach a dataList (if(not (member (car a) blkList)) (setq blkList(append blkList (list (car a)))) ) (if(not (member (cadr a) tagList)) (setq tagList(append tagList (list (cadr a)))) ) (if(not (member (caddr a) valList)) (setq valList(append valList (list (caddr a))))

Page 29

Page 30: Exchange format

pmk ) )

;;;−−− Sort the list (setq blkList(sort blkList)) (setq tagList(sort tagList)) (setq valList(sort valList))

;;;−−− Add the "ALL" option (setq blkList(append (list "All") blkList)) (setq tagList(append (list "All") tagList)) (setq valList(append (list "All") valList))

;;;−−− Build the data list (setq blkDataList blkList tagDataList tagList valDataList valList) ;;;−−− Put up the dialog box (setq dcl_id (load_dialog "BLOCKS.dcl")) ;;;−−− See if it is already loaded (if (not (new_dialog "BLOCKS" dcl_id)) (progn (alert "The BLOCKS.DCL file could not be found!") (exit) ) )

;;;−−− Add the list to the dialog box (start_list "blklist" 3) (mapcar ’add_list blkList) (end_list) (start_list "taglist" 3) (mapcar ’add_list tagList) (end_list) (start_list "vallist" 3) (mapcar ’add_list valList) (end_list)

(updateData)

;;;−−− If an action event occurs, do this function (action_tile "blklist" "(updateData)") (action_tile "taglist" "(updateData)") (action_tile "vallist" "(updateData)") (action_tile "write" "(writeData)") (action_tile "cancel" "(done_dialog)")

;;;−−− Display the dialog box (start_dialog) ) (alert "No blocks with attributes found in drawing!") ) (princ))

_________________________________________________________________________________________________________________________________________________________

Page 30