commerce value convert

58
PRICOL (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 :") DI(DISTANCE P1 P2 ) ; fi(fix di) Page 1

Upload: muthu-kumar

Post on 20-Nov-2015

37 views

Category:

Documents


8 download

DESCRIPTION

FDGHHFGFGH

TRANSCRIPT

  • PRICOL(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 :")

    DI(DISTANCE P1 P2 )

    ; fi(fix di)

    Page 1

  • PRICOL

    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") (VLVBALOAD "D:/pro/HIDEOBJ.DVB") (VLVBARUN "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") )__________________________________________________________________________________________________________________________________

    (DEFUN C:HB() (SETQ bO(SSGET "X" (LIST(CONS 0 "INSERT")))

    Page 2

  • PRICOL ) (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:UH() (command "UNISOLATEOBJECTS")

    )

    _________________________________________________________________(defun c:SD()

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

    (command "stretch" a1 pause)

    )

    ___________________________________________________________________________________________________________________________________________________________________________________

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

    )

    ___________________________________________________________________________________________________________________________________________________________________________________

    (DEFUN C:AS()

    (setq

    Page 3

  • PRICOL 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")

    )

    _________________________________________________________________________________________________________________________________________________

    ;;=={ Automatic Block Break }==;;;; ;;;; This program enables the user to insert a block at a specified ;;

    Page 4

  • PRICOL;; 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.leemac.com ;;;;;;;; Version 1.0 22112010 ;;;; ;;;; First Release. ;;;;;;;; Version 1.1 07022011 ;;;; ;;;; Entire program rewritten to allow subfunction to be called with ;;;; block object argument. ;;;; ;;;; Multiple intersecting objects are now trimmed. ;;;;;;;; Version 1.2 08022011 ;;;; ;;;; Changed block insertion to Visual LISP InsertBlock method. ;;;; ;;;; Added calling functions to trim blocks insitu (ABBE / ABBS). ;;;;;;;; Version 1.3 03082011 ;;;; ;;;; 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 30092011 ;;;; ;;;; Added option to enable/disable automatic block rotation. ;;;; ;;;; Updated code formatting. ;;;;;;;; Version 1.5 04032013 ;;;; ;;;; 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. ;;

    Page 5

  • PRICOL;;;;;; Version 1.6 01102013 ;;;; ;;;; 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 " : ") ) ) ) ) (cond ( (= 7 (getvar errno)) (princ "\nMissed, Try Again.") ) ( (null sel) (if (= "" blk) (setq blk nil) ) ) ( (= "Rotation" sel) (initget "ON OFF") (setenv "LMac\\ABBRotation" (cond ( (getkword (strcat "\nAutomatic Block Rotation [ON/OFF] : " ) ) ) ( (getenv "LMac\\ABBRotation") ) ) ) ) ( (= "Browse" sel) (setq blk (getfiled "Select Block" "" "dwg" 16)) nil )

    Page 6

  • PRICOL ( (listp sel) (if (/= "INSERT" (cdr (assoc 0 (entget (car sel))))) (princ "\nObject must be a block.") (setq obj (vlacopy (vlaxename>vlaobject (car sel))) blk nil ) ) ) ) ) ) (not (or blk obj)) ) ) ( (setq ins (getpoint "\nSpecify Point for Block: ")) (LM:startundo (LM:acdoc)) (if (null obj) (setq obj (vlainsertblock (vlaxgetproperty (LM:acdoc) (if (= 1 (getvar cvport)) paperspace modelspace)) (vlax3Dpoint (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 (vlfilenamebase blk))) (vlaputinsertionpoint obj (vlax3Dpoint (trans ins 1 0))) (LM:AutoBlockBreak (vlaxvlaobject>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 ;;;; 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.leemac.com ;;;;;;

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

    Page 7

  • PRICOL (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") ) ) ) ) ( (= 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.") ) ( 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.leemac.com ;;

    Page 8

  • PRICOL;;;;

    (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 nonnil value, the supplied block reference is ;;;; rotated to align with the curve. ;;;; ;;;;;;;; Author: Lee Mac, Copyright 2010 www.leemac.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 (= vlaobject (type ply)) (null (vlaxerasedp ply)) (vlaxwriteenabledp ply) ) (vladelete ply) ) (if (= int (type cmd)) (setvar cmdecho cmd) ) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) )

    Page 9

  • PRICOL (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) (1e4 1e4)) (mapcar (trans ins ent 1) (1e4 1e4)) ((0 . "ARC,ELLIPSE,CIRCLE,LINE,XLINE,SPLINE,*POLYLINE")) ) ) ) (progn (setq crv (ssname crv 0)) (setq ang (angle (0.0 0.0 0.0) (trans (vlaxcurvegetfirstderiv crv (vlaxcurvegetparamatpoint crv (vlaxcurvegetclosestpointto crv (trans ins ent 0)) ) ) 0 (cdr (assoc 210 (entget crv))) ) ) ) (if (and (< (/ pi 2.0) ang) (vlaobject ent) ang) ;; VL used to account for attributes ) ) (if (and (setq bbx (LM:blockboundingbox (vlaxename>vlaobject ent))) (setq sel (ssget "_C" (trans (car bbx) 0 1) (trans (caddr bbx) 0 1) ((0 . "ARC,ELLIPSE,CIRCLE,LINE,XLINE,SPLINE,*POLYLINE"))

    Page 10

  • PRICOL ) ) ) (progn (setq ply (vlaxename>vlaobject (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 (vlaxename>vlaobject ent) ply acextendthisentity)) (setq lst (cons (cons ent int) lst)) ) ) (vladelete ply) (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] VLAObjects 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 (vlaxinvoke obj1 intersectwith obj2 mode)) (repeat (/ (length l) 3) (setq r (cons (list (car l) (cadr l) (caddr l)) r) l (cdddr l) ) ) (reverse r))

    Page 11

  • PRICOL

    ;;=={ 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.leemac.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 (vlagetname blk))) (cond ( (setq lst (cdr (assoc bnm *blockboundingboxes*)))) ( (progn (vlaxfor obj (vlaitem (LM:acblk) bnm) (cond ( (= "AcDbBlockReference" (vlagetobjectname obj)) (setq lst (append lst (LM:blockboundingbox obj))) ) ( (and (= :vlaxtrue (vlagetvisible obj)) (not (wcmatch (vlagetobjectname obj) "AcDbAttributeDefinition,AcDb*Text")) (vlaxmethodapplicablep obj getboundingbox) (not (vlcatchallerrorp (vlcatchallapply vlagetboundingbox (list obj llp urp)))) ) (setq lst (vllist* (vlaxsafearray>list llp) (vlaxsafearray>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 (vlaxvlaobject>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);;

    Page 12

  • PRICOL;; 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) ) (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) (vlastartundomark doc)

    Page 13

  • PRICOL)

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

    (defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar undoctl))) (vlaendundomark doc) ))

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

    (defun LM:acdoc nil (eval (list defun LM:acdoc nil (vlagetactivedocument (vlaxgetacadobject)))) (LM:acdoc))

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

    (defun LM:acblk nil (eval (list defun LM:acblk nil (vlagetblocks (LM:acdoc)))) (LM:acblk))

    ;;;;

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

    ;;;;

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

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

    ________________________________________________________________________________________________________________________________________________________________

    (DEFUN C:1()

    (COMMAND "LAYUNISO")

    Page 14

  • PRICOL

    )

    _________________________________________________________________________________________________________________________________________________________________________________________________________

    (DEFUN C:0()

    (COMMAND "LAYISO")

    )

    _________________________________________________________________________________________________________________________________________________________________________________________________________

    (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 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

    Page 15

  • PRICOL (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" "NEW POINTS" "")

    (COMMAND "CHANGE" SS "" "P" "CO" 3 "") (princ));Endoffile

    ________________________________________________________________________________________________________________________________________________________

    (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 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));Endoffile

    Page 16

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

    (command "layer" "n" "STANDARDPOINTS" "co" 7 "STANDARDPOINTS" "") (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 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));Endoffile

    ________________________________________________________________________________________________________________________________________________________

    ;;=={ 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. ;;;; ;;

    Page 17

  • PRICOL;; The program may be called from the commandline using either CB ;;;; to create a renamed copy of a selected block reference, or RB to ;;;; 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 deepcloned, renamed, ;;;; and then deepcloned 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.leemac.com ;;;;;;;; Version 1.5 05072013 ;;;;;;

    (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 (= vlaobject (type dbx)) (not (vlaxobjectreleasedp dbx))) (vlaxreleaseobject 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 18

  • PRICOL (if (= ename (type src)) (progn (setq app (vlaxgetacadobject) doc (vlagetactivedocument app) src (vlaxename>vlaobject src) old (vlaxgetproperty src (if (vlaxpropertyavailablep src effectivename) effectivename name)) tmp 0 ) (while (tblsearch "block" (setq def (strcat (vlstringlefttrim "*" old) "_" (itoa (setq tmp (1+ tmp))))))) (while (and (/= "" (setq new (getstring t (strcat "\nSpecify new block name : ")))) (or (not (snvalid new)) (tblsearch "block" new) ) ) (princ "\nBlock name invalid or already exists.") ) (if (= "" new) (setq new def) ) (setq dbx (vlcatchallapply vlagetinterfaceobject (list app (if (< (setq vrs (atoi (getvar acadver))) 16) "objectdbx.axdbdocument" (strcat "objectdbx.axdbdocument." (itoa vrs)) ) ) ) ) (if (or (null dbx) (vlcatchallerrorp dbx)) (princ "\nUnable to interface with ObjectDBX.") (progn (setq abc (vlagetblocks doc) dbc (vlagetblocks dbx) ) (vlaxinvoke doc copyobjects (list (vlaitem abc old)) dbc) (if (wcmatch old "**") (vlaputname (vlaitem dbc (1 (vlagetcount dbc))) new) (vlaputname (vlaitem dbc old) new) ) (vlaxinvoke dbx copyobjects (list (vlaitem dbc new)) abc) (vlaxreleaseobject dbx) (if cpy (setq src (vlacopy src))) (if (and (vlaxpropertyavailablep src isdynamicblock) (= :vlaxtrue (vlagetisdynamicblock src)) ) (progn (setq prp (mapcar vlagetvalue (vlaxinvoke src getdynamicblockproperties))) (vlaputname src new) (mapcar (lambda ( a b ) (if (/= "ORIGIN" (strcase (vlagetpropertyname a))) (vlaputvalue a b) ) ) (vlaxinvoke src getdynamicblockproperties) prp ) ) (vlaputname src new)

    Page 19

  • PRICOL ) (if (= :vlaxtrue (vlagetisxref (setq def (vlaitem (vlagetblocks doc) new)))) (vlareload def) ) (if cpy (sssetfirst nil (ssadd (vlaxvlaobject>ename src)))) ) ) ) ) (princ))

    ;;;;

    (vlloadcom)(princ (strcat "\n:: CopyRenameBlock.lsp | Version 1.5 | \\U+00A9 Lee Mac " (menucmd "m=$(edtime,$(getvar,date),YYYY)") " www.leemac.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)

    MM(/ FI 0.04)

    )

    (COMMAND "OFFSET" MM SS ST "")

    Page 20

  • PRICOL (COMMAND "LUNITS" 2) )

    ____________________________________________________________________________________________________________________________________________________________________________________________________________(defun C:TM (/ str basept ss n); = Text Mark (setq str (getstring "\nText content to mark: ") basept (getpoint "\nBase point for marking Lines: ") ); setq ; (COMMAND "LAYER" "N" STR "" )(COMMAND "LAYER" "S" STR "" ) (if (setq ss (ssget "_X" (list (0 . "TEXT") (cons 1 str) (cons 410 (getvar CTAB))))) (repeat (setq n (sslength ss)); then (entmake (list (0 . "LINE") (cons 10 basept) (cons 11 (cdr (assoc 10 (entget (ssname ss (setq n (1 n))))))) ); list ); entmake ); repeat (alert "No Text found with that content."); else ); if (alert (strcat (strcase str) "\t" "=" "\t" (itoa (sslength ss)) "Nos")) (princ)); defun

    ________________________________________________________________________________________________________________________________________________________________________________________________________(defun C:MTM (/ str basept ss n); = MText Mark (setq str (getstring "\nText content to mark: ") basept (getpoint "\nBase point for marking Lines: ") ); setq

    ;(COMMAND "LAYER" "N" STR "" )(COMMAND "LAYER" "S" STR "" ) (if (setq ss (ssget "_X" (list (0 . "MTEXT") (cons 1 str) (cons 410 (getvar CTAB))))) (repeat (setq n (sslength ss)); then (entmake (list (0 . "LINE") (cons 10 basept) (cons 11 (cdr (assoc 10 (entget (ssname ss (setq n (1 n))))))) ); list ); entmake ); repeat (alert "No Text found with that content."); else ); if (alert (strcat (strcase str) "\t" "=" "\t" (itoa (sslength ss)) "Nos")) (princ)); defun

    ___________________________________________________________________________________________________________________________________________________________________________________________________________(defun C:BM (/ str basept ss n); = BLOCK Mark

    Page 21

  • PRICOL (setq str (getstring "\nText content to mark: ") basept (getpoint "\nBase point for marking Lines: ") ); setq (COMMAND "LAYER" "N" STR "" )(COMMAND "LAYER" "S" STR "" ) (if (setq ss (ssget "_X" (list (0 . "insert") (cons 2 str) (cons 410 (getvar CTAB))))) (repeat (setq n (sslength ss)); then (entmake (list (0 . "LINE") (cons 10 basept) (cons 11 (cdr (assoc 10 (entget (ssname ss (setq n (1 n))))))) ); list ); entmake ); repeat (alert "No Text found with that content."); else ); if (alert (strcat (strcase str) "\t" "=" "\t" (itoa (sslength ss)) "Nos")) (princ)); defun

    _____________________________________________________________________________________________________________________________________________________________________________________________________________

    ;;; 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 entitys 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 blocks 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))

    Page 22

  • PRICOL ;;; 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)) ;;; 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 subentity or nested entity as you will (setq en(entnext en)) ;;; Get the dxf group codes of the next subentity (setq enlist(entget en)) ;;; Get the block type of the next subentity (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)

    Page 23

  • PRICOL

    ;;; Function to count occurences within a list

    (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 24

  • PRICOL )

    ;;; 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

    ;;; Make sure we havent counted it already (if(not(member a usedData))

    Page 25

  • PRICOL (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 dont 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) ) (progn ;;; Clear the list in the dialog box (start_list "totallist" 3) (mapcar add_list newData) (end_list) )

    Page 26

  • PRICOL ))

    ;;; 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) (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!") )

    Page 27

  • PRICOL)

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; 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)))) ) )

    ;;; 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)

    Page 28

  • PRICOL ;;; 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))

    _________________________________________________________________________________________________________________________________________________________

    (defun c:tfind() (tfindfun nil nil 0) )

    (defun tfindfun(inputF inputR caseSn / goto goWhile strinF strinR selSet selTxt searep case count error) ; 01 Create selection set. GOTO 02 if success, or GOTO 08 if fail ; 02 Check passed input. If both nil, GOTO 03. If first string and second nil, GOTO 06. If both strings,GOTO 07. Otherwise, return error and GOTO 08 ; 03 Display menus and obtain data from user. If Search, GOTO 04. If Replace, GOTO 05 ; 04 Search option selected. Prompt user for single search term. GOTO 06 ; 05 Replace option selected. Prompt user for search term and replace term. GOTO 07 ; 06 One string has been passed. Assume automatic search. Run same as current (tfind). GOTO FINISH ; 07 Two strings have been passed. Assume automatic replace. Pass both strings to (replace) function.GOTO FINISH ; 08 FINISH. Return errors if needed. End loop and program. (vlloadcom) (setq goTo 1) (setq goWhile 1)

    Page 29

  • PRICOL (setq count 0) (if (not (mlml (list caseSn) (list 0 1))) (progn (setq goWhile nil) (princ "\nCase selection not recognized."))) (if (= caseSn 0) (setq case "N") (setq case "Y")) (while goWhile (cond ((= goTo 1) (setq selSet (extTxtPt (ssget "_X" (list (cons 4 ""))))) (if selSet (setq goTo 2) (setq error "\nSelection set not found." goTo 8)) ) ((= goTo 2) ; Check input, pass to whatever. (cond ((and (= inputF nil) (= inputR nil)) (setq goTo 3) ) ((and (= (type inputF) STR) (= inputR nil)) (setq strinF inputF) (setq goTo 6) ) ((and (= (type inputF) STR) (= (type inputR) STR)) (setq strinF inputF) (setq strinR inputR) (setq goTo 7) ) (t (setq error "\nPassed arguments are not accepted.") (setq goTo 8) ) ) ) ((= goTo 3) ; Obtain desired option from user (while (not (mlml (list (setq searep (strcase (getstring nil "\nSelect option [Find/Replace/Quit/Case]: ")))) (list "F" "FIND" "R" "REPLACE" "Q" "QUIT" "C" "CASE") )) ) (cond ((mlml (list searep) (list "F" "FIND")) (setq goTo 4) ) ((mlml (list searep) (list "R" "REPLACE")) (setq goTo 5) ) ((mlml (list searep) (list "Q" "QUIT")) (setq goTo 8) ) ((mlml (list searep) (list "C" "CASE")) (while (not (mlml (list (setq case (strcase (getstring nil "\nCase sensitive? [Yes/No]: ")))) (list "Y" "YES" "N" "NO") )) ) ) ) ) ((= goTo 4) ; Obtain search string from user, set to strinF (while (eq "" (setq strinF (getstring T "\nEnter search term: ")))) (setq goTo 6) ) ((= goTo 5) ; Obtain search string and replace string from user, set to strinF and strinR respectively

    Page 30

  • PRICOL (while (eq "" (setq strinF (getstring T "\nEnter find term: ")))) (while (eq "" (setq strinR (getstring T "\nEnter replace term: ")))) (setq goTo 7) ) ((= goTo 6) ; Search drawing for strinF (cond ((mlml (list case) (list "Y" "YES")) ; Compare using (vlstringsearch strinF input), view selection ; use "while" to get all search occurances (foreach selVar selSet (if (vlstringsearch strinF (nth 0 selVar)) (progn (setq count (1+ count)) (if (/= (getvar "ctab") (caddr selVar)) (command "ctab" (caddr selVar))) (command "zoom" "c" (trans (cadr selVar) 0 1) (* 32 (nth 3 selVar))) (getstring "\nPress Enter to continue: ") ) ) ) ) ((mlml (list case) (list "N" "NO")) ; Compare using (vlstringsearch (strcase strinF) (strcase input)), view selection ; use "while" to get all search occurances (foreach selVar selSet (if (vlstringsearch (strcase strinF) (strcase (nth 0 selVar))) (progn (setq count (1+ count)) (if (/= (getvar "ctab") (caddr selVar)) (command "ctab" (caddr selVar))) (command "zoom" "c" (trans (cadr selVar) 0 1) (* 32 (nth 3 selVar))) (getstring "\nPress Enter to continue: ") ) ) ) ) ) (if (= count 0) (setq error "\nNo matches found.") (setq error (strcat (itoa count) " matches found."))) (setq goTo 8) ) ((= goTo 7) ; Replace strinF with strinR (cond ((mlml (list case) (list "Y" "YES")) ; Compare using (vlsearchstring strinF input), modify using (vlstringsubst) within a while loop (foreach selVar selSet (setq selTxt (nth 0 selVar)) (setq seaLoc 0) (while (setq seaLoc (vlstringsearch strinF selTxt seaLoc)) (setq selTxt (vlstringsubst strinR strinF selTxt seaLoc)) (setq seaLoc (+ seaLoc (strlen strinR))) (setq count (1+ count)) ) (vlaputTextString (vlaxename>vlaobject (nth 4 selVar)) selTxt) ) ) ((mlml (list case) (list "N" "NO")) ; Compare using (vlstringsearch (strcase strinF) (strcase input)), modify using (vlstringsubst) within a while loop (foreach selVar selSet (setq selTxt (nth 0 selVar)) (setq seaLoc 0) (while (setq seaLoc (vlstringsearch (strcase strinF) (strcase selTxt) seaLoc)) (setq selTxt (strcat (substr selTxt 1 seaLoc) strinR (substr selTxt (+ 1 seaLoc (strlen

    Page 31

  • PRICOLstrinF))))) (setq seaLoc (+ seaLoc (strlen strinR))) (setq count (1+ count)) ) (vlaputTextString (vlaxename>vlaobject (nth 4 selVar)) selTxt) ) ) ) (if (= count 0) (setq error "\nNo occurances found.") (setq error (strcat (itoa count) " occurancesmodified."))) (setq goTo 8) ) ((= goTo 8) (if error (princ error)) (setq goWhile nil) ) ) ) (princ) )

    (defun mlml(inSMLChar inSMLStri / returnVarMS toCheck chkWith) (setq returnVarMS nil) (if (and (= (type inSMLChar) LIST) (= (type inSMLStri) LIST) ) (progn (foreach toCheck inSMLStri (foreach chkWith inSMLChar (if (eq toCheck chkWith) (setq returnVarMS T)) ) ) );/progn ) returnVarMS ); Checks a list to see if a member of that list is the same as a member of another list. Returns T or nil

    (defun extTxtPt(ssList / subVar getEnt entTyp entTxt entPnt entLay entHgt grp66 entAtt getEntAtt entAttTyp uniLst) (setq uniLst nil) (setq subVar 0) (if ssList (repeat (sslength ssList) (setq getEnt (entget (cadr (car (ssnamex ssList subVar))))) (setq entTyp (cdr (assoc 0 getEnt))) (cond ((or (= entTyp "TEXT") (= entTyp "MTEXT")) (setq entTxt (cdr (assoc 1 getEnt))) (setq entPnt (cdr (assoc 10 getEnt))) (setq entHgt (cdr (assoc 40 getEnt))) (setq entLay (cdr (assoc 410 getEnt))) (setq entNam (cdr (assoc 1 getEnt)))

    (setq uniLst (append uniLst (list (list entTxt entPnt entLay entHgt entNam)))) ) ((= entTyp "INSERT") (setq grp66 (assoc 66 getEnt)) (if grp66 (progn (setq entAtt (entnext (cdr (assoc 1 getEnt)))) (setq getEntAtt (entget entAtt)) (setq entAttTyp (cdr (assoc 0 getEntAtt))) )

    Page 32

  • PRICOL ) (while (= entAttTyp "ATTRIB") (setq entTxt (cdr (assoc 1 getEntAtt))) (setq entPnt (cdr (assoc 10 getEntAtt))) (setq entHgt (cdr (assoc 40 getEntAtt))) (setq entLay (cdr (assoc 410 getEntAtt))) (setq entNam (cdr (assoc 1 getEntAtt))) (setq uniLst (append uniLst (list (list entTxt entPnt entLay entHgt entNam))))

    ; Get next entity. (setq entAtt (entnext (cdr (assoc 1 getEntAtt))))

    ; Get ent and ent type (setq getEntAtt (entget entAtt)) (setq entAttTyp (cdr (assoc 0 getEntAtt))) ) ) (t ) ) (setq subVar (1+ subVar)) ) ) uniLst ); Return list of all textbased objects (Text, MText, Attribute) in the current drawing

    _________________________________________________________________________________________________________________________________________________________

    (defun c:FC(/ ss l sset str e); FEET CHECK AND CONVERT IN MM

    (COMMAND "lunits" 2)

    (COMMAND "luprec" 0)

    (SETQ

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

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

    DI(DISTANCE P1 P2 )

    ; fi(fix di)

    CV(CVUNIT DI "MILLIMETER" "FOOT")

    TE(RTOS (FIX DI))

    P2(GETPOINT "\n PICK VER FIRST POINT :")

    P3(GETPOINT P2 "\n PICK VER SECOND POINT :")

    Page 33

  • PRICOL

    DI1(DISTANCE P2 P3 )

    ; fi(fix di)

    CV1(CVUNIT DI1 "MILLIMETER" "FOOT")

    TE1(RTOS (FIX DI1))

    )

    (alert (strcat (RTOS (* 12 CV) 3 1) " ""x "" " (RTOS (* 12 CV1) 3 1) "\n" "\n" (rtos di) " ""x "" "(rtos di1) " " "MM" ))

    (if (setq ss (ssget "_:L" ((0 . "TEXT,MTEXT")))) (repeat (setq l (sslength ss)) (setq sset (ssname ss (setq l (1 l)))) (setq str (cdr (assoc 1 (setq e (entget sset))))) (entupd (cdr (assoc 1 (entmod (subst (cons 1 (strcat (rtos di) " ""x"" " (rtos di1))) (assoc 1 e) e)) ) ) ) ) (princ) ) (princ) (COMMAND "luprec" 2)

    (VLVBALOAD "D:/PRICOL/FM.DVB") (VLVBARUN "FM")

    )

    ___________________________________________________________________________________________________________________________________________________________________________________________________________

    (defun c:CF(/ ss l sset str e); FEET CHECK AND CONVERT IN MM TO FEET

    (COMMAND "lunits" 2)

    (COMMAND "luprec" 0)

    (SETQ

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

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

    Page 34

  • PRICOL

    DI(DISTANCE P1 P2 )

    ; fi(fix di)

    CV(CVUNIT DI "MILLIMETER" "FOOT")

    TE(RTOS (FIX DI))

    P2(GETPOINT "\n PICK VER FIRST POINT :")

    P3(GETPOINT P2 "\n PICK VER SECOND POINT :")

    DI1(DISTANCE P2 P3 )

    ; fi(fix di)

    CV1(CVUNIT DI1 "MILLIMETER" "FOOT")

    TE1(RTOS (FIX DI1))

    )

    (alert (strcat (RTOS (* 12 CV) 3 0) " ""x "" " (RTOS (* 12 CV1) 3 0) "\n" "\n" (rtos di) " ""x "" "(rtos di1) "" "MM" ))

    (if (setq ss (ssget "_:L" ((0 . "TEXT,MTEXT")))) (repeat (setq l (sslength ss)) (setq sset (ssname ss (setq l (1 l)))) (setq str (cdr (assoc 1 (setq e (entget sset))))) (entupd (cdr (assoc 1 (entmod (subst (cons 1 (strcat (RTOS (* 12 CV) 3 0) " ""x"" " (RTOS (* 12 CV1) 3 0))) (assoc 1 e)e)) ) ) ) ) (princ) ) (princ) (COMMAND "luprec" 2)

    Page 35

  • PRICOL

    (VLVBALOAD "D:/PRICOL/FM.DVB") (VLVBARUN "FM")

    )

    ___________________________________________________________________________________________________________________________________________________________________________________________________________

    (DEFUN C:FTC()

    (VLVBALOAD "D:/PRICOL/FM.DVB") (VLVBARUN "FM")

    ) ___________________________________________________________________________________________________________________________________________________ (DEFUN C:0() (COMMAND "LAYOFF" PAUSE)

    )

    _____________________________________________________________________________________________________________________________________________

    (defun c:eq()

    (setq ent (car (entsel "\nSelect Dimension: ")) entlist (entget ent) newtext "eq" entlist (subst (cons 1 newtext) (assoc 1 entlist) entlist) );setq (entmod entlist)

    )

    _________________________________________________________________________________________________________________________________________________

    (DEFUN C:CMO()

    (SETQ

    LN(GETSTRING "\n ENTER LAYER NAME:")

    AS(GETINT"\n ENTER CLOUD SIZE:")

    )

    (REPEAT 10

    (SETQ

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

    P2(GETCORNER P1 "\n PICK FIRST CORNER :")

    )

    Page 36

  • PRICOL (COMMAND "LAYER" "N" LN "CO" "RED" LN "")

    (COMMAND "LAYER" "S" LN "")

    (COMMAND "RECTANGLE" P1 P2 )(SETQ OBJ1(ENTLAST))

    (COMMAND "REVCLOUD" "A" AS AS "O" OBJ1 "")

    (SETQ

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

    P4(GETPOINT P3 "\n PICK SECOND POINT :")

    P5(GETPOINT P4 "\n PICK THIRD POINT :")

    )

    (SETQ

    JJ(getvar CLAYER)

    )

    (COMMAND "PLINE" P3 P4 P5 "")

    (COMMAND "TEXT" P4 (/ AS 2) 0 JJ "")

    )

    )

    ______________________________________________________________________________________________________________________________________________________________________________________________________________

    (defun c:DLP( / confirm ) (princ "\nCaution: this will delete all layouts and data contained in layouts. ") (initget 1 "Y N ") (setq confirm (getkword "\nProceed? [Yes/No] : ")) (if (or (= confirm "") (= confirm "Y")) (vlaxfor x (vlagetlayouts (vlagetactivedocument (vlaxgetacadobject))) (if (/= "Model" (vlagetname x)) (vladelete x) ) ) (princ "\nLayouts were not deleted. ") )

    (princ)(REPEAT 100 (command "PURGE" "A" "*" "N")

    )

    )_________________________________________________________________________________________________________________________________________________________________________________________________________________

    (DEFUN C:KK()

    Page 37

  • PRICOL

    (startapp "C:/AutoLisp/convert.exe")

    )

    ___________________________________________________________________________________________________________________________________________________________________________________________________________

    ;; DimPoly.lsp [command names: DPI, DPO]

    ;; To dimension the lengths of all segments of a Polyline on the Inboard or Outboard;; side; for selfintersecting or open Polyline without a clear "inside" and "outside,";; will determine a side if not as desired, undo and run other command.;; Dimensions along arc segments will be angular Dimensions, showing length of arc;; as text override, not included angle native to angular Dimensions. They will not;; update if Polyline is stretched, as those along line segments will; redo DPI/DPO.;; Uses current Dimension and Units settings; dimension line location distance from;; Polyline segment = 1.5 x dimension text height for stacked fractions to clear [see;; commentary at setting of dimtxt variable re: stacked fractions].;; Accepts LW and 2D "heavy" Polylines, but not 3D Polylines or meshes.;; Kent Cooper, last edited 17 March 2014

    (vlloadcom)

    (defun DP (side / *error* clay osm cmde styht plsel pl cw inc pt1 pt3 pt2 ang1 ang2 dimtxt pt4)

    (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break")) (princ (strcat "\nError: " errmsg)) ); if (setvar clayer clay) (setvar osmode osm) (command "_.undo" "_end") (setvar cmdecho cmde) (princ) ); defun *error*

    (setq clay (getvar clayer) osm (getvar osmode) cmde (getvar cmdecho)) (setvar cmdecho 0) (setvar osmode 0) (command "_.undo" "_begin" "_.layer" "_make" "AANNODIMS" "_color" 2 "" "" ;; vlaobject (car plsel))) (vlaoffset pl styht); temporary (setq cw (< (vlagetarea (vlaxename>vlaobject (entlast))) (vlagetarea pl))) ;; clockwise for closed or clearly inside/outside open; may not give ;; desired result for open without obvious inside/outside

    Page 38

  • PRICOL (entdel (entlast)) (repeat (setq inc (fix (vlaxcurvegetEndParam pl))) (setq pt1 (vlaxcurvegetPointAtParam pl inc) pt3 (vlaxcurvegetPointAtParam pl (1 inc)) ); setq (if (not (equal pt1 pt3 1e8)); not coincident vertices (progn ; then proceed to dimension segment (setq pt2 (vlaxcurvegetPointAtParam pl ( inc 0.5)); segment midpoint ang1 (angle pt1 pt2) ang2 (angle pt2 pt3) ); setq (if (or ; line segment? (equal ang1 ang2 1e8); any non0 direction or both reading as 0 or 2 pi (equal (abs ( ang2 ang1)) (* pi 2) 1e8); 0degree with one reading as 2 pi +/ ); or (command "_.dimaligned" pt1 pt3); then [leaves at dimension line location prompt] (progn ; else [arc segment] (setq dimtxt (rtos (abs ; length along arc segment ( (vlaxcurvegetDistAtParam pl inc) (vlaxcurvegetDistAtParam pl (1 inc))) ); abs ;; [include mode/precision here if current dimension styles settings not desired] ); rtos ); setq (if (wcmatch dimtxt "*/*"); includes fraction? ;; can omit this entire (if) function if you dont use stacked fractions (setq dimtxt ; stack it (strcat "\\A1;" (vlstringsubst ";}\"" "\""; (vlstringsubst "#" "/" ;; remove ; from beginning of above line and its closing parenthesis ;; below to make diagonal stack [makes horizontalline stack without] (vlstringsubst "{\\H0.875x;\\S" " " dimtxt) ;; change 0.875 ratio to agree with Dimension Styles setting; ); subst ); subst ); strcat & dimtxt ); setq ); if (command "_.dimangular" "" (inters ; arc center (setq pt4 (mapcar / (mapcar + pt1 pt2) (2 2 2))) (polar pt4 (+ (angle pt1 pt2) (/ pi 2)) 1) (setq pt4 (mapcar / (mapcar + pt2 pt3) (2 2 2))) (polar pt4 (+ (angle pt2 pt3) (/ pi 2)) 1) nil ); inters pt1 pt3 "_text" dimtxt ); command [leaves at dimension line location prompt] ); progn ); if (command ; complete Dimension: dimension line location (polar pt2 (apply ; angle (if (or (and cw (= side "in")) (and (not cw) (= side "out"))) +) (list

    Page 39

  • PRICOL (angle (0 0 0) (vlaxcurvegetFirstDeriv pl ( inc 0.5))) (/ pi 2) ); list ); apply (* styht 1.5); distance ;; [If you dont use stacked fractions, consider using styht without multiplier] ); polar ); command ); progn ); if [not coincident] (setq inc (1 inc)) ); repeat (setvar clayer clay) (setvar osmode osm) (command "_.undo" "_end") (setvar cmdecho cmde) (princ)); defun DP

    (defun C:DPI () (DP "in")); = Dimension Polyline Inside(defun C:DPO () (DP "out")); = Dimension Polyline Outside

    (prompt "\nType DPI to Dimension a Polyline on the Inside, DPO to do so on the Outside.")

    _______________________________________________________________________________________________________________________________________________________________________________________________________________

    ;; By Joe Burke

    ;; What does CC2 do which ExpressTools extrim, AKA CookieCutter, doesnt?;; Works with blocks, hatches and regions by exploding them.;; Other object types which cannot be trimmed are left intact.;; Works with objects which do not use a Continuous linetype.;; Offers an option to delete all objects on visible layers either;; inside or outside the selected trim object.

    ;; The interface is similar to extrim.

    ;; First extrim prompt: ;; Pick a POLYLINE, LINE, CIRCLE, ARC, ELLIPSE, IMAGE or TEXT for cutting edge...;; Select objects:;; Confusing because the routine does not allow multiple object selection.;; Plus it works with some object types not mentioned, like splines.

    ;; First CookieCutter2 prompt:;; Select circle or closed polyline, ellipse or spline for trimming edge:;; The object must be closed or appear to be closed.

    ;; Second extrim prompt:;; Specify the side to trim on:

    ;; Second CookieCutter2 prompt:;; Pick point on side to trim:

    ;; Third CookieCutter2 prompt:;; One of the following depending on whether the point picked is inside;; or outside the trim object.;; Erase all objects inside? [Yes/No] :;; Erase all objects outside? [Yes/No] :;; If Yes, all objects on visible layers are erased. If No it behaves;; like extrim.

    Page 40

  • PRICOL;; Both CC2 and extrim only operate on objects on visible layers.

    ;; The routine will display an additional prompt if one or more solid ;; hatches intersects the trim object.;; Convert solid hatch to lines? [Yes/No] :;; If Yes, solid hatches are converted to lines using the ANSI31 pattern ;; and the lines are trimmed. If No, solid hatches are not trimmed.

    ;; Miscellaneous Notes:

    ;; The routine may be used to simply erase all objects inside or ;; outside the trim object.

    ;; The routine does not trim annotation objects such as text, mtext,;; dimensions, leaders, mleaders and tables. The user may choose to ;; explode some of these objects types before running the routine.

    ;; It ignores xrefs. Bind xrefs beforehand if those block objects ;; should be trimmed.

    ;; Some cleanup may be needed after the routine ends.

    ;; The routine offsets the selected trim object inside or outside in;; order to determine trim points. The offset distance is a variable ;; which depends on the size if the trim object. Likewise, if solid;; hatches are converted to lines, the scale of the ANSI31 pattern ;; depends on the same variable.

    ;; The routine will end (exit) if offset fails or offset creates more;; than one new object. Message at the command line:;; "Problem detected with selected object. Try another. Exiting... "

    ;; Selfintersecting trim objects are not allowed. The select object;; part of the routine checks for this and cycles if a selfintersecting;; object is selected.

    (defun c:CookieCutter2 ( / *error* *acad* doc ps osm as om emode pmode offd elev locked typ typlst e d notclosed splinetyp i o intpts lst sc minpt maxpt hidelst dellst offsetename offsetobj trimename trimobj curcoord mark postlst coord reg selfinter ext UCSpkpt UCStrimobjpts WCStrimobjpts delother side ssinside ssall sscross ssoutside ssintersect solidflag solidans solidlst CC:GetScreenCoords CC:TraceObject CC:GetInters CC:SpinBar CC:AfterEnt CC:CommandExplode CC:ExpNestedBlock CC:FirstLastPts CC:GetBlock CC:AttributesToText CC:UniformScale CC:SSVLAList CC:Inside CC:UnlockLayers CC:RelockLayers CC:ZoomToPointList Extents)

    (defun *error* (msg) (cond ((not msg)) ((wcmatch (strcase msg) "*QUIT*,*CANCEL*")) (T (princ (strcat "\nError: " msg))) ) (setvar "pickstyle" ps) (setvar "osmode" osm) (setvar "autosnap" as) (setvar "edgemode" emode) (setvar "projmode" pmode) (setvar "orthomode" om) (setvar "elevation" elev) (setvar "offsetdist" offd)

    Page 41

  • PRICOL (setvar "cmdecho" 1) (if (and offsetobj (not (vlaxerasedp offsetobj))) (vladelete offsetobj) ) (foreach x hidelst (if (not (vlaxerasedp x)) (vlaxput x Visible acTrue) ) ) (if (and trimobj (not (vlaxerasedp trimobj))) (vlahighlight trimobj acFalse) ) (CC:RelockLayers locked) (vlaEndUndoMark doc) (princ) ) ;end error

    ;;;; START SUBFUNCTIONS ;;;; ;; by Tony Tanzillo ;; Returns the lower left and upper right corners of a point list. (defun Extents (plist) (list (apply mapcar (cons min plist)) (apply mapcar (cons max plist)) ) ) ;end

    ;; Argument: WCS point list. ;; In lieu of (command "zoom" "object"...) which requires 2005 or later. (defun CC:ZoomToPointList (pts) (setq pts (Extents pts)) (vlaxinvoke *acad* ZoomWindow (car pts) (cadr pts)) (vlaxinvoke *acad* ZoomScaled 0.85 acZoomScaledRelative) ) ;end

    ;; Unlock any locked layers in the active file. ;; Returns a list of unlocked layers if any. (defun CC:UnlockLayers (doc / laylst) (vlaxfor x (vlagetLayers doc) ;filter out xref layers (if (and (not (vlstringsearch "|" (vlaxget x Name))) (eq :vlaxtrue (vlagetlock x)) ) (progn (setq laylst (cons x laylst)) (vlaputlock x :vlaxfalse) ) ) ) laylst ) ;end

    ;; Argument: a list of layer objects from CC:UnlockLayers. (defun CC:RelockLayers (lst) (foreach x lst (vlcatchallapply vlaputlock (list x :vlaxtrue)) ) ) ;end

    ;Returns the coordinates of the current view, lower left and upper right. ;Works in a rotated view.

    Page 42

  • PRICOL (defun CC:GetScreenCoords ( / ViwCen ViwDim ViwSiz VptMin VptMax) (setq ViwSiz (/ (getvar "VIEWSIZE") 2.0) ViwCen (getvar "VIEWCTR") ViwDim (list (* ViwSiz (apply / (getvar "SCREENSIZE"))) ViwSiz ) VptMin (mapcar ViwCen ViwDim) VptMax (mapcar + ViwCen ViwDim) ) (list VptMin VptMax) ) ;end

    ;; By John Uhden. Return T if point is inside point list. ;; Check how many intersections found with an "infinite" line (like a ray). ;; If the number intersections is odd, point is inside. ;; If the number intersections is even, point is outside. (defun CC:Inside (p ptlist / p2 i n #) ;; define a point at a sufficiently large distance from p... (setq p2 (polar p 0.0 (distance (getvar "extmin")(getvar "extmax")))) ;; Make sure the ptlist is closed... (if (not (equal (car ptlist) (last ptlist) 1e10)) (setq ptlist (append ptlist (list (car ptlist)))) ) (setq i 0 # 0 n (1 (length ptlist))) (while (< i n) (if (inters p p2 (nth i ptlist)(nth (1+ i) ptlist)) (setq # (1+ #)) ) (setq i (1+ i)) ) (not (zerop (rem # 2))) ) ; end CC:Inside

    ;Argument: selection set. ;Returns: list of VLA objects. (defun CC:SSVLAList (ss / obj lst i) (setq i 0) (if ss (repeat (sslength ss) (setq obj (vlaxename>vlaobject (ssname ss i)) lst (cons obj lst) i (1+ i) ) ) ) (reverse lst) ) ;end

    ;; Returns a list of primary enames after ename ent. ;; Filter out subentities and entities not in current space. (defun CC:AfterEnt (ent / lst entlst) (while (setq ent (entnext ent)) (setq entlst (entget ent)) (if (and (not (wcmatch (cdr (assoc 0 entlst)) "ATTRIB,VERTEX,SEQEND")) (eq (cdr (assoc 410 entlst)) (getvar "ctab")) ) (setq lst (cons ent lst)) ) ) (reverse lst) ) ;end

    Page 43

  • PRICOL

    (defun CC:SpinBar (sbar) (cond ((= sbar "\\") "|") ((= sbar "|") "/") ((= sbar "/") "") (t "\\") ) ) ;end

    (defun CC:TraceObject (obj / typlst typ ZZeroList TracePline TraceCE TraceSpline)

    ;;;; start trace subfunctions ;;;;

    ;; Argument: 2D or 3D point list. ;; Returns: 3D point list with zero Z values. (defun ZZeroList (lst) (mapcar (lambda (p) (list (car p) (cadr p) 0.0)) lst) )

    ;; Argument: vlaobject, a heavy or lightweight pline. ;; Returns: WCS point list if successful. ;; Notes: Duplicate adjacent points are removed. ;; The last closing point is included given a closed pline. (defun TracePline (obj / param endparam anginc tparam pt blg ptlst delta inc arcparam flag)

    (setq param (vlaxcurvegetStartParam obj) endparam (vlaxcurvegetEndParam obj) ;anginc (* pi (/ 7.5 180.0)) ;;;; note 7.5 here