You are on page 1of 56

;;; AreaText.LSP ver 3.

0
;;; Command name is AT ;;; Q: How can I change the title bar to say AutoCAD instead of Architectural
;;; Select a polyline and where to place the text Desktop?
;;; Sample result: 2888.89 SQ. FT. ;;; A: Download JTB_TitleBar 2005.dvb and you can call it like the example below.
;;; As this is a FIELD it is updated based on the FIELDEVAL ;;; Change the path as where JTB_TitleBar.dvb is placed.
;;; or the settings found in the OPTIONS dialog box ;;; To make it fun you might even make it AutoCAD 2003 or whatever you want.

;;; By Jimmy Bergmark (defun c:JTB_SetTitleBarAutoCAD2005()


;;; Copyright (C) 2007-2010 JTB World, All Rights Reserved (vl-load-com)
;;; Website: www.jtbworld.com (setq JTB_TitleBar "AutoCAD 2005")
;;; E-mail: info@jtbworld.com (vl-vbarun "C:/Program Files/jtbworld/JTB_TitleBar2005.dvb!JTB_TitleBar")
;;; 2007-09-05 - First release (princ)
;;; 2009-08-02 - Updated to work in both modelspace and paperspace )
;;; 2010-10-29 - Updated to work also on 64-bit AutoCAD
(defun c:JTB_SetTitleBarRevitADT2005()
;;; Uses TEXTSIZE for the text height (vl-load-com)
(setq JTB_TitleBar "Revit-ADT 2005")
(defun Get-ObjectIDx64 (obj / util) (vl-vbarun "C:/Program Files/jtbworld/JTB_TitleBar2005.dvb!JTB_TitleBar")
(setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object)))) (princ)
(if (= (type obj) 'ENAME)(setq obj (vlax-ename->vla-object obj))) )
(if (= (type obj) 'VLA-OBJECT) ;;; Layer and lineweight list to drawing
(if (> (vl-string-search "x64" (getvar "platform")) 0) ;;;
(vlax-invoke-method util "GetObjectIdString" obj :vlax-False) ;;; By Jimmy Bergmark
(rtos (vla-get-objectid obj) 2 0) ;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
) ;;; Website: www.jtbworld.com
) ;;; E-mail: info@jtbworld.com
) ;;; 2000-06-27
;;;
(defun c:AT (/ entObject entObjectID InsertionPoint ad) (vl-load-com)
(vl-load-com) (defun ax:layer-lw-list (/ layer lw lst)
(setq entObject (vlax-ename->vla-object(car (entsel))) (vlax-for layer (vla-get-Layers
entObjectID (Get-ObjectIDx64 entObject) (vla-get-ActiveDocument
InsertionPoint (vlax-3D-Point (getpoint "Select point: ")) (vlax-get-acad-object)
ad (vla-get-ActiveDocument (vlax-get-acad-object)) )
) )
(vla-addMText (if (= 1 (vla-get-activespace ad)) (setq lw (vla-get-lineweight layer))
(vla-get-modelspace ad) (if (= lw -3)
(if (= (vla-get-mspace ad) :vlax-true) (setq lw 0.25 lwt "Default")
(vla-get-modelspace ad) (setq lw (/ lw 100.0) lwt (strcat (rtos lw 2 2) " mm"))
(vla-get-paperspace ad) )
) (setq lst (cons
) (list
InsertionPoint 0.0 (strcat (vla-get-name layer)
"%<\\AcObjProp Object(%<\\_ObjId " lw
entObjectID lwt
">%).Area \\f \"%pr2%lu2%ct4%qf1 SQ. FT.\">%" ) lst))
)) )
) (vl-sort lst
(function (lambda (e1 e2)
;;;---------------------------------------------------------------------------; (< (strcase (car e1)) (strcase (car e2)))
;;; )
;;; accdist.lsp )
;;; )
;;; By Jimmy Bergmark )
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
;;; Website: www.jtbworld.com (defun c:layer-lw-list (/ p row y ts xd plinewidold)
;;; E-mail: info@jtbworld.com (setq p (getpoint "Specify top left point of list: "))
;;; (setq ts (getvar "textsize"))
;;; 1999-06-12 - First release (setq y (cadr p))
;;; 2000-05-11 - Fixed for AutoCAD 2000 (setq xd (* ts 15)) ; dist between columns
;;; should be working on older versions too. (setq plinewidold (getvar "PLINEWID"))
;;; (if p
;;;---------------------------------------------------------------------------; (foreach row (ax:layer-lw-list)
;;; Methods to accumulate distances (command "text" p "" "" (car row))
;;; c:accdist - combined (setvar "PLINEWID" (* (/ ts 2.11) (cadr row)))
;;; c:accdist1 - accumulate distances from first point to next point (command "pline"
;;; c:accdist2 - accumulate distances from first point to second point (list (+ (car p) (* 0.9 xd)) (+ (cadr p) (/ ts 2.0)) (caddr p))
;;;---------------------------------------------------------------------------; (list (+ (car p) (* 0.98 xd)) (+ (cadr p) (/ ts 2.0)) (caddr p))
""
(defun c:accdist (/ errexit undox restore *error* p1 p2 sum) )
(defun errexit (s) (command "text" (list (+ (car p) xd) (cadr p) (caddr p)) "" "" (caddr row))
(princ) (setq y (- y (* ts 1.66667)))
(restore) (setq p (list (car p) y (caddr p)))
) )
)
(defun undox () (setvar "PLINEWID" plinewidold)
(redraw) (princ)
(setq *error* olderr) )
(princ)
)

(setq olderr *error* ;;;---------------------------------------------------------------------------;


restore undox ;;;
*error* errexit ;;; layers-erase.lsp
) ;;;
(setq p1 (getpoint "\nSpecify first point: ") ;;; By Jimmy Bergmark
p2 "First" ;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
sum 0 ;;; Website: www.jtbworld.com
) ;;; E-mail: info@jtbworld.com
(while (and p1 p2) ;;;
(if (= p2 "First") ;;; 2000-05-25 - First release
(progn ;;; Tested on AutoCAD 2000
(initget 32) ;;;
(setq p2 (getpoint "\nSpecify next point: " p1)) ;;;---------------------------------------------------------------------------;
) ;;; DESCRIPTION
(progn ;;;
(initget 32 "First") ;;; c:layers-erase - Erase all layers that are frozen or off
(setq p2 (getpoint "\nSpecify next point or [First]: " p1)) ;;;---------------------------------------------------------------------------;
) (vl-load-com)
) (defun c:layers-erase ()
(cond (defun layer-del (layer / ss e d c f doc la)
((not p2)) (if (setq e (tblobjname "layer" layer))
((= p2 "First") (progn
(setq p1 (getpoint "\nSpecify first point: ")) (setq
) d (entget e)
(t c (cdr (assoc 62 d))
(grdraw p1 p2 -1 1) f (cdr (assoc 70 d))
(setq sum (+ sum (distance p1 p2)) del nil
p1 p2 )
) (if (minusp c)
) ; layer is off, force abs of color
) (progn (setq del T)
) (setq d (subst (cons 62 (abs c)) (assoc 62 d) d))
(princ "\nAccumulated distance = ") )
(princ sum) )
(restore) (if (eq 1 (logand 1 f))
) ; layer is frozen, mask off 1
(progn (setq del T)
(defun c:accdist1 (/ p1 p2 sum) (setq f (boole 6 f 1))
(setq sum 0) )
(setq p1 (getpoint "\nSpecify first point: ")) )
(while (and p1 (if (eq 4 (logand 4 f))
(not (initget 32)) ; layer is locked, mask off 4
(setq p2 (getpoint "\nSpecify next point: " p1)) (setq f (boole 6 f 4))
) )
(grdraw p1 p2 -1 1) ; did we change the flag value?
(setq sum (+ sum (distance p1 p2))) (if (not (eq f (cdr (assoc 70 d))))
(setq p1 p2) (setq d (subst (cons 70 f) (assoc 70 d) d))
) )
(redraw) ; did we change the dxf data at all?
(princ "\nAccumulated distance = ") (if (not (equal d (entget e)))
(princ sum) (entmod d)
(princ) )
) (if del
(progn
(defun c:accdist2 (/ p1 p2 sum) (setq ss (ssget "X" (list (cons 8 layer)))
(setq sum 0) doc (vla-get-activedocument (vlax-get-acad-object))
(while c -1
(and (setq p1 (getpoint "\nSpecify first point: ")) )
(not (initget 32)) (vla-put-activeLayer
(setq p2 (getpoint "\nSpecify second point: " p1)) doc
) (vla-item (vla-get-layers doc) "0")
(setq sum (+ sum (distance p1 p2))) )
) (if ss
(princ "\nAccumulated distance = ") (repeat (sslength ss)
(princ sum) (vla-erase
(princ) (vlax-ename->vla-object (ssname ss (setq c (1+ c))))
) )
)
)
;;; purge the layer
;;; Read and write the settings that AecExportToAutoCAD and the like command (vl-catch-all-apply
uses 'vla-delete
;;; The effect of writing this settings is directly affecting the commands. (list (vla-item (vla-get-layers doc) layer))
;;; By Jimmy Bergmark )
;;; www.jtbworld.com ;;; if not purged freeze it again
;;; For ADT 2004 (if (setq e (tblobjname "layer" layer))
(command "._layer" "_f" layer "")
;;; Reads the settings that AecExportToAutoCAD and the like command uses )
;;; Bind xrefs or not when exporting )
;;; (0 = no bind, 1 = bind) )
;;; (readAecGuiBase40 "ExportExplodedToAutoCADBindXrefs") )
;;; Bind method when xrefs are bound when exporting )
;;; (0 = Bind method, 1 = Insert method) )
;;; (readAecGuiBase40 "ExportExplodedToAutoCADInsertWhenBinding") (setq ss nil)
;;; File prefix used when exporting (vlax-for la (vla-get-layers
;;; (readAecGuiBase40 "ExportExplodedToAutoCADFilePrefix") (vla-get-activedocument (vlax-get-acad-object))
;;; File suffix used when exporting )
;;; (readAecGuiBase40 "ExportExplodedToAutoCADFileSuffix") (layer-del (vla-get-name la))
(vl-load-com) )
(defun readAecGuiBase40 (keyname) ) ;;; List layers according to state
(vl-registry-read ;;;
(strcat ;;; By Jimmy Bergmark
"HKEY_CURRENT_USER\\" ;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
(vlax-product-key) ;;; Website: www.jtbworld.com
"\\Profiles\\" ;;; E-mail: info@jtbworld.com
(vla-get-activeprofile ;;; 2000-05-15
(vla-get-profiles ;;;
(vla-get-preferences (vlax-get-acad-object)) ;;; Argument: state
) ;;; 1 frozen
) ;;; 2 thawed
"\\Preferences\\AecGuiBase40" ;;; 3 on
) ;;; 4 off
keyname ;;; 5 lock
) ;;; 6 not locked
) ;;; 7 plottable
;;; 8 not plottable
;;; Example: (layer-state 1)
;;; Writes the settings that AecExportToAutoCAD and the like command uses ;;; Return values: list of layers
;;; Bind xrefs or not when exporting (vl-load-com)
;;; (0 = no bind, 1 = bind) (defun layer-state (state / typ names tf skip)
;;; (writeAecGuiBase40 "ExportExplodedToAutoCADBindXrefs" 1) (setq names nil)
;;; Bind method when xrefs are bound when exporting (vlax-for layer (vla-get-Layers
;;; (0 = Bind method, 1 = Insert method) (vla-get-ActiveDocument
;;; (writeAecGuiBase40 "ExportExplodedToAutoCADInsertWhenBinding" 1) (vlax-get-acad-object)
;;; Set the file prefix used when exporting )
;;; (writeAecGuiBase40 "ExportExplodedToAutoCADFilePrefix" "") )
;;; Set the file suffix used when exporting (setq skip nil)
;;; (writeAecGuiBase40 "ExportExplodedToAutoCADFileSuffix" "-ACAD- (cond
EXPORT") ((= 1 state) (setq typ (vla-get-freeze layer) tf :vlax-true))
((= 2 state) (setq typ (vla-get-freeze layer) tf :vlax-false))
((= 3 state) (setq typ (vla-get-layeron layer) tf :vlax-true))
(defun writeAecGuiBase40 (keyname n) ((= 4 state) (setq typ (vla-get-layeron layer) tf :vlax-false))
(vl-registry-write ((= 5 state) (setq typ (vla-get-lock layer) tf :vlax-true))
(strcat ((= 6 state) (setq typ (vla-get-lock layer) tf :vlax-false))
"HKEY_CURRENT_USER\\" ((= 7 state) (setq typ (vla-get-plottable layer) tf :vlax-true))
(vlax-product-key) ((= 8 state) (setq typ (vla-get-plottable layer) tf :vlax-false))
"\\Profiles\\" (t (setq skip T))
(vla-get-activeprofile )
(vla-get-profiles (if (and (null skip) (eq typ tf))
(vla-get-preferences (vlax-get-acad-object)) (setq names (cons (vla-get-name layer) names))
) )
) )
"\\Preferences\\AecGuiBase40" (reverse names)
) )
keyname
n
)
) ;;; toggle the freeze state of layer
;;; Read and write the settings in the "Explode AEC Objects" dialog box ;;; and regens only the objects on the layer
;;; using the command _AecObjExplode ;;; but if layer is xref dependant it regens
;;; The effect of writing this settings is directly affecting the command. ;;;
;;; By Jimmy Bergmark ;;; By Jimmy Bergmark
;;; www.jtbworld.com ;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
;;; For ADT 2004 ;;; Website: www.jtbworld.com
;;; E-mail: info@jtbworld.com
;;; Reads the settings "Explode to anonymous blocks" ;;; 2000-03-05 - First release
;;; (readAECObjectsExplodeOptions "Anonymous Block") ;;;
;;; 0 = Disable Explode to anonymous blocks ;;; Tested on AutoCAD 2000
;;; 1 = Enable Explode to anonymous blocks ;;; Argument: layer {list of layers}
;;; (readAECObjectsExplodeOptions "Bind Xrefs") ;;; Example: (layer-toggle-freeze '("Layer1" "Layer2"))
;;; 0 = Don't bind xrefs
;;; 1 = Bind xrefs (defun layer-toggle-freeze (layer / en f ss ent i fg)
;;; Others that can be used are: (foreach la layer
;;; (readAECObjectsExplodeOptions "Bind Xrefs Bind Type") (setq en (entget (tblobjname "layer" la)))
;;; (readAECObjectsExplodeOptions "Erase AEC Objects") (setq f (cdr (assoc 70 en)))
;;; (readAECObjectsExplodeOptions "Explode AEC Objects") (setq f (boole 6 f 1))
;;; (readAECObjectsExplodeOptions "Include Model Tab") (if (and (wcmatch la "*|*") (eq 0 (logand 1 f))) (setq rg T))
;;; (readAECObjectsExplodeOptions "Maintain Properties") (setq en (subst (cons 70 f) (assoc 70 en) en))
;;; (readAECObjectsExplodeOptions "Name Length") (entmod en)
;;; (readAECObjectsExplodeOptions "Reuse Existing Names") (setq ss (ssget "X" (list (cons 8 la))))
;;; (readAECObjectsExplodeOptions "Short Block Names") (setq i 0)
;;; (readAECObjectsExplodeOptions "Verbose") (if ss
;;; (readAECObjectsExplodeOptions "Views") (while (setq ent (ssname ss i))
(vl-load-com) (entupd ent)
(defun readAECObjectsExplodeOptions (keyname) (setq i (1+ i))
(vl-registry-read )
(strcat )
"HKEY_CURRENT_USER\\" )
(vlax-product-key) (setq sset nil)
"\\Profiles\\" (if rg (command "._regenall"))
(vla-get-activeprofile (princ)
(vla-get-profiles ) ;;;
(vla-get-preferences (vlax-get-acad-object)) ;;; LayoutsToDwgs.lsp
) ;;; Created 2000-03-27
)
"\\Dialogs\\AecObjExplode40-Options" ;;; By Jimmy Bergmark
) ;;; Copyright (C) 1997-2012 JTB World, All Rights Reserved
keyname ;;; Website: www.jtbworld.com
) ;;; E-mail: info@jtbworld.com
) ;;;
;;; 2003-12-12 Sets UCS to world in model space
;;; to avoid problem with wblock
;;; Writes the settings "Explode to anonymous blocks" ;;; 2011-06-06 Excludes empty layouts
;;; Disable Explode to anonymous blocks ;;; 2012-06-01 Handle Map prompt with WBLOCK
;;; (writeAECObjectsExplodeOptions "Anonymous Block" 0) ;;; Include AutoCAD Map information in the export? [Yes/No] <Y>:
;;; Enable Explode to anonymous blocks ;;; 2013-03-04 Added _ on some commands to internationalize it
;;; (writeAECObjectsExplodeOptions "Anonymous Block" 1) ;;;
;;; Don't bind xrefs ;;; For AutoCAD 2000, 2000i, 2002, 2004, 2005,
;;; (writeAECObjectsExplodeOptions "Bind Xrefs" 0) ;;; 2006, 2007, 2008, 2009, 2011, 2012, 2013 and newer
;;; Bind xrefs ;;;
;;; (writeAECObjectsExplodeOptions "Bind Xrefs" 1) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Others that can be used are: ;;; Creates separate drawings of all layouts.
;;; (writeAECObjectsExplodeOptions "Bind Xrefs Bind Type" 1) ;;; The new drawings are saved to the current drawings path
;;; (writeAECObjectsExplodeOptions "Erase AEC Objects" 1) ;;; and overwrites existing drawings.
;;; (writeAECObjectsExplodeOptions "Explode AEC Objects" 1) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; (writeAECObjectsExplodeOptions "Include Model Tab" 0) (defun c:LayoutsToDwgs (/ errexit undox olderr oldcmdecho fn path
;;; (writeAECObjectsExplodeOptions "Maintain Properties" 0) msg msg2 fileprefix i j)
;;; (writeAECObjectsExplodeOptions "Name Length" 31)
;;; (writeAECObjectsExplodeOptions "Reuse Existing Names" 0) (defun errexit (s)
;;; (writeAECObjectsExplodeOptions "Short Block Names" 1) (princ "\nError: ")
;;; Display status messages (princ s)
;;; (writeAECObjectsExplodeOptions "Verbose" 1) (restore)
;;; (writeAECObjectsExplodeOptions "Views" 0) )
(defun writeAECObjectsExplodeOptions (keyname n)
(vl-registry-write (defun undox ()
(strcat (command "._undo" "_E")
"HKEY_CURRENT_USER\\" (setvar "cmdecho" oldcmdecho)
(vlax-product-key) (setq *error* olderr)
"\\Profiles\\" (princ)
(vla-get-activeprofile )
(vla-get-profiles
(vla-get-preferences (vlax-get-acad-object)) (setq olderr *error*
) restore undox
) *error* errexit
"\\Dialogs\\AecObjExplode40-Options" )
) (setq oldcmdecho (getvar "cmdecho"))
keyname (setvar "cmdecho" 0)
n (defun DelAllLayouts (Keeper / TabName)
) (vlax-for Layout
) (vla-get-Layouts
;;; By Jimmy Bergmark (vla-get-activedocument (vlax-get-acad-object))
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved )
;;; Website: www.jtbworld.com (if
;;; E-mail: info@jtbworld.com (and
;;; (/= (setq TabName (strcase (vla-get-name layout))) "MODEL")
;;; returns the area of selected object (/= TabName (strcase Keeper))
;;; Made for AutoCAD 2000 )
(defun c:areaOfObject (/ en curve area) (vla-delete layout)
(if (setq en (entsel)) )
(progn )
(setq curve (vlax-ename->vla-object (car en))) )
(if
(vl-catch-all-error-p (vl-load-com)
(setq (setq msg "" msg2 "" i 0 j 0)
area (vl-catch-all-apply 'vlax-curve-getArea (list curve)) (command "._undo" "_BE")
) (setq fileprefix (getstring "Enter filename prefix: "))
) (foreach lay (layoutlist)
nil (if (and (/= lay "Model") (> (vla-get-count (vla-get-block (vla-Item (vla-get-Layouts
area (vla-get-activedocument (vlax-get-acad-object))) lay))) 1))
) (progn
) (command "_.undo" "_M")
) (DelAllLayouts lay)
) (setvar "tilemode" 1)
(command "_.ucs" "_w")
(setvar "tilemode" 0)
;;; AreaText.LSP ver 3.0 (setq path (getvar "DWGPREFIX"))
;;; Command name is AT (setq fn (strcat path fileprefix lay ".dwg"))
;;; Select a polyline and where to place the text (if (findfile fn)
;;; Sample result: 2888.89 SQ. FT. (progn
;;; As this is a FIELD it is updated based on the FIELDEVAL (command "_.-wblock" fn "_Y")
;;; or the settings found in the OPTIONS dialog box (if (equal 1 (logand 1 (getvar "cmdactive")))
(progn
;;; By Jimmy Bergmark (setq i (1+ i) msg (strcat msg "\n" fn))
;;; Copyright (C) 2007-2010 JTB World, All Rights Reserved (command "*")
;;; Website: www.jtbworld.com )
;;; E-mail: info@jtbworld.com (setq j (1+ j) msg2 (strcat msg2 "\n" fn))
;;; 2007-09-05 - First release )
;;; 2009-08-02 - Updated to work in both modelspace and paperspace )
;;; 2010-10-29 - Updated to work also on 64-bit AutoCAD (progn
(command "_.-wblock" fn "*")
;;; Uses TEXTSIZE for the text height (setq i (1+ i) msg (strcat msg "\n" fn))
)
(defun Get-ObjectIDx64 (obj / util) )
(setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object)))) (if (equal 1 (logand 1 (getvar "cmdactive")))
(if (= (type obj) 'ENAME)(setq obj (vlax-ename->vla-object obj))) (command "_N")
(if (= (type obj) 'VLA-OBJECT) )
(if (> (vl-string-search "x64" (getvar "platform")) 0) (command "_.undo" "_B")
(vlax-invoke-method util "GetObjectIdString" obj :vlax-False) )
(rtos (vla-get-objectid obj) 2 0) )
) )
) (if (/= msg "")
) (progn
(if (= i 1)
(defun c:AT (/ entObject entObjectID InsertionPoint ad) (prompt "\nFollowing drawing was created:")
(vl-load-com) (prompt "\nFollowing drawings were created:")
(setq entObject (vlax-ename->vla-object(car (entsel))) )
entObjectID (Get-ObjectIDx64 entObject) (prompt msg)
InsertionPoint (vlax-3D-Point (getpoint "Select point: ")) )
ad (vla-get-ActiveDocument (vlax-get-acad-object)) )
) (if (/= msg2 "")
(vla-addMText (if (= 1 (vla-get-activespace ad)) (progn
(vla-get-modelspace ad) (if (= j 1)
(if (= (vla-get-mspace ad) :vlax-true) (prompt "\nFollowing drawing was NOT created:")
(vla-get-modelspace ad) (prompt "\nFollowing drawings were NOT created:")
(vla-get-paperspace ad) )
) (prompt msg2)
) )
InsertionPoint 0.0 (strcat )
"%<\\AcObjProp Object(%<\\_ObjId " (command "._undo" "_E")
entObjectID (textscr)
">%).Area \\f \"%pr2%lu2%ct4%qf1 SQ. FT.\">%" (restore)
)) (princ)
) )
;;; By Jimmy Bergmark (princ)
;;; Copyright (C) 2008 JTB World, All Rights Reserved ;;; By Jimmy Bergmark
;;; Website: www.jtbworld.com ;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
;;; E-mail: info@jtbworld.com ;;; Website: www.jtbworld.com
;;; ;;; E-mail: info@jtbworld.com
;;; Created: 2008-03-31 (vl-load-com)
;;; ;;; (loadLinetype (vla-get-activedocument (vlax-get-acad-object)) "Divide"
;;; Convert Attribute definitions to mtext "acadiso.lin")
;;; ;;; returns: T if loaded else nil
(defun loadLinetype (doc LineTypeName FileName)
(defun c:AttDefToMText (/ eset1 blkcnt en enlist tag1 ht pnt vl space) (if (and
(setq eset1 (ssget (list (cons 0 "ATTDEF"))) (not (existLinetype doc LineTypeName))
blkcnt 0 (vl-catch-all-error-p
) (vl-catch-all-apply
'vla-load
(if eset1 (list
(while (<= blkcnt (- (sslength eset1) 1)) (vla-get-Linetypes doc)
(setq en (ssname eset1 blkcnt) LineTypeName
enlist (entget en) FileName
ht (cdr (assoc 40 enlist)) )
pnt (assoc 10 enlist) )
pnt (subst (+ ht (caddr pnt)) (caddr pnt) pnt) )
space (cdr (assoc 67 enlist)) )
) nil
(setq vl (list T
(cons 0 "MTEXT") )
(cons 100 "AcDbEntity") )
(cons 100 "AcDbMText")
(assoc 7 enlist) ;;; (existLinetype (vla-get-activedocument (vlax-get-acad-object)) "Divide")
(assoc 8 enlist) (defun existLinetype (doc LineTypeName / item loaded)
pnt (vlax-for item (vla-get-linetypes doc)
(assoc 40 enlist) (if (= (strcase (vla-get-name item)) (strcase LineTypeName))
(cond ((assoc 62 enlist)) (setq loaded T)
((cons 62 256)) )
) )
(cons 1 (cdr (assoc 2 enlist))) )
(if (= space nil)
(cons 67 0) ;;; (purgeAllLinetypes (vla-get-activedocument (vlax-get-acad-object)))
(cons 67 space) (defun purgeAllLinetypes (doc / item)
) (vlax-for item (vla-get-linetypes doc)
) (vl-catch-all-apply 'vla-delete (list item))
) )
(entdel en) )
(entmake vl)
(setq blkcnt (1+ blkcnt))
) ;;; By Jimmy Bergmark
) ;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
(setq eset1 nil) ;;; Website: www.jtbworld.com
) ;;; E-mail: info@jtbworld.com
;;; By Jimmy Bergmark
;;; Copyright (C) 2008 JTB World, All Rights Reserved ;;; Midpoint of 2 points
;;; Website: www.jtbworld.com (defun c:mpt (/ pt1 pt2)
;;; E-mail: info@jtbworld.com (if (and
;;; (= (getvar "cmdactive") 1)
;;; Created: 2008-03-31 (setq pt1 (getpoint "\nFirst point: "))
;;; (setq pt2 (getpoint pt1 "\nSecond point: "))
;;; Convert Attribute definitions to text )
;;; (command
"_non"
(defun c:AttDefToText (/ eset1 blkcnt en enlist vl space) (list
(setq eset1 (ssget (list (cons 0 "ATTDEF"))) (/ (+ (car pt1) (car pt2)) 2)
blkcnt 0 (/ (+ (cadr pt1) (cadr pt2)) 2)
) (/ (+ (caddr pt1) (caddr pt2)) 2)
)
(if eset1 )
(while (<= blkcnt (- (sslength eset1) 1)) )
(setq en (ssname eset1 blkcnt) (princ)
enlist (entget en) )
space (cdr (assoc 67 enlist))
) ;;; 1/3:rd point of 2 points
(setq vl (list (defun c:3pt (/ pt1 pt2)
(cons 0 "TEXT") (if (and
(cons 100 "AcDbEntity") (= (getvar "cmdactive") 1)
(cons 100 "AcDbText") (setq pt1 (getpoint "\nFirst point: "))
(assoc 7 enlist) (setq pt2 (getpoint pt1 "\nSecond point: "))
(assoc 8 enlist) )
(assoc 10 enlist) (command
(assoc 40 enlist) "_non"
(cond ((assoc 62 enlist)) (list
((cons 62 256)) (+ (/ (- (car pt2) (car pt1)) 3) (car pt1))
) (+ (/ (- (cadr pt2) (cadr pt1)) 3) (cadr pt1))
(cons 1 (cdr (assoc 2 enlist))) (+ (/ (- (caddr pt2) (caddr pt1)) 3) (caddr pt1))
(if (= space nil) )
(cons 67 0) )
(cons 67 space) )
) (princ)
) )
)
(entdel en) ;;; 1/4:th point of 2 points
(entmake vl) (defun c:4pt (/ pt1 pt2)
(setq blkcnt (1+ blkcnt)) (if (and
) (= (getvar "cmdactive") 1)
) (setq pt1 (getpoint "\nFirst point: "))
(setq eset1 nil) (setq pt2 (getpoint pt1 "\nSecond point: "))
) )
;;; By Jimmy Bergmark (command
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved "_non"
;;; Website: www.jtbworld.com (list
;;; E-mail: info@jtbworld.com (+ (/ (- (car pt2) (car pt1)) 4) (car pt1))
;;; (+ (/ (- (cadr pt2) (cadr pt1)) 4) (cadr pt1))
;;; Updated: 2003-02-24 (+ (/ (- (caddr pt2) (caddr pt1)) 4) (caddr pt1))
;;; )
)
;;; (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) )
(princ)
;;; Erases all blocks named "revtext2" )
;;; (ax:EraseBlock doc "revtext2")
(defun ax:EraseBlock (doc bn / layout i) ;;; Midpoint of 3 points
(vlax-for layout (vla-get-layouts doc) (defun c:mpt3 (/ pt1 pt2 pt3)
(vlax-for i (vla-get-block layout) (if (and
(if (and (= (getvar "cmdactive") 1)
(= (vla-get-objectname i) "AcDbBlockReference") (setq pt1 (getpoint "\nFirst point: "))
(= (strcase (vla-get-name i)) (strcase bn)) (setq pt2 (getpoint pt1 "\nSecond point: "))
) (setq pt3 (getpoint pt2 "\nThird point: "))
(vla-Delete i) )
) (command
) "_non"
) (list
) (/ (+ (car pt1) (car pt2) (car pt3)) 3)
(/ (+ (cadr pt1) (cadr pt2) (cadr pt3)) 3)
;;; Test if block named "revtext2" exist (/ (+ (caddr pt1) (caddr pt2) (caddr pt3)) 3)
;;; (ax:ExistBlock doc "revtext2") )
(defun ax:ExistBlock (doc bn / layout i exist) )
(setq exist nil) )
(vlax-for layout (vla-get-layouts doc) (princ)
(vlax-for i (vla-get-block layout) )
(if (and
(= (vla-get-objectname i) "AcDbBlockReference")
(= (strcase (vla-get-name i)) (strcase bn))
) ;;; PageSetup.LSP
(setq exist T) ;;; Miscellaneous routines related to Page Setup
) ;;; By Jimmy Bergmark
) ;;; Copyright (C) 1997-2011 JTB World, All Rights Reserved
) ;;; Website: www.jtbworld.com
exist ;;; E-mail: info@jtbworld.com
) ;;; 2000-04-05 - First release
;;; 2011-02-10 - Second release
;;; Rename block from "revtext" to "revtext1" ;;; Tested on AutoCAD 2000 and AutoCAD 2011
;;; (ax:RenameBlock doc "revtext" "revtext1") (vl-load-com)
(defun ax:RenameBlock (doc bn nn / layout i) ;;; (listPageSetups <AcadDocument>)
(vlax-for layout (vla-get-layouts doc) ;;; (listPageSetups (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for i (vla-get-block layout) (defun listPageSetups (doc / pc)
(if (and (vlax-for pc (vla-get-plotconfigurations doc)
(= (vla-get-objectname i) "AcDbBlockReference") (princ (strcat (vla-get-name pc) "\n"))
(= (strcase (vla-get-name i)) (strcase bn)) )
) (princ)
(vla-put-name i nn) )
)
) ;;; (allPageSetups <AcadDocument>)
) ;;; (allPageSetups (vla-get-activedocument (vlax-get-acad-object)))
) (defun allPageSetups (doc / aps pc)
(vlax-for pc (vla-get-plotconfigurations doc)
;;; a list of all block names (setq aps (cons (vla-get-name pc) aps))
;;; return example ("*D5" "A$C263E5435" "b2" "b1") )
(defun ax:blocks (/ b bn tl) (reverse aps)
(vlax-for b (vla-get-blocks )
(vla-get-ActiveDocument (vlax-get-acad-object))
) ;;; (allPageSetupsAndModelType <AcadDocument>)
(if (= (vla-get-islayout b) :vlax-false) ;;; (allPageSetupsAndModelType (vla-get-activedocument (vlax-get-acad-object)))
(setq tl (cons (vla-get-name b) tl)) (defun allPageSetupsAndModelType (doc / aps pc)
) (vlax-for pc (vla-get-plotconfigurations doc)
) (setq aps (cons (cons (vla-get-name pc)
(reverse tl) (if (= (vla-get-ModelType pc) :vlax-true)
) "Model"
"Layout"
;;; a list of all xref names )
;;; return example ("xref1" "x2") )
(defun ax:xrefs (/ b bn tl) aps
(vlax-for b (vla-get-blocks )
(vla-get-ActiveDocument (vlax-get-acad-object)) )
) )
(if (= (vla-get-isxref b) :vlax-true) (reverse aps)
(setq tl (cons (vla-get-name b) tl)) )
)
) ;;; (allPageSetupsOfModelType <AcadDocument>)
(reverse tl) ;;; (allPageSetupsOfModelType (vla-get-activedocument (vlax-get-acad-object)))
) (defun allPageSetupsOfModelType (doc / aps)
(vlax-for pc (vla-get-plotconfigurations doc)
;;; Returns a list with references to a given block (if (= (vla-get-ModelType pc) :vlax-true)
;;; (blockrefs <block name>) (setq aps (cons (vla-get-name pc) aps))
;;; example: (blockrefs "b1") )
;;; return: (<Entity name: 2ea6290> <Entity name: 2ea6288>) )
;;; tip: if return is nil it's not inserted (vl-sort aps '<)
(defun blockrefs (bn / lst ed) )
(if (setq ed (tblobjname "block" bn))
(setq ;;; (allPageSetupsOfLayoutType <AcadDocument>)
lst (entget ;;; (allPageSetupsOfLayoutType (vla-get-activedocument (vlax-get-acad-object)))
(cdr (assoc 330 (entget ed))) (defun allPageSetupsOfLayoutType (doc / aps)
) (vlax-for pc (vla-get-plotconfigurations doc)
) (if (= (vla-get-ModelType pc) :vlax-false)
) (setq aps (cons (vla-get-name pc) aps))
(apply )
'append )
(mapcar '(lambda (x) (vl-sort aps '<)
(list (cdr x)) )
)
(cdr (reverse (cdr (member (assoc 102 lst) lst)))) ;;; (deleteAllPageSetups <AcadDocument>)
) ;;; (deleteAllPageSetups (vla-get-activedocument (vlax-get-acad-object)))
) (defun deleteAllPageSetups (doc)
) (vlax-for pc (vla-get-plotconfigurations doc)
(vla-delete pc)
;;; Returns a list containing every reference to a given block )
;;; Arguments: a string identifying the block to search for )
(defun listblockrefs (blkName / lst)
(setq lst (entget ;;; (deletePageSetup <AcadDocument> <PageSetupName>)
(cdr (assoc 330 (entget (tblobjname "block" blkName)))) ;;; (deletePageSetup (vla-get-activedocument (vlax-get-acad-object))
) "PageSetupName")
) (defun deletePageSetup (doc name)
(apply (vlax-for pc (vla-get-plotconfigurations doc)
'append (if (= (strcase (vla-get-name pc)) (strcase name))
(mapcar '(lambda (x) (vla-delete pc)
(if (entget (cdr x)) )
(list (cdr x)) )
) )
)
(cdr (reverse (cdr (member (assoc 102 lst) lst)))) ;;; add a new page setup name to current layout-type based on current plot
configuration
)
;;; (addPageSetup <AcadDocument> <PageSetupName>)
)
;;; (addPageSetup (vla-get-activedocument (vlax-get-acad-object))
)
"PageSetupName")
(defun addPageSetup (doc name / space pc lay)
;;; Returns a list containing the entity names of block definitions that reference
(deletePageSetup doc name)
a given block
(if (= (getvar "ctab") "Model")
;;; Arguments: a string identifying the block to search for
(setq space :vlax-true
(defun ax:GetParentBlocks (blkName / doc)
lay (vla-get-Layout (vla-get-ModelSpace
(vl-load-com)
(vla-get-activedocument (vlax-get-acad-object)))))
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq space :vlax-false
(apply
lay (vla-get-ActiveLayout (vla-get-activedocument
'append
(vlax-get-acad-object))))
(mapcar '(lambda (x)
)
(if (= :vlax-false
(setq pc (vla-add
(vla-get-IsLayout
(vla-get-plotconfigurations doc)
(vla-ObjectIdToObject
name
doc
space))
(vla-get-OwnerId (vlax-ename->vla-object x))
(vla-CopyFrom pc lay)
)
(vla-put-name pc name)
)
)
)
(list x)
;;; (getPageSetupName "Model")
)
;;; (getPageSetupName "Layout1")
)
;;; (getPageSetupName (getvar "ctab"))
(listblockrefs blkName)
;;; return value: PageSetupName or nil if Page Setup Name doesn't exist
)
(defun getPageSetupName (layout / laydict psn)
)
(setq dn (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_LAYOUT"))))
)
(setq laydict (dictsearch dn layout))
(setq psn (member '(100 . "AcDbPlotSettings") laydict))
;;; Deletes the specified subentity from its block definition
;;; Arguments: the entity name of an item within a block reference (if (= (caadr psn) 1) ; Page Setup Name exist
;;; Returns: the remaining item count of the block definition (setq psn (cdadr psn))
;;; The drawing must be regenerated for the change to become visible )
(defun ax:DeleteObjectFromBlock (ent / doc blk) )
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object))
ent (vlax-ename->vla-object ent) ;;; (getAllPageSetupName <AcadDocument>)
blk (vla-ObjectIdToObject doc (vla-get-OwnerID ent)) ;;; (getAllPageSetupName (vla-get-activedocument (vlax-get-acad-object)))
) ;;; Example return: (("Model" . "PageSetupName") ("Layout1" . "PPA") ("Layout2"))
(vla-Delete ent) ;;; Layout2 has no page setup name
(vla-get-Count blk) (defun getAllPageSetupName (doc / layoutitem lst)
) (foreach layoutitem (layout-tab-list doc)
(setq lst (cons (cons layoutitem (getPageSetupName layoutitem)) lst))
;;; Adds the specified item to a given block definition )
;;; Arguments: the entity name of a block reference (reverse lst)
;;; a selection set containing the objects to add )
;;; Returns: nil
;;; The drawing must be regenerated for the change to become visible ;; (layout-tab-list <AcadDocument> )
(defun ax:AddObjectsToBlock (blk ss / doc blkref blkdef inspt refpt) ;;
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)) ;; Returns a list of tne names of all
blkref (vlax-ename->vla-object blk) ;; layouts in the specified document,
blkdef (vla-Item (vla-get-Blocks doc) (vla-get-Name blkref)) ;; in ascending tab-order.
inspt (vlax-variant-value (vla-get-InsertionPoint blkref)) ;; TonyT
ssarray (selectionset->array ss) ;; (layout-tab-list (vla-get-activedocument (vlax-get-acad-object)))
refpt (vlax-3d-point '(0 0 0)) (defun layout-tab-list (doc / layouts)
) (mapcar 'vla-get-name
(foreach ent (vlax-safearray->list ssarray) (vl-sort
(vla-Move ent inspt refpt) (vlax-for layout (vla-get-layouts doc)
) (setq layouts (cons layout layouts))
(vla-CopyObjects doc ssarray blkdef) )
(foreach ent (vlax-safearray->list ssarray) '(lambda (a b)
(vla-Delete ent) (< (vla-get-taborder a)
) (vla-get-taborder b)
(princ) )
) )
)
;;; Utility routine to convert a selection set to an ActiveX array )
(defun selectionset->array (ss / c r) )
(vl-load-com)
(setq c -1) ;;; Set a named page setup as current
(repeat (sslength ss) ;;; (setPageSetupName <AcadDocument> <Layout> <PageSetupName>)
(setq r (cons (ssname ss (setq c (1+ c))) r)) ;;; (setPageSetupName (vla-get-activedocument (vlax-get-acad-object)) "Model"
) "PageSetupName")
(setq r (reverse r)) (defun setPageSetupName (doc layout newpsn / pc layoutitem exist1 exist2)
(vlax-safearray-fill (vlax-for layoutitem (vla-get-Layouts doc)
(vlax-make-safearray (if (= (strcase (vla-get-name layoutitem)) (strcase layout))
vlax-vbObject (setq exist1 T)
(cons 0 (1- (length r))) )
) )
(mapcar 'vlax-ename->vla-object r) (if exist1 ; layout exist
) (vlax-for pc (vla-get-plotconfigurations doc)
) (if (and
(= (strcase (vla-get-name pc)) (strcase newpsn))
;;; (ax:GetTagTextString doc "sheet-text" "client-drw") (if (= (strcase layout) "MODEL")
(defun ax:GetTagTextString (doc bn tagname / layout i atts tag str) (= (vla-get-ModelType pc) :vlax-true)
(vlax-for layout (vla-get-layouts doc) (= (vla-get-ModelType pc) :vlax-false)
(vlax-for i (vla-get-block layout) )
(if (and )
(= (vla-get-objectname i) "AcDbBlockReference") (setq exist2 T)
(= (strcase (vla-get-name i)) (strcase bn)) )
) )
(if (and )
(= (vla-get-hasattributes i) :vlax-true) (if exist2 ; page setup name exist for selected model type
(safearray-value (command "._plot" "_n" layout newpsn "" "" "_y" "_n")
(setq atts )
(vlax-variant-value )
(vla-getattributes i)
) ;;; Set a named page setup as current on current layout by avoiding command
) usage
) ;;; (SetCurrentPageSetup <AcadDocument> <PageSetupName>)
) ;;; (SetCurrentPageSetup (vla-get-activedocument (vlax-get-acad-object)) "Setup2")
(foreach tag (vlax-safearray->list atts) (defun SetCurrentPageSetup (doc pcname / layout PlotConfig)
(if (= (strcase tagname) (strcase (vla-get-tagstring tag))) (setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq str (vla-get-TextString tag)) (setq layout (vla-get-activelayout doc))
) (setq PlotConfig (vl-catch-all-apply
) 'vla-item
) (list
) (vla-get-PlotConfigurations
) doc
) )
str pcname
) )
)
;;; (ax:FindBlockTagValue (vla-get-activedocument (vlax-get-acad-object)) )
"blockname" "tagname" "tagvalue") (if (not (vl-catch-all-error-p PlotConfig))
(defun ax:FindBlockTagValue (vla-copyfrom layout PlotConfig)
(doc bn tagname value / layout i atts tag sset c) )
(vlax-for layout (vla-get-layouts doc) )
(vlax-for i (vla-get-block layout)
(if (and ;;; PersonalMtextSymbols.LSP ver 1.1
(= (vla-get-objectname i) "AcDbBlockReference") ;;; Add personal mtext symbols in the right click menu in the mtext editor
(= (strcase (vla-get-name i)) (strcase bn)) ;;; By Jimmy Bergmark
) ;;; Copyright (C) 1997-2008 JTB World, All Rights Reserved
(if (and ;;; Website: www.jtbworld.com
(= (vla-get-hasattributes i) :vlax-true) ;;; E-mail: info@jtbworld.com
(safearray-value ;;; Tested on AutoCAD 2002, 2004, 2005, 2008, 2009. Not sure about 2006. 2007
(setq atts does not support this.
(vlax-variant-value ;;;
(vla-getattributes i) ;;; Remember that you can change the contents to whatever you would like
) ;;; The syntax is:
) ;;; (vl-registry-write key "Name <1,2,3...n>" "<Description>")
) ;;; (vl-registry-write key "Contents <1,2,3...n>" "<Value>")
)
(progn (defun PersonalMtextSymbols ()
(foreach tag (vlax-safearray->list atts) (vl-load-com)
(if (and (setq key (strcat "HKEY_CURRENT_USER\\" (vlax-product-key)
"\\MTEXT\\Symbols"))
(= (strcase tagname)
(vl-registry-write key "Name 1" "Name")
(strcase (vla-get-TagString tag))
(vl-registry-write key "Name 2" "Company")
)
(vl-registry-write key "Contents 1" "Jimmy Bergmark")
(= value (vla-get-TextString tag))
(vl-registry-write key "Contents 2" "JTB World")
)
)
(progn
(if (not sset)
(defun c:PM ()
(setq sset (ssadd (vlax-vla-object->ename i)))
(PersonalMtextSymbols)
(ssadd (vlax-vla-object->ename i) sset)
(princ)
)
)
)
;;; PLJOINFUZZ.LSP
)
;;; Joins lines, arcs and polylines using a fuzz distance
)
;;; If only one object is selected it tries to join to all objects that are possible
)
;;; By Jimmy Bergmark
)
;;; Copyright (C) 2003-2004 JTB World, All Rights Reserved
)
;;; Website: www.jtbworld.com
)
;;; E-mail: info@jtbworld.com
)
;;; Tested on AutoCAD 2002,2004 and 2005
(sssetfirst nil sset)
) ;;; Latest revision made 2004-11-11
;;; Minor code cosmetic change made 2004-11-13
;;; list of all "REV-NO" in block "revtext1" in order of y-coordinate, bottom to up ;;; Bug corrected 2004-12-23
;;; (ax:GetManyTags "revtext1" "REV-NO")
(defun ax:GetManyTags (bn tag / ax lst) (defun c:jf () (c:pljoinfuzz)) ; this line can be commented out if there is an existing
(foreach x (ax:ListBlockIns doc bn) command called jf
(setq lst (cons (ax:GetTagTextStringByRef (cadddr x) tag) lst)) (defun c:pljoinfuzz (/ ss1 entLine objType oldcmdecho oldpeditaccept fuzz
okObjects)
)
(setq oldcmdecho (getvar "cmdecho"))
(reverse lst)
(setq oldpeditaccept (getvar "PEDITACCEPT"))
)
(setvar "cmdecho" 0)
(setq A2k4 (>= (substr (getvar "ACADVER") 1 2) "16"))
;;; list of all "REV-NO" in block "revtext2" in order of y-coordinate, bottom to up
(if A2k4 (setvar "PEDITACCEPT" 0))
;;; (ax:SetManyTags "revtext2" "revtext1" "REV-NO" "REV-NO")
(setq okObjects '((0 . "LINE,ARC,POLYLINE,LWPOLYLINE")))
(defun ax:SetManyTags (bn-to bn-from tag-to tag-from / ax lst i)
(princ "\nSelect object to join: ")
(setq lst (ax:GetManyTags bn-from tag-from))
(setq ss1 (ssget okObjects))
(setq i 0)
(setq fuzz (getdist "\nFuzz distance <0>: "))
(foreach x (ax:ListBlockIns doc bn-to)
(if (= fuzz nil) (setq fuzz 0))
(ax:PutTagTextStringByRef (cadddr x) tag-to (nth i lst))
(if (/= ss1 nil)
(setq i (1+ i))
(progn
)
(setq objType (cdr (assoc 0 (entget (setq entLine (ssname ss1 0))))))
)
(if (= (sslength ss1) 1) (setq ss1 (ssget "X" okObjects)))
(if (member objType '("LINE" "ARC"))
;;; (ax:GetTagTextStringByRef #<VLA-OBJECT IAcadBlockReference 071b9e24>
"REV-NO") (command "_.pedit" "_M" ss1 "" "_Y" "_J" "_J" "_B" fuzz "")
(defun ax:GetTagTextStringByRef (br tagname / atts tag str) (command "_.pedit" "_M" ss1 "" "_J" "_J" "_B" fuzz "")
(if (and )
(= (vla-get-hasattributes br) :vlax-true) )
(safearray-value )
(setq atts (setq ss1 nil)
(vlax-variant-value (setvar "cmdecho" oldcmdecho)
(vla-getattributes br) (if A2k4 (setvar "PEDITACCEPT" oldpeditaccept))
) (princ)
) )
) ;;; By Jimmy Bergmark
) ;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
(foreach tag (vlax-safearray->list atts) ;;; Website: www.jtbworld.com
(if (= (strcase tagname) (strcase (vla-get-tagstring tag))) ;;; E-mail: info@jtbworld.com
(setq str (vla-get-TextString tag)) ;;;
) ;;; PlotDevicesFunctions.lsp
) ;;;
) ;;; 2003-01-09 More functions added
str ;;; 2006-07-30 Make it possible to add this lisp into your acaddoc.lsp
) ;;; 2006-12-15 Corrected a minor bug
;;;
;;; (ax:PutTagTextString doc "sheet-text" "client-drw" "new value")
(defun ax:PutTagTextString (doc bn tagname textstring / layout i atts tag) (vl-load-com)
(vlax-for layout (vla-get-layouts doc)
(vlax-for i (vla-get-block layout) (defun ActLay ()
(if (and (vla-get-ActiveLayout
(= (vla-get-objectname i) "AcDbBlockReference") (vla-get-activedocument
(= (strcase (vla-get-name i)) (strcase bn)) (vlax-get-acad-object)
) )
(if (and )
(= (vla-get-hasattributes i) :vlax-true) )
(safearray-value
(setq atts ; Return the Plotter configuration name
(vlax-variant-value (defun GetActivePlotDevice ()
(vla-getattributes i) (vla-get-ConfigName
) (ActLay)
) )
) )
)
(foreach tag (vlax-safearray->list atts) ; Return the Plot style table name
(if (= (strcase tagname) (strcase (vla-get-tagstring tag))) (defun GetActiveStyleSheet ()
(vla-put-TextString tag textstring) (vla-get-StyleSheet
) (ActLay)
) )
(vla-update i) )
)
) ; Force the Plotter configuration to something
) (defun PutActivePlotDevice (PlotDeviceName)
) (vla-put-ConfigName
) (ActLay)
PlotDeviceName
;;; (ax:PutTagTextStringByRef #<VLA-OBJECT IAcadBlockReference 071b9e24> )
"REV-NO" "new value") )
(defun ax:PutTagTextStringByRef (br tagname textstring / atts tag)
(if (and ; Force the Plot style table to something
(= (vla-get-hasattributes br) :vlax-true) (defun PutActiveStyleSheet (StyleSheetName)
(safearray-value (vla-put-StyleSheet
(setq atts (ActLay)
(vlax-variant-value StyleSheetName
(vla-getattributes br) )
) )
)
) ; Return a list of all Plotter configurations
) (defun PlotDeviceNamesList ()
(foreach tag (vlax-safearray->list atts) (vla-RefreshPlotDeviceInfo (ActLay))
(if (= (strcase tagname) (strcase (vla-get-tagstring tag))) (vlax-safearray->list
(vla-put-TextString tag textstring) (vlax-variant-value
) (vla-GetPlotDeviceNames
) (ActLay)
(vla-update br) )
) )
) )
)
;;; (ax:ChangeTagHeight <doc> <block name> <tag name> <tag height>)
;;; (ax:ChangeTagHeight doc "sheet-text" "client-drw" 0.97) ; Return a list of all Plot style tables
(defun ax:ChangeTagHeight (doc bn tagname tagheight / layout i atts tag)
(vlax-for layout (vla-get-layouts doc) (defun PlotStyleTableNamesList ()
(vlax-for i (vla-get-block layout) (vla-RefreshPlotDeviceInfo (ActLay))
(if (and (vlax-safearray->list
(= (vla-get-objectname i) "AcDbBlockReference") (vlax-variant-value
(= (strcase (vla-get-name i)) (strcase bn)) (vla-GetPlotStyleTableNames
) (ActLay)
(if (and )
(= (vla-get-hasattributes i) :vlax-true) )
(safearray-value )
(setq atts )
(vlax-variant-value
(vla-getattributes i) ; If the saved Plotter configuration doesn't exist set it to None
) (defun PutActivePlotDeviceToNoneIfNotExist ()
) (if (not (member (GetActivePlotDevice) (PlotDeviceNamesList)))
) (PutActivePlotDevice "None")
) )
(foreach tag (vlax-safearray->list atts) )
(if (= (strcase tagname) (strcase (vla-get-tagstring tag)))
(vla-put-height tag tagheight) ; If the saved Plot style table doesn't exist set it to None
) (defun PutActiveStyleSheetToNoneIfNotExist ()
) (if (not
(vla-update i) (member (GetActiveStyleSheet) (PlotStyleTableNamesList))
) )
) (PutActiveStyleSheet "")
) )
) )
)
; Change the Plotter configuration "CompanyStandard.pc3" to your need
;;; List the insertion point and reference of a block in active layout (defun PutActivePlotDeviceToCompanyStandardIfNotExist ()
;;; sort them by y-value (if (not (member (GetActivePlotDevice) (PlotDeviceNamesList)))
;;; (ax:ListBlockIns doc "revtext1") (PutActivePlotDevice "CompanyStandard.pc3")
;;; return value example: )
;;; ((341.385 29.2937 0.0 #<VLA-OBJECT IAcadBlockReference 071b9e24>) )
;;; (341.385 34.2937 0.0 #<VLA-OBJECT IAcadBlockReference 071b9e74>)
;;; (341.385 39.2937 0.0 #<VLA-OBJECT IAcadBlockReference 071bd184>)) ; Change the Plot style table "CompanyStandard-A3-BW.ctb" to your need
(defun ax:ListBlockIns (doc bn / layout i pl) (defun PutActiveStyleSheetToCompanyStandardIfNotExist ()
(vlax-for layout (vla-get-layouts doc) (if (not
(vlax-for i (vla-get-block layout) (member (GetActiveStyleSheet) (PlotStyleTableNamesList))
(if (and )
(= (vla-get-objectname i) "AcDbBlockReference") (PutActiveStyleSheet "CompanyStandard-A3-BW.ctb")
(= (strcase (vla-get-name i)) (strcase bn)) )
) )
(setq pl
(cons ; Change the Plotter configuration to the default one set in the options
(append (safearray-value ; if the active plot device does not exist
(vlax-variant-value (vla-get-InsertionPoint i)) (defun PutActivePlotDeviceToDefaultIfNotExistOrNone ()
) (if (or (not (member (GetActivePlotDevice) (PlotDeviceNamesList)))
(list i) (= (GetActivePlotDevice) "None")
) )
pl (if (= (vla-get-UseLastPlotSettings
) (vla-get-output
) (vla-get-preferences (vlax-get-acad-object))
) )
) )
) :vlax-true
; sort by y-value )
(vl-sort pl (PutActivePlotDevice
(function (lambda (e1 e2) (getenv "General\\MRUConfig")
(< (cadr e1) (cadr e2)) ) ) ) )
) (PutActivePlotDevice
(vla-get-DefaultOutputDevice
;;; Changes the insertion point of a tag (vla-get-output
;;; (ax:ChangeTagIns doc "sheet-text" "a3-scale" '(703.4722 17.8350 0)) (vla-get-preferences (vlax-get-acad-object))
(defun ax:ChangeTagIns (doc bn tagname ins / layout i atts tag) )
(defun list->variantArray (ptsList / arraySpace sArray) )
(setq arraySpace )
(vlax-make-safearray )
vlax-vbdouble )
(cons 0 (- (length ptsList) 1)) )
)
) ; Change the Plot style table to the default one set in the options
(setq sArray (vlax-safearray-fill arraySpace ptsList)) ; if the active Plot style table does not exist
(vlax-make-variant sArray) (defun PutActiveStyleSheetToDefaultIfNotExistOrNone ()
) (if (or (not
(vlax-for layout (vla-get-layouts doc) (member (GetActiveStyleSheet) (PlotStyleTableNamesList))
(vlax-for i (vla-get-block layout) )
(if (and (= (GetActiveStyleSheet) "")
(= (vla-get-objectname i) "AcDbBlockReference") )
(= (strcase (vla-get-name i)) (strcase bn)) (PutActiveStyleSheet
) (vla-get-DefaultPlotStyleTable
(if (and (vla-get-output
(= (vla-get-hasattributes i) :vlax-true) (vla-get-preferences (vlax-get-acad-object))
(safearray-value )
(setq atts )
(vlax-variant-value )
(vla-getattributes i) )
) )
)
) ; Customize this as you want
) ; Either force the Plot Device and/or the Style Sheet to something
(foreach tag (vlax-safearray->list atts) ; or only if the saved setting doesn't exist.
(if (= (strcase tagname) (strcase (vla-get-tagstring tag)))
(vla-put-InsertionPoint tag (list->variantArray ins)) ; If the Plot Device (printer, plotter or PC3 file) saved in the drawing
) ; and that will be used when printing does not exist or is set to None
) ; set it instead to your default plotter/printer
(vla-update i) (PutActivePlotDeviceToDefaultIfNotExistOrNone)
)
) ; If the Plot Style Table saved in the drawing
) ; and that will be used when printing does not exist or is set to None
) ; set it instead to your default plot style table
) (PutActiveStyleSheetToDefaultIfNotExistOrNone)

;;; Changes attributes on all block references matching <Tag Name> ; These below can be used if you want them set to None if they don't exists
;;; (ChangeAttributes (list <Block Name> '(<Tag Name> . <Tag Value>) ...)) ;(PutActivePlotDeviceToNoneIfNotExist)
;;; (ChangeAttributes (list "testblock" '("TESTTAG2" . "item1") '("NEWTAG" . ;(PutActiveStyleSheetToNoneIfNotExist)
"tagvalue")))
(defun ChangeAttributes (lst / sset item atts ename i) ; If you want to enforce another company standard you can
(setq i 0) ; activate and change in these functions
(setq sset (ssget "X" (list '(0 . "INSERT") (cons 2 (car lst))))) ;(PutActivePlotDeviceToCompanyStandardIfNotExist)
(if sset ;(PutActiveStyleSheetToCompanyStandardIfNotExist)
(repeat (sslength sset)
(setq ename (ssname sset i)) (princ)
(setq i (+ 1 i)) ;;; By Jimmy Bergmark
(if (safearray-value ;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
(setq atts ;;; Website: www.jtbworld.com
(vlax-variant-value ;;; E-mail: info@jtbworld.com
(vla-getattributes (vlax-ename->vla-object ename))
) ;;; Plot dialog by lisp
) (defun c:plotdialog()
) (initdia)
(progn (command "._plot")
(foreach item (cdr lst) )
(mapcar
'(lambda (x)
(if ;;; profiles.lsp
(= (strcase (car item)) ;;; miscellaneous profile commands
(strcase (vla-get-tagstring x)) ;;; By Jimmy Bergmark
) ;;; Copyright (C) 1997-2008 JTB World, All Rights Reserved
(vla-put-textstring x (cdr item)) ;;; Website: www.jtbworld.com
) ;;; E-mail: info@jtbworld.com
) ;;; 2000-01-25
(vlax-safearray->list atts) ;;; 2003-01-23 Added functions
) ;;; 2008-08-08 Added forceImport
)
(vla-update (vlax-ename->vla-object ename)) (vl-load-com)
)
) ; Brute force a profile to be imported
) ; (forceImport "profilename" "C:\\temp\\testprof.arg" 1)
) ; inclpathinfo=1 The path information in the registry file will be preserved.
(setq sset nil) ; inclpathinfo=0 The path information in the registry file will not be preserved.
) ; return T if profile is imported
(defun forceImport (profilename argname inclpathinfo / tmp1 tmp2)
;;; (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (setq tmp1 "<<most-temporary1>>")
;;; (ax:ChangeTagWidth <doc> <block name> <tag name> <tag height>) (deleteProfile tmp1)
;;; (ax:ChangeTagWidth doc "panel1" "drw-no" 0.97) (if (importProfile tmp1 argname inclpathinfo)
(defun ax:ChangeTagWidth (doc bn tagname tagwidth / layout i atts tag) (progn
(vlax-for layout (vla-get-layouts doc) (putActiveProfile tmp1)
(vlax-for i (vla-get-block layout) (deleteProfile profilename)
(if (and (renameProfile tmp1 profilename)
(= (vla-get-objectname i) "AcDbBlockReference") (putActiveProfile profilename)
(= (strcase (vla-get-name i)) (strcase bn)) T
) )
(if (and nil
(= (vla-get-hasattributes i) :vlax-true) )
(safearray-value )
(setq atts
(vlax-variant-value (defun getActiveProfile ()
(vla-getattributes i) (vla-get-activeprofile
) (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
) )
) )
)
(foreach tag (vlax-safearray->list atts) (defun putActiveProfile (profilename)
(if (= (strcase tagname) (strcase (vla-get-tagstring tag))) (vla-put-activeprofile
(vla-put-scalefactor tag tagwidth) (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
) profilename
) )
(vla-update i) )
)
) (defun getAllProfileNames(/ allprofiles)
) (vla-getallprofilenames
) (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
) 'allprofiles
;;; By Jimmy Bergmark )
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved (vlax-safearray->list allprofiles)
;;; Website: www.jtbworld.com )
;;; E-mail: info@jtbworld.com
(vl-load-com) (defun existProfile (profilename)
;;; (ax:CreateVP (vla-get-activedocument (vlax-get-acad-object)) '(200 200 0) (not (not (member
150 100) (strcase profilename)
(mapcar '(lambda (x) (strcase x)) (getallprofilenames))
(defun ax:CreateVP (ad center width height / ps ent) )))
(setq ps (vla-get-paperspace ad)) )
(vla-put-activespace ad acpaperspace)
(vla-put-mspace ad :vlax-false) (defun c:listProfileNames(/ nr profnames)
(setq ent (setq nr 0)
(vla-addpviewport (setq profnames (getAllProfileNames))
ps (repeat (length profnames)
(vlax-safearray-fill (princ (nth nr profnames))
(vlax-make-safearray (print)
vlax-vbdouble (setq nr (1+ nr))
(cons 0 2) )
) (princ)
center )
)
width ; return T if profile is deleted and nil if not
height (defun deleteProfile (profilename)
) (if (and
) (/= (strcase profilename) (strcase (getActiveProfile)))
(vla-put-viewporton ent :vlax-true) (existProfile profilename))
(vla-display ent :vlax-true) (not (vla-deleteprofile
(vla-update ent) (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
) profilename
;;; By Jimmy Bergmark ))
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved )
;;; Website: www.jtbworld.com )
;;; E-mail: info@jtbworld.com
; Delete all profiles except the current profile
;;; Example of inserting a block with ActiveX in modelspace (defun deleteAllProfilesExceptCurrent (/ item)
;;; (foreach item (getAllProfileNames)
;;; (ax:insert (vla-get-activedocument (vlax-get-acad-object)) (vl-catch-all-apply
;;; "r:\\projekt\\4045\\B\\revtext3.dwg" "0" 'vla-deleteprofile
;;; '(160 120 0) 1 1 1 0) (list (vla-get-profiles
(vl-load-com) (vla-get-preferences (vlax-get-acad-object))
(defun ax:insert (doc bn layer ins x y z rt) )
(setq layer (vla-item (vla-get-layers doc) layer)) item
; put the layer on )
(vla-put-LayerOn layer 1) )
; cannot thaw if active layer is 0 )
(vl-catch-all-apply 'vla-put-Freeze (list layer :vlax-false)) )
; put active layer
(vla-put-activeLayer doc layer) ; return T if profile is reseted and nil if not
(setq ins (list->variantArray ins)) (defun resetProfile (profilename)
(vla-insertblock (vla-get-modelspace doc) ins bn x y z rt) (if (existProfile profilename)
) (not (vla-resetprofile
(vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
(defun list->variantArray (ptsList / arraySpace sArray) profilename
(setq arraySpace ))
(vlax-make-safearray )
vlax-vbdouble )
(cons 0 (- (length ptsList) 1))
) ; return T if profile is renamed and nil if not
) ; if profilenameNew exist it's substituded with profilenameOld
(setq sArray (vlax-safearray-fill arraySpace ptsList)) (defun renameProfile (profilenameOld profilenameNew)
(vlax-make-variant sArray) (if (existProfile profilenameOld)
) (not (vla-renameprofile
;;; BackgroundChanger.LSP ver 1.0 (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
;;; Lets you change the background in a simple way profilenameOld
;;; Works for both model space and paper space but could simply be customized profilenameNew
for your need ))
;;; )
;;; By Jimmy Bergmark )
;;; Copyright (C) 1997-2004 JTB World, All Rights Reserved
;;; Website: www.jtbworld.com ; return T if profile is copied and nil if not
;;; E-mail: info@jtbworld.com ; if profilename2 exists it's copied
;;; 2003-07-01 - First release (defun copyProfile (profilename1 profilename2)
;;; Tested on AutoCAD 2002, 2004, 2005 (if (existProfile profilename1)
(not (vla-copyprofile
; Set the background in model and paper space to grey (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
(defun c:BGGrey () profilename1
(vl-load-com) profilename2
(setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object)))) ))
(setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad-object)))) )
(vla-put-GraphicsWinModelBackgrndColor disp 5987163) )
(vla-put-GraphicsWinLayoutBackgrndColor disp 5987163)
(vla-put-LayoutCrosshairColor disp 16777215) ; (exportProfile "profilename" "C:\\TEMP\\profilename.arg")
(vla-put-ModelCrosshairColor disp 16777215) ; if path is omitted profile is saved in active directory
(vla-put-AutoTrackingVecColor disp 16777215) ; overwrites argname if it exists
(vla-put-AutoSnapMarkerColor drafting 2) ; return T if profile is exported
(princ) (defun exportProfile (profilename argname)
) (if (existProfile profilename)
(not (vla-exportprofile
; Set the background in model and paper space to white (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
(defun c:BGWhite () profilename
(vl-load-com) argname
(setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object)))) ))
(setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad-object)))) )
(vla-put-GraphicsWinModelBackgrndColor disp 16777215) )
(vla-put-GraphicsWinLayoutBackgrndColor disp 16777215)
(vla-put-LayoutCrosshairColor disp 0) ; (importProfile "profilename" "C:\\TEMP\\profilename.arg" 1)
(vla-put-ModelCrosshairColor disp 0) ; overwrites profilename if it exists
(vla-put-AutoTrackingVecColor disp 0) ; if path is omitted profile is imported from active directory
(vla-put-AutoSnapMarkerColor drafting 6) ; inclpathinfo=1 The path information in the registry file will be preserved.
(princ) ; inclpathinfo=0 The path information in the registry file will not be preserved.
) ; return T if profile is imported
(defun importProfile (profilename argname inclpathinfo)
; Set the background in model and paper space to black (not (vl-catch-all-apply 'vla-importprofile (list
(defun c:BGBlack () (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
(vl-load-com) profilename
(setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object)))) argname
(setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad-object)))) inclpathinfo
(vla-put-GraphicsWinModelBackgrndColor disp 0) ))
(vla-put-GraphicsWinLayoutBackgrndColor disp 0) )
(vla-put-LayoutCrosshairColor disp 16777215) )
(vla-put-ModelCrosshairColor disp 16777215)
(vla-put-AutoTrackingVecColor disp 16777215) ; Brute force a profile to be imported and all the resting to be deleted
(vla-put-AutoSnapMarkerColor drafting 2) ; (forceImportAndDeleteTheRest "profilename" "C:\\temp\\testprof.arg" 1)
(princ) ; inclpathinfo=1 The path information in the registry file will be preserved.
) ; inclpathinfo=0 The path information in the registry file will not be preserved.
; return T if profile is imported
; Background toggle between black and white (defun forceImportAndDeleteTheRest (profilename argname inclpathinfo / tmp1
(defun c:bgt () tmp2)
(vl-load-com) (setq tmp1 "<<most-temporary1>>")
(setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object)))) (deleteProfile tmp1)
(setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad- (if (importProfile tmp1 argname inclpathinfo)
object)))) (progn
(if (= (vlax-variant-value (putActiveProfile tmp1)
(vlax-variant-change-type (deleteProfile profilename)
(vla-get-graphicswinmodelbackgrndcolor disp) (renameProfile tmp1 profilename)
vlax-vblong (putActiveProfile profilename)
) (deleteAllProfilesExceptCurrent)
) T
0 )
) nil
(c:bgwhite) )
(c:bgblack) )
)
(princ)
)
;;; ProjectPaths.LSP
(princ) ;;; Among other things it can save the paths
;;; BlockToXref.LSP ;;; to a file that can be imported on another PC.
;;; Convert Blocks to Xrefs ;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
;;; By Jimmy Bergmark ;;; Website: www.jtbworld.com
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved ;;; E-mail: info@jtbworld.com
;;; Website: www.jtbworld.com ;;; Tested on AutoCAD 2000, 2006
;;; E-mail: info@jtbworld.com
(vl-load-com)
;;; 2000-04-03 - First release
;;; Supports nested blocks, multiple tabs (defun ReadProject-Settings (cprof)
;;; Tested on AutoCAD 2000 (vl-registry-descendents
(strcat
(defun c:btx () (c:BlockToXref)) "HKEY_CURRENT_USER\\"
(defun c:BlockToXref (/ errexit undox (vlax-product-key)
olderr restore errexitA2k "\\Profiles\\"
ss ss1 e1 ix path cprof
bsl bn bnl bl bt not_ok repl oldvport oldregenmode "\\Project Settings"
typ ed layer color ltype ang ins tab oldtab )
) )
(defun errexit (s) )
(princ "\nError: ")
(princ s) (defun ReadRefSearchPath (cprof ProjSet)
(restore) (vl-registry-read
) (strcat
"HKEY_CURRENT_USER\\"
(defun undox () (vlax-product-key)
(setq ss1 nil) "\\Profiles\\"
(setq ss2 nil) cprof
(setvar "ctab" oldtab) "\\Project Settings\\"
(if (> oldcvport 1) (command "._mspace") (command "._pspace")) ProjSet
(setvar "cvport" oldcvport) )
(setvar "regenmode" oldregenmode) "RefSearchPath"
(command "._undo" "_E") )
(setvar "cmdecho" oldcmdecho) )
(setq *error* olderr)
(princ) ;;; Ex: (AllProjPath (getvar "CPROFILE"))
) (defun AllProjPath (cprof / lst ProjSet)
(foreach ProjSet (ReadProject-Settings cprof)
(setq olderr *error* (setq lst (cons (cons ProjSet (ReadRefSearchPath cprof ProjSet)) lst))
restore undox )
*error* errexit )
)
(setq oldcmdecho (getvar "cmdecho")) ;;; Ex: (WriteRefSearchPath (getvar "CPROFILE") "Project1" "c:\temp;c:\project")
(setq oldtab (getvar "ctab")) (defun WriteRefSearchPath (cprof ProjSet path)
(setq oldcvport (getvar "cvport")) (vl-registry-write
(setq oldregenmode (getvar "regenmode")) (strcat
(setvar "cmdecho" 0) "HKEY_CURRENT_USER\\"
(setvar "regenmode" 0) (vlax-product-key)
(command "._UNDO" "_BE") "\\Profiles\\"
(setq A2k (wcmatch (getvar "ACADVER") "15*")) cprof
(if (and A2k (/= (setq ss1 (ssget '((0 . "INSERT")))) nil)) "\\Project Settings\\"
(progn ProjSet
(vl-load-com) )
(setq ix 0) "RefSearchPath"
(setq bsl nil) ; block selection list path
(setq bnl nil) ; unique block name list )
(repeat (sslength ss1) )
(setq e1 (ssname ss1 ix))
(setq bn (cdr (assoc 2 (entget e1)))) ; block name ;;; Deletes all Project paths
(setq bl (tblsearch "block" bn)) ; block list bn (defun DeleteRefSearchPath (cprof)
(setq bt (cdr (assoc 70 bl))) ; block type (foreach ProjSet (ReadProject-Settings cprof)
(if (and (/= (logand bt 4) 4) (not (member bn bnl))) ; no xrefs and no (vl-registry-delete
duplicates (strcat
(setq bnl (cons bn bnl)) "HKEY_CURRENT_USER\\"
) (vlax-product-key)
(setq ix (1+ ix)) "\\Profiles\\"
); end repeat cprof
"\\Project Settings\\"
(foreach bn bnl ProjSet
(setq ss1 (ssget "X" (list (cons 0 "INSERT") (cons 2 bn)))) )
(setq ix 0) )
(repeat (sslength ss1) )
(setq e1 (ssname ss1 ix)) )
(setq bsl (cons (entget e1) bsl))
(setq ix (1+ ix)) ;;; Ex: (WriteAllProjPath (getvar "CPROFILE") (list (cons "Project1" "C:\\") (cons
) "Project2" "D:\\")))
); end repeat ;;; Deletes all old Paths first
(defun WriteAllProjPath (cprof lst / ProjSet)
(foreach bn bnl (DeleteRefSearchPath cprof)
(setq not_ok T) (foreach ProjSet lst
(while not_ok (WriteRefSearchPath cprof (car ProjSet) (cdr ProjSet))
(setq path (getfiled "Match the block to a file" )
(if (not path) (strcat (getvar "dwgprefix") bn) (strcat (vl- )
filename-directory path) "\\" bn))
"dwg" 0)) ;;; Ex: (Print-AllProjPaths (getvar "CPROFILE"))
(if path (defun Print-AllProjPaths (cprof / ProjSet)
(if (= (strcase (vl-filename-base path)) (strcase bn)) (princ "Project Files Search Path:\n")
(setq not_ok nil) (foreach ProjSet (ReadProject-Settings cprof)
(progn (princ ProjSet)
(initget 0 "Yes No") (princ " = ")
(setq repl (getkword "\nAssign a different name? [Yes/No] <No>: ")) (princ (ReadRefSearchPath cprof ProjSet))
(if (not repl) (setq repl "Yes")) (terpri)
(if (= "Yes" repl) )
(setq not_ok nil) (princ)
(setq not_ok T) )
)
) ;;; Change "r:\\paths.txt" to a location on the server
) ;;; (getProjectPaths "c:\\paths.txt")
) (defun getProjectPaths (fn / cprof paths f)
(if (not not_ok) (setq cprof (getvar "CPROFILE"))
(progn (setq paths (AllProjPath cprof))
(setq ss (ssget "X" (list (cons 0 "INSERT") (cons 2 bn)))) (setq f (open fn "w"))
(setq ix 0) (foreach ProjSet (ReadProject-Settings cprof)
(repeat (sslength ss) (write-line ProjSet f)
(setq ed (ssname ss ix)) (write-line (ReadRefSearchPath cprof ProjSet) f)
(setq tab (cdr (assoc 410 (entget ed)))) )
(setvar "ctab" tab) (close f)
(entdel ed) )
(setq ix (1+ ix))
) ;;; Change "r:\\paths.txt" to a location on the server
(repeat 10 ;;; (putProjectPaths "c:\\paths.txt")
(vl-cmdf "._purge" "_b" "*" "N") (defun putProjectPaths (fn / cprof line1 line2 paths f)
) (setq cprof (getvar "CPROFILE"))
(initget 0 "Overlay Attach") (setq f (open fn "r"))
(setq repl (getkword "\nEnter an option [Overlay/Attach] <Attach>: ")) (while (and (setq line1 (read-line f)) (setq line2 (read-line f)))
(if (not repl) (setq repl "Attach")) (setq paths (cons (cons line1 line2) paths))
(if (= "Attach" repl) (setq typ "_A") (setq typ "_O")) )
(setq ix 0) (close f)
(repeat (length bsl) (WriteAllProjPath cprof paths)
(setq ed (nth ix bsl)) )
(if (= bn (cdr (assoc 2 ed))) ;;; purge-point.LSP
(progn ;;;
(setq layer (cdr (assoc 8 ed))) ;;; These commands shall be used with caution since they destroys
(setq color (cdr (assoc 62 ed))) ;;; the intelligence in the objects. But it can reduce the size very much
(if (not color) (setq color "_ByLayer")) ;;; if that is what is needed.
(setq ltype (cdr (assoc 6 ed))) ;;; A test with an Architectural drawing reduced the size from 1061kB to 172kB.
(if (not ltype) (setq ltype "_ByLayer")) ;;;
(setq ang (/ (* 180.0 (cdr (assoc 50 ed))) pi)) ;;; c:purge-vent Kills all POINT 5 vent-objects and V50-dictionaries
(setq ins (cdr (assoc 10 ed))) ;;; c:purge-aec Kills all POINT 5 architect-objects and dictionaries
(setq tab (cdr (assoc 410 ed))) ;;; the above command (purge-aec) shall be run when POINT A is unloaded to work
(setvar "ctab" tab) correct
(if (/= tab "Model") (command "._pspace")) ;;; c:purge-point5 Kills all POINT 5 general objects in a drawing
(vl-cmdf "._xref" typ path "_X" (cdr (assoc 41 ed)) "_Y" (cdr (assoc 42 ;;; c:purge-point Kills all POINT general objects in a drawing
ed)) "_Z" (cdr (assoc 43 ed)) ins ang) ;;; c:purge-all-point runs all of the above commands
(vl-cmdf "._change" "_L" "" "_P" "_C" color "_LA" layer "_LT" ltype ;;;
"") ;;; By Jimmy Bergmark
) ;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
) ;;; Website: www.jtbworld.com
(setq ix (1+ ix)) ;;; E-mail: info@jtbworld.com
) ;;; 2000-04-05 - First release
) ;;; 2000-06-05 - Strcase on wcmatch of dict. on entities
) ;;; 2000-06-19 - Buggfix on strcase of nil
(if (= path nil) (setq not_ok nil)) ;;; Tested on AutoCAD 2000 and POINT 5
)
) (defun deldict (dictName)
); end progn (dictremove (namedobjdict) dictName)
); end if )
(setq ss1 nil)
(restore) (defun listdictionaries ()
) (massoc 3 (entget (namedobjdict)))
;;;---------------------------------------------------------------------------; )
;;;
;;; bomlengths.lsp (defun massoc (key alist / x nlist)
;;; (foreach x alist
;;; By Jimmy Bergmark (if (eq key (car x))
;;; Copyright (C) 1997-2007 JTB World, All Rights Reserved (setq nlist (cons (cdr x) nlist))
;;; Website: www.jtbworld.com )
;;; E-mail: info@jtbworld.com )
;;; (reverse nlist)
;;; 1998-03-31 - First release )
;;; 2000-05-11 - Fixed for LWPOLYLINES and for A2k
;;; 2003-06-10 - Tested on 2004 and fixed a minor bug (defun kill-dict (typ / olderr oldcmdecho errexit undox restore en more ed no repl
;;; 2004-03-18 - Added (vl-load-com) ed360 ed3)
;;; 2007-09-24 - Shows the result in the active unit (defun errexit (s)
;;; Tested on AutoCAD 2000, 2004, 2005, 2008 (princ "\nError: ")
;;; should be working on older versions too with minor modifications. (princ s)
;;; exchange bom-code-old with bom-code (restore)
;;; )
;;;---------------------------------------------------------------------------;
;;; DESCRIPTION (defun undox ()
;;; (command "._undo" "_E")
;;; BILL OF LENGTHS. Get the accumulated sum length of multiple objects. (setvar "cmdecho" oldcmdecho)
;;; c:bomlengths - length of lines, arcs, polylines and splines and total. (setq *error* olderr)
;;; c:bom_lines - length of lines and total. (princ)
;;; c:bom_arcs - length of arcs, and total. )
;;; c:bom_polylines - length of polylines and total.
;;; c:bom_splines - length of splines and total. (setq olderr *error*
;;;---------------------------------------------------------------------------; restore undox
*error* errexit
(defun dxf (n ed) (cdr (assoc n ed))) )
(setq oldcmdecho (getvar "cmdecho"))
(defun bom-code (ssfilter / errexit undox restore (setvar "cmdecho" 0)
*error* olderr oldcmdecho %l %t (command "._UNDO" "_BE")
sset %i en ed p1 p2 (initget 0 "Yes No")
ot a1 a2 r (setq repl (getkword "\nAre you sure? [Yes/No] <No>: "))
) (if repl
(defun errexit (s) (progn
(princ) (setq en (entnext))
(restore) (setq more (not (not en)))
) (setq no 0)
(while more
(defun undox () (setq ed (entget en))
(command "._undo" "_E") (if (and
(setvar "cmdecho" oldcmdecho) (/= (member '(102 . "{ACAD_XDICTIONARY") ed) nil)
(setq *error* olderr) (setq ed360 (assoc 360 ed))
(princ) (setq ed3 (assoc 3 (entget (cdr ed360))))
) (wcmatch (strcase (cdr ed3)) (strcase typ))
)
(setq olderr *error* (progn
restore undox (entdel en)
*error* errexit (setq ed
) (append
(setq oldcmdecho (getvar "cmdecho")) (reverse
(setvar "cmdecho" 0) (cdr (member '(102 . "{ACAD_XDICTIONARY") (reverse ed)))
(command "._UNDO" "_BE") )
(setq %i 0 (cdr (member '(102 . "}") ed))
%t 0 )
) )
(vl-load-com) (if (not (entmake ed))
(setq sset (ssget ssfilter)) (progn
(if sset (entdel en)
(progn (princ "\nError deleting: ")
(princ "\nLengths:") (princ en)
(repeat (sslength sset) )
(setq en (ssname sset %i)) (setq no (1+ no))
(setq ed (entget en)) )
(setq ot (dxf 0 ed)) )
(setq curve (vlax-ename->vla-object en)) (if (= (setq en (entnext en)) nil)
(if (vl-catch-all-error-p (setq more nil)
(setq len (vl-catch-all-apply )
'vlax-curve-getDistAtParam )
(list curve )
(vl-catch-all-apply (foreach dict (listdictionaries)
'vlax-curve-getEndParam (if (wcmatch (strcase dict) (strcase typ)) (deldict dict))
(list curve) )
))))) )
nil )
len (princ "\nNumber of deleted objects: ")
) (princ no)
(setq %l len) (restore)
)
(setq %i (1+ %i)
%t (+ %l %t) (defun c:purge-vent() (kill-dict "V50*"))
) (defun c:purge-point5() (kill-dict "Point5*"))
(terpri) (defun c:purge-point() (kill-dict "Point"))
;(princ %l ) (defun c:purge-aec() (kill-dict "PointAec*"))
(princ (rtos %l (getvar "lunits")(getvar "luprec"))) (defun c:purge-all-point() (kill-dict "Point*") (kill-dict "V50*"))
) (princ)
(princ "\nTotal = ")
;(princ %t)
(princ (rtos %t (getvar "lunits")(getvar "luprec")))
(textpage) ;;; PURGER.LSP
) ;;;
) ;;; Various purge functions with no command line echo
(setq sset nil) ;;;
(restore) ;;; By Jimmy Bergmark
) ;;; Copyright (C) 1997-2004 JTB World, All Rights Reserved
;;; Website: www.jtbworld.com
(defun bom-code-old (ssfilter / errexit undox restore ;;; E-mail: info@jtbworld.com
*error* olderr oldcmdecho %l %t ;;; 2000-02-12 - First release
sset %i en ed p1 p2 ;;; 2003-01-09 - More added
ot a1 a2 r ;;; 2004-05-23 - Added support to delete filters in 2005
) ;;; Written for AutoCAD 2000, 2000i, 2002, 2004, 2005
(defun errexit (s) ;;;
(princ)
(restore) ;;; Purge named block
) ;;; Example: (ax:purge-block (vla-get-activedocument (vlax-get-acad-object))
"testblock")
(defun undox () ;;; Argument: doc {document}
(command "._undo" "_E") ;;; name {a block name}
(setvar "cmdecho" oldcmdecho) ;;; Return values: T if successful, nil if not successful
(setq *error* olderr) (defun ax:purge-block (doc name)
(princ) (if (vl-catch-all-error-p
) (vl-catch-all-apply
'vla-delete
(setq olderr *error* (list (vl-catch-all-apply
restore undox 'vla-item
*error* errexit (list (vla-get-blocks doc) name)
) )
(setq oldcmdecho (getvar "cmdecho")) )
(setvar "cmdecho" 0) )
(command "._UNDO" "_BE") )
(setq %i 0 nil ; name cannot be purged or doesn't exist
%t 0 T ; name purged
) )
(setq sset (ssget ssfilter)) )
(if sset
(progn ;;; Purge named layer
(princ "\nLengths:") ;;; Example: (ax:purge-layer (vla-get-activedocument (vlax-get-acad-object))
(repeat (sslength sset) "testlayer")
(setq en (ssname sset %i)) ;;; Argument: doc {document}
(setq ed (entget en)) ;;; name {a layer name}
(setq ot (dxf 0 ed)) ;;; Return values: T if successful, nil if not successful
(cond (defun ax:purge-layer (doc name)
((= ot "LINE") (if (vl-catch-all-error-p
(setq p1 (dxf 10 ed) (vl-catch-all-apply
p2 (dxf 11 ed) 'vla-delete
%l (distance p1 p2) (list (vl-catch-all-apply
) 'vla-item
) (list (vla-get-layers doc) name)
((= ot "ARC") )
(setq a1 (dxf 50 ed) )
a2 (dxf 51 ed) )
r (dxf 40 ed) )
%l (* r (abs (- a2 a1))) nil ; name cannot be purged or doesn't exist
) T ; name purged
) )
(t )
(command "._area" "_obj" en)
(setq %l (getvar "perimeter")) ;;; Purge all layers
;;; Example: (ax:purge-all-layers (vla-get-activedocument (vlax-get-acad-object)))
) ;;; Argument: doc {document}
) (defun ax:purge-all-layers (doc)
(setq %i (1+ %i) (vlax-for item (vla-get-layers doc)
%t (+ %l %t) (purge-layer (vla-get-name item))
) )
(terpri) )
(princ %l)
) ;;; Purge all layers except those in list
(princ "\nTotal = ") ;;; Example: (ax:purge-layers (vla-get-activedocument (vlax-get-acad-object))
'("DIM" "LAYER1"))
(princ %t)
;;; Argument: doc {document}
(textpage)
;;; name {a layer name list}
)
(defun ax:purge-layers (doc except)
)
(vlax-for item (vla-get-layers doc)
(setq sset nil)
(setq ln (vla-get-name item))
(restore)
(if (not (member (strcase ln) except))
)
(purge-layer ln)
)
(defun c:bomlengths ()
)
(initget "Lines Arcs Polylines Splines ALL")
)
(setq ans (getkword
"Enter an option [Lines/Arcs/Polylines/Splines] <ALL>: "
;;; Purge all with no echo to command window
)
;;; Example: (ax:purge-no-echo (vla-get-activedocument (vlax-get-acad-object)))
)
;;; Argument: doc {document}
(cond
(defun ax:purge-no-echo (doc)
((= ans "Lines") (c:bom_lines))
((= ans "Arcs") (c:bom_arcs))
;;; Returns a list of keynames from the specified dictionary
((= ans "Polylines") (c:bom_polylines))
(defun getkeys (dictName / tmp)
((= ans "Splines") (c:bom_splines))
(if (setq tmp (dictsearch (namedobjdict) dictName))
(t
(massoc 3 tmp)
(bom-code '((-4 . "<OR")
)
(0 . "LINE")
)
(0 . "ARC")
(0 . "POLYLINE")
(0 . "LWPOLYLINE") ;;; Retrieves the entity name of the specified dictionary
(0 . "SPLINE") (defun getdictname (dictName)
(-4 . "OR>") (if (setq tmp (dictsearch (namedobjdict) dictName))
) (cdr (assoc -1 tmp))
) )
) )
)
(princ) ;;; Utility function to get multiple group code CDRs
) (defun massoc (key alist / x nlist)
(foreach x alist
(defun c:bom_lines () (if (eq key (car x))
(bom-code '((0 . "LINE"))) (setq nlist (cons (cdr x) nlist))
(princ) )
) )
(reverse nlist)
(defun c:bom_arcs () )
(bom-code '((0 . "ARC")))
(princ) (vlax-for item (vla-get-blocks doc)
) (vl-catch-all-apply 'vla-delete (list item))
)
(defun c:bom_polylines () (vlax-for item (vla-get-dimstyles doc)
(bom-code '((-4 . "<OR") (vl-catch-all-apply 'vla-delete (list item))
(0 . "POLYLINE") )
(0 . "LWPOLYLINE") (vlax-for item (vla-get-linetypes doc)
(-4 . "OR>") (vl-catch-all-apply 'vla-delete (list item))
) )
) (vlax-for item (vla-get-plotconfigurations doc)
(princ) (vl-catch-all-apply 'vla-delete (list item))
) )
; textstyles
(defun c:bom_splines () (vlax-for item (vla-get-textstyles doc)
(bom-code '((0 . "SPLINE"))) (if (= (cdr (assoc 70 (entget (vlax-vla-object->ename item)))) 0)
(princ) (vl-catch-all-apply 'vla-delete (list item))
) )
)
(defun c:CreateLT() ; shapes
(vl-load-com) (vlax-for item (vla-get-textstyles doc)
(setq pDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (if (= (cdr (assoc 70 (entget (vlax-vla-object->ename item)))) 1)
(vl-catch-all-apply 'vla-delete (list item))
)
;get the DBConnect )
(setq pDBObj (vla-GetInterfaceObject (vlax-get-acad-object) (setq li (getkeys "ACAD_MLINESTYLE"))
"CAO.dbConnect")) (setq len (length li))
; one style has to be left
(foreach na (cdr li)
(if (null pDBObj) (delrecord "ACAD_MLINESTYLE" na)
(progn )
(alert "Cannot create CAO Automation server.") (setq li (getkeys "ACAD_MLINESTYLE"))
(exit))) (setq len (length li))
(if (> len 1)
(delrecord "ACAD_MLINESTYLE" (car li))
;get the linktemplates )
(setq pLTs(vlax-invoke-method pDBObj "GetLinkTemplates" pDoc)) (vlax-for item (vla-get-layers doc)
(vl-catch-all-apply 'vla-delete 'item)
)
;prepare the keydescriptions nil
(setq pKeyDescs (vla-GetInterfaceObject (vlax-get-acad-object) )
"CAO.KeyDescriptions"))
(vlax-invoke-method pKeyDescs "ADD" "TAG_NUMBER" 3 nil nil)
;;; Purge/delete all layer filters
(vlax-invoke-method pKeyDescs "ADD" "Manufacturer" 1 nil nil)
;;; Example: (DeleteLayerFilters)
;create two link templates
(defun DeleteLayerFilters ()
(vlax-invoke-method pLTs "ADD" "jet_dbsamples" nil nil "COMPUTER"
(vl-Catch-All-Apply
"LTCreatedByVLispCAO" pKeyDescs) '(lambda ()
(vlax-invoke-method pLTs "ADD" "jet_dbsamples" nil nil "COMPUTER" (vla-Remove
"LTtobeDeleted" pKeyDescs) (vla-GetExtensionDictionary
(vla-Get-Layers
(vla-Get-ActiveDocument (vlax-Get-Acad-Object))
;sample code to show how to delete the link template )
(vlax-invoke-method pLTs "delete" "LTtobeDeleted") )
) "ACAD_LAYERFILTERS"
;;; c:ChangeNoPlottableLayers )
;;; )
;;; By Jimmy Bergmark )
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved (princ)
;;; Website: www.jtbworld.com )
;;; E-mail: info@jtbworld.com
;;; Purge/delete all layer filter or filters compatible with 2005 or later
;;; 2000-03-13 ;;; Example: (DeleteLayerFilters2)
;;; 2003-01-08 - Handle frozen/off/locked defpoints layer by (defun DeleteLayerFilters2 ()
thawing/on/unlocking it
(vl-Catch-All-Apply
;;; Tested on AutoCAD 2000, 2002
'(lambda ()
;;;
(vla-Remove
;;; This is useful when you want to save a file to
(vla-GetExtensionDictionary
;;; r14 or older.
(vla-Get-Layers
;;; It tries to move all entities from layers that
(vla-Get-ActiveDocument (vlax-Get-Acad-Object))
;;; are not plottable to layer defpoints.
)
;;;
)
(vl-load-com)
"AcLyDictionary"
(defun c:ChangeNoPlotLayers (/ ad layer ss)
)
(layer-set "defpoints")
)
(setq ad (vla-get-ActiveDocument (vlax-get-Acad-Object)))
)
(vlax-for layer (vla-get-Layers ad)
(princ)
(cond
)
((eq (vla-get-plottable layer) :vlax-true))
((/= (vla-get-name layer) "defpoints")
(vla-put-Freeze layer :vlax-false)
;;; Purge/delete all layer states
(vla-put-Lock layer :vlax-false)
;;; Example: (DeleteLayerStates)
(GlobalChangeLayer (vla-get-name layer) "defpoints")
(defun DeleteLayerStates ()
)
(vl-Catch-All-Apply
)
'(lambda ()
)
(vla-Remove (vla-GetExtensionDictionary
(command "._regenall")
(vla-Get-Layers
(princ)
(vla-Get-ActiveDocument
)
(vlax-Get-Acad-Object))))
"ACAD_LAYERSTATES")))
;;; By Tony Tanzillo ?
(princ)
(defun GlobalChangeLayer (oldlayer newlayer / ent old new)
)
(setq old (cons 8 (getLayerName oldlayer)))
;;; Purge/delete all Express Tool layer states
(setq new (cons 8 (getLayerName newlayer)))
;;; Example: (LmanKill)
(BlockEntityIterator
(defun LmanKill (/ lyr ent cnt)
'(lambda (e)
(setq cnt 0)
(changeLayer e old new)
(while (setq lyr (tblnext "layer" (not lyr)))
)
(setq ent (entget (tblobjname "layer" (cdr (assoc 2 lyr)))'("RAK")))
)
(if (and ent (assoc -3 ent))
(setq ent (entnext))
(progn
(while ent
(setq ent (subst '(-3 ("RAK")) (assoc -3 ent) ent))
(changeLayer ent old new)
(entmod ent)
(setq ent (entnext ent))
(setq cnt (1+ cnt))
)
)
)
)
)
(defun getLayerName (name)
(princ)
(cdr (assoc 2 (tblsearch "layer" name)))
)
)
;;; (deleteAllPageSetups)
(defun deleteAllPageSetups (/ pc)
(defun BlockEntityIterator (bei_Func / bei_block bei_ent) (vlax-for pc (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-
(while (setq bei_block (tblnext "block" (not bei_block))) object)))
(setq bei_ent (cdr (assoc -2 bei_block))) (vla-delete pc)
(while bei_ent )
(apply bei_func (list bei_ent)) )
(setq bei_ent (entnext bei_ent))
) (defun PurgeAnonymGroups (/ grpList index grp)
) (setq grpList (dictsearch (namedobjdict) "ACAD_GROUP"))
) (setq index 1)
(while (setq grp (nth index grplist))
(defun ChangeLayer (ent old new / data) (if (= (car grp) 3)
(setq data (entget ent)) (progn
(if (equal (assoc 8 data) old) (if (= (chr 42) (substr (cdr grp) 1 1))
(entmod (subst new old data)) (entdel (cdr (nth (+ index 1) grplist)))
) )
) )
)
; Not by me (setq index (+ 1 index))
(defun layer-set (layer / e d c f) )
(cond (princ)
; _________________ )
; (defun PurgeAllGroups (/ grpList index grp)
; layer exists (setq grpList (dictsearch (namedobjdict) "ACAD_GROUP"))
; ensure "settable" (setq index 1)
; set current (while (setq grp (nth index grplist))
; _________________ (if (= (car grp) 3)
(entdel (cdr (nth (+ index 1) grplist)))
( (setq e (tblobjname "layer" layer)) )
(setq (setq index (+ 1 index))
d (entget e) ; data )
c (cdr (assoc 62 d)) ; color (princ)
f (cdr (assoc 70 d)) ; flags )
) (defun DelACAD_VBA ()
(if (minusp c) (dictremove (namedobjdict) "ACAD_VBA")
; layer is off, force abs of color (princ)
(setq d (subst (cons 62 (abs c)) (assoc 62 d) d)) )
) (defun PurgeAPPID (/ appid)
(if (eq 1 (logand 1 f)) (vl-load-com)
; layer is frozen, mask off 1 (vlax-for appid (vla-get-registeredapplications
(setq f (boole 6 f 1)) (vla-get-activedocument
) (vlax-get-acad-object)
(if (eq 4 (logand 4 f)) )
; layer is locked, mask off 4 )
(setq f (boole 6 f 4)) (vl-catch-all-apply 'vla-delete (list appid))
) )
; did we change the flag value? (princ)
(if (not (eq f (cdr (assoc 70 d)))) )
(setq d (subst (cons 70 f) (assoc 70 d) d))
) (princ)
; did we change the dxf data at all?
(if (not (equal d (entget e))) ;;; PurgeReconciledLayers.LSP
(entmod d) ;;;
) ;;; By Jimmy Bergmark
; set layer current, return ;;; Copyright (C) 2007 JTB World, All Rights Reserved
; layer name to calling function ;;; Website: www.jtbworld.com
(setvar "clayer" layer) ;;; E-mail: info@jtbworld.com
) ;;; 2007-04-05 - First release
; _____________________ ;;; Written for AutoCAD 2008
;
; layer doesn't exist,
; symbol name is valid, ;;; Purge all information about reconciled layers in the drawing
; make it / set it
; _____________________ (defun PurgeReconciledLayers ()
(vl-load-com)
( (snvalid layer) (vlax-for layer (vla-get-Layers
(if (vla-get-ActiveDocument
(entmake (vlax-get-acad-object)
(list )
'(0 . "LAYER") )
'(100 . "AcDbSymbolTableRecord") (vl-Catch-All-Apply
'(100 . "AcDbLayerTableRecord") '(lambda ()
(cons 2 layer) (vla-Remove
'(70 . 0) (vla-GetExtensionDictionary
'(62 . 7) layer
'(6 . "CONTINUOUS") )
) "ADSK_XREC_LAYER_RECONCILED"
) )
; ______________________________ )
; )
; if entmake was successful (vl-Catch-All-Apply
; set layer current, return '(lambda ()
; layer name to calling function (vla-delete
; ______________________________ (vla-GetExtensionDictionary
layer
(setvar "clayer" layer) )
) )
) )
; _____________________ )
; )
; layer doesn't exist (setvar "LAYEREVAL" 0)
; symbol name invalid (setvar "LAYERNOTIFY" 0)
; return nil to calling (princ)
; function )
; _____________________
; Remove the row below if you don't want to run the code automatically when the
) AutoLISP file is loaded.
) (PurgeReconciledLayers)
;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2012 JTB World, All Rights Reserved
;;; ;;; Website: www.jtbworld.com
;;; ;;; E-mail: info@jtbworld.com
================================================================= ;;; This program is created for AutoCAD 2002, AutoCAD 2004
======== ;;; AutoCAD 2005, AutoCAD 2006, AutoCAD 2007, AutoCAD 2008
;;; DIMLINECHANGE.LSP ;;; AutoCAD 2009, AutoCAD 2010, AutoCAD 2011, AutoCAD 2012
;;; ;;; AutoCAD 2013 and vertical products
;;; By Jimmy Bergmark ;;; Removes the icons Autodesk 360, Buzzsaw, RedSpark, Point A and FTP in Open
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved dialog box
;;; Website: www.jtbworld.com ;;;
;;; E-mail: info@jtbworld.com ;;; To remove all of the Icons above for all profiles use (remicons T T T T T T)
;;; ;;; To remove only Buzzsaw in active profile use (remicons nil T nil nil nil nil)
;;; 2000-03-02 ;;; To restore all of the Icons to all profiles use (remicons nil nil nil nil nil T)
;;; ;;; (remicons <Autodesk 360> <Buzzsaw> <RedSpark> <Point A> <FTP> <All
;;; Description: Changes selected line on a dimension to current layer. profiles=T, current profile=nil>)
;;; This layer can be with another linetype.
;;; So, it can be used for dimensioning to centerlines. (defun remicons (accloud ibuzz ired ipoint iftp allprof / prof profiles regkey)
;;; (vl-load-com)
(defun C:DIMLINECHANGE (/ nents nlst ent nen lasten pen ent en oe tbl) (defun getallprofilenames (/ allprofiles)
(vla-getallprofilenames
(defun *error* (MSG) (vla-get-profiles
(princ MSG) (vla-get-preferences (vlax-get-acad-object))
(princ) )
) 'allprofiles
)
(if (setq nents (nentsel)) (vlax-safearray->list allprofiles)
(progn )
(setq nen (car nents)) (setq profiles (getallprofilenames))
(if (setq nlst (cadddr nents)) (if (not allprof) (setq profiles (list (getvar "CPROFILE"))))
(if (> (length nlst) 1) (foreach prof profiles
(*error* "Nested block!\n") (setq regkey (strcat "HKEY_CURRENT_USER\\"
) (vlax-product-key)
(*error* "\nNo dimension selected!") "\\Profiles\\"
) prof
(setq pen (car nlst)) "\\Dialogs\\AllAnavDialogs\\DeletedExtensions"
(if (= (cdr (assoc 0 (entget pen))) "DIMENSION") )
(cond )
((= (cdr (assoc 0 (setq ent (entget nen)))) "LINE") (if accloud
(if (setq (vl-registry-write
tbl (tblsearch "BLOCK" (cdr (assoc 2 (entget pen)))) regkey
) "AcCloud"
(progn ""
(entmake tbl) )
(setq en (cdr (assoc -2 tbl))) (vl-registry-delete regkey "AcCloud")
(while (not lasten) )
(setq ent (entget en)) (if ibuzz
(if (equal nen (cdr (assoc -1 ent))) (vl-registry-write
(progn regkey
(setq ent (subst (cons 8 (getvar "clayer")) "Buzzsaw"
(assoc 8 ent) ""
ent )
) (vl-registry-delete regkey "Buzzsaw")
) )
(entmake ent) (if ibuzz
) (vl-registry-write
(entmake ent) regkey
) "ACPROJECT"
(if (= (cdr (assoc 0 ent)) "ENDBLK") ""
(setq lasten T) )
(setq lasten (not (setq en (entnext en)))) (vl-registry-delete regkey "ACPROJECT")
) )
) (if ired
(if (entmake (list (cons 0 "ENDBLK"))) (vl-registry-write
(entupd pen) regkey
) "RedSpark"
) ""
) )
) (vl-registry-delete regkey "RedSpark")
(T (prompt "\nSelect a dimensionline.")) )
) (if ipoint
(prompt "\nNo dimension selected!") (vl-registry-write
) regkey
) "SimpleStorageSites"
) ""
(princ) )
) (vl-registry-delete regkey "SimpleStorageSites")
)
(defun C:DLC () (C:DIMLINECHANGE)) (if iftp
(princ "\nLoaded command DIMLINECHANGE (or short DLC)") (vl-registry-write
(princ "\n(c) Jimmy Bergmark - 2000.") regkey
(princ) "FTPSites"
""
)
;;; DisplayColorProperties.LSP (vl-registry-delete regkey "FTPSites")
;;; Miscellaneous commands related to Colors on the Display tab on the Options )
dialog )
;;; By Jimmy Bergmark (princ)
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved )
;;; Website: www.jtbworld.com
;;; E-mail: info@jtbworld.com (princ)
;;; 2000-03-29 - First release ;;; SOPEN.LSP
;;; 2003-03-07 - Now for AutoCAD 2004 ;;; Open command that works for all cases
;;; Tested on AutoCAD 2000, 2000i, 2002 and 2004 ;;; Works for SDI=0 or SDI=1

(vl-load-com) ;;; By Jimmy Bergmark


;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
(setq pref (vla-get-preferences (vlax-get-acad-object))) ;;; Website: www.jtbworld.com
;;; E-mail: info@jtbworld.com
(setq display (vla-get-display pref)) ;;; 1999-09-12 - First release
;;; 2002-05-14 - Bug fixed
;;; Set the ModelColor using the color dialog box ;;; Written for AutoCAD 2000+
(defun c:SetModelColor(/ col oldcol) ;;; Ex: (sopen "c:\\drawing1.dwg")
(setq oldcol (getGraphicsWinModelBackgrndColor)) ;;; Note that QAFLAGS might not be restored to 0 so you might want to add (setvar
(if (= oldcol nil) (setq oldcol 0)) "qaflags" 0) to acaddoc.lsp or any other startup lisp.
(if (= oldcol 0) (setq oldcol 1)) (vl-load-com)
(setq col (acad_colordlg oldcol nil)) ;;; opens and activates a file as Read-Only
(if (and (= oldcol 7) (= col 7)) (setq col 0)) (defun openRO (fna)
(if (/= col nil) (putGraphicsWinModelBackgrndColor col)) (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) fna :VLAX-
TRUE))
(princ)
)
)
(defun c:SetModelColor2004(/ col oldcol)
(defun sopen (fna / n)
(setq oldcol (getGraphicsWinModelBackgrndColor2004))
(if (= 0 (getvar "SDI"))
(if (= oldcol nil) (setq oldcol 0))
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) fna))
(if (= oldcol 0) (setq oldcol 1))
(progn
(setq col (acad_colordlg oldcol nil))
(if (not (equal 2 (logand 2 (getvar "qaflags"))))
(if (and (= oldcol 7) (= col 7)) (setq col 0))
(setvar "qaflags" (+ (getvar "qaflags") 2))
(if (/= col nil) (putGraphicsWinModelBackgrndColor col))
)
(princ)
(if (not (equal 4 (logand 4 (getvar "qaflags"))))
)
(setvar "qaflags" (+ (getvar "qaflags") 4))
)
;;; Set the LayoutColor using the color dialog box
(command "_.open")
(defun c:SetLayoutColor(/ col oldcol)
(if (not (equal 0 (getvar "dbmod")))
(setq oldcol (getGraphicsWinLayoutBackgrndColor))
(command "_y")
(if (= oldcol nil) (setq oldcol 0))
)
(if (= oldcol 0) (setq oldcol 1))
(command fna)
(setq col (acad_colordlg oldcol nil))
(setq n 0)
(if (and (= oldcol 7) (= col 7)) (setq col 0))
(while (and (< n 4)
(if (/= col nil) (putGraphicsWinLayoutBackgrndColor col))
(wcmatch (getvar "cmdnames") "*OPEN*")
(princ)
)
)
(T
(command "")
(defun getGraphicsWinModelBackgrndColor()
)
(OLE_color->ACI_color
(setq n (+ n 1))
(vla-get-GraphicsWinModelBackgrndColor
)
(vla-get-display (vla-get-preferences (vlax-get-acad-object)))))
(setvar "qaflags" 0)
)
)
)
(defun getGraphicsWinModelBackgrndColor2004 ()
)
(OLE_colorToACI
(vlax-variant-value
;;; By Jimmy Bergmark
(vlax-variant-change-type
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
(vla-get-GraphicsWinModelBackgrndColor
;;; Website: www.jtbworld.com
(vla-get-display
;;; E-mail: info@jtbworld.com
(vla-get-preferences (vlax-get-acad-object))
;;;
)
;;; Save and loads support paths to a text file
)
;;;
vlax-vbLong
;;; Change the path as wished
)
)
) (defun C:saveSupportPaths (/ files paths f)
) (vl-load-com)
(setq files (vla-get-files (vla-get-preferences (vlax-get-acad-object))))
(defun putGraphicsWinModelBackgrndColor(col) (setq paths (vla-get-supportpath files))
(vla-put-GraphicsWinModelBackgrndColor (setq f (open "r:\\paths.txt" "w"))
(vla-get-display (vla-get-preferences (vlax-get-acad-object))) (write-line paths f)
(ACI_color->OLE_color col) (close f)
) (princ)
) )

(defun getGraphicsWinLayoutBackgrndColor() (defun C:loadSupportPaths (/ files paths f)


(OLE_color->ACI_color (vl-load-com)
(vla-get-GraphicsWinLayoutBackgrndColor (setq files (vla-get-files (vla-get-preferences (vlax-get-acad-object))))
(vla-get-display (vla-get-preferences (vlax-get-acad-object))))) (setq f (open "r:\\paths.txt" "r"))
) (setq paths (read-line f))
(close f)
(defun putGraphicsWinLayoutBackgrndColor(col) (vla-put-supportpath files paths)
(vla-put-GraphicsWinLayoutBackgrndColor (princ)
(vla-get-display (vla-get-preferences (vlax-get-acad-object))) )
(ACI_color->OLE_color col)
)
)
;;; Change all text styles on all objects to specified text style
(defun getModelCrosshairColor() ;;; (ax:ChangeTextStyleName "ISOCPEUR")
(OLE_color->ACI_color (defun ax:ChangeTextStyleName (style / sset ename i)
(vla-get-ModelCrosshairColor (vl-load-com)
(vla-get-display (vla-get-preferences (vlax-get-acad-object))))) (setq i 0)
) (setq sset (ssget "X" '((-4 . "<OR") (0 . "MTEXT") (0 . "TEXT") (-4 . "OR>"))))
(if sset
(defun putModelCrosshairColor(col) (repeat (sslength sset)
(vla-put-ModelCrosshairColor (setq ename (ssname sset i))
(vla-get-display (vla-get-preferences (vlax-get-acad-object))) (setq i (1+ i))
(ACI_color->OLE_color col) (vla-put-stylename (vlax-ename->vla-object ename) style)
) )
) )
(setq sset nil)
(defun getLayoutCrosshairColor() )
(OLE_color->ACI_color ;;; th.LSP ver 1.0
(vla-get-LayoutCrosshairColor ;;; Set selected text or mtext to specified height
(vla-get-display (vla-get-preferences (vlax-get-acad-object))))) ;;; Text is resized based on the justification point
) ;;; By Jimmy Bergmark
;;; Copyright (C) 2008 JTB World, All Rights Reserved
(defun putLayoutCrosshairColor(col) ;;; Website: www.jtbworld.com
(vla-put-LayoutCrosshairColor ;;; E-mail: info@jtbworld.com
(vla-get-display (vla-get-preferences (vlax-get-acad-object))) ;;; 2008-03-14 - First release
(ACI_color->OLE_color col) ;;; Tested on AutoCAD 2009
) ;;; should be working on older and newer versions too.
)
(defun c:th (/ sset i txtheight textsize)
(defun getTextWinBackgrndColor() (vl-load-com)
(OLE_color->ACI_color (setq i 0)
(vla-get-TextWinBackgrndColor (setq sset (ssget '((-4 . "<OR") (0 . "MTEXT") (0 . "TEXT") (-4 . "OR>"))))
(vla-get-display (vla-get-preferences (vlax-get-acad-object))))) (if sset
) (progn
(setq textsize (getvar "textsize"))
(defun putTextWinBackgrndColor(col) (setq txtheight (getdist (strcat "\nSpecify text height <" (rtos textsize) ">: ")))
(vla-put-TextWinBackgrndColor (if (= txtheight nil) (setq txtheight textsize))
(vla-get-display (vla-get-preferences (vlax-get-acad-object))) (repeat (sslength sset)
(ACI_color->OLE_color col) (vla-put-height (vlax-ename->vla-object (ssname sset i)) txtheight)
) (setq i (1+ i))
) )
(setq sset nil)
(defun getTextWinTextColor() )
(OLE_color->ACI_color )
(vla-get-TextWinTextColor (princ)
(vla-get-display (vla-get-preferences (vlax-get-acad-object))))) )
)
(princ "\nRun with the TH command")
(defun putTextWinTextColor(col) (princ)
(vla-put-TextWinTextColor ;;; tsh0.LSP ver 1.0
(vla-get-display (vla-get-preferences (vlax-get-acad-object))) ;;; Set all text style's height to 0
(ACI_color->OLE_color col) ;;; By Jimmy Bergmark
) ;;; Copyright (C) 2008 JTB World, All Rights Reserved
) ;;; Website: www.jtbworld.com
;;; E-mail: info@jtbworld.com
(defun getAutoTrackingVecColor() ;;; 2008-03-08 - First release
(OLE_color->ACI_color ;;; Tested on AutoCAD 2009
(vla-get-AutoTrackingVecColor ;;; should be working on older versions too.
display))
) (defun C:TSH0 (/ ad style oldcmdecho)
(vl-load-com)
(defun putAutoTrackingVecColor(col) (setq ad (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vla-put-AutoTrackingVecColor (princ "Listed text style's height have been set to 0:")
display (vlax-for style (vla-get-TextStyles ad)
(ACI_color->OLE_color col) (if (and (/= (wcmatch (vla-get-Name style) "*|*") T) (/= (vla-get-Height style) 0.0))
) (progn
) (vla-put-Height style 0.0)
(princ "\n")
(princ (vla-get-Name style))
(defun OLE_color->ACI_color (olec) )
(vl-position )
(boole 1 )
(vlax-variant-value (setq oldcmdecho (getvar "cmdecho"))
(vlax-variant-change-type olec vlax-vbLong) (setvar "cmdecho" 0)
) (command "._regenall")
16777215 (setvar "cmdecho" oldcmdecho)
) (princ)
OLE_COLOR_LIST )
)
) (princ "\nRun with the TSH0 command")
(princ)
;;; By Jimmy Bergmark
(defun ACI_color->OLE_color (aci) ;;; Copyright (C) 1997-2012 JTB World, All Rights Reserved
; black is 0 ;;; Website: www.jtbworld.com
; white is 7 ;;; E-mail: info@jtbworld.com
(if (and (>= aci 0) (<= 255)) ;;; rotate selected text objects to specified angle
(setq aci (nth aci OLE_COLOR_LIST)
) (defun c:txtrot (/ sset i ed ang)
) (if (setq sset (ssget '((-4 . "<OR")
) (0 . "MTEXT")
(0 . "TEXT")
(setq OLE_COLOR_LIST (-4 . "OR>")
'(0 255 65535 65280 16776960 )
16711680 16711935 16777215 8421504 12632256 )
255 8421631 166 5460902 128 )
4210816 76 2500172 38 1250086 (progn
16639 8429567 10662 5466278 8320 (setq ang (getangle "Specify rotation angle <0>: "))
4214912 4940 2502732 2598 1251366 (if (null ang)
33023 8437759 21414 5471398 16512 (setq ang 0)
4219008 9804 2505036 4902 1252646 )
49151 8445951 31910 5476774 24704 (repeat (setq i (sslength sset))
4223104 14668 2507596 7462 1253670 (setq ed (entget (ssname sset (setq i (1- i)))))
65535 8454143 42662 5482150 32896 (entmod (subst (cons 50 ang)
4227200 19532 2509900 9766 1254950 (assoc 50 ed)
65471 8454111 42620 5482129 32864 ed
4227184 19513 2509891 9757 1254945 )
65408 8454079 42579 5482108 32832 )
4227168 19494 2509881 9747 1254941 )
65344 8454047 42537 5482088 32800 )
4227152 19475 2509872 9738 1254936 )
65280 8454016 42496 5482067 32768 (setq sset nil)
4227136 19456 2509862 9728 1254931 (princ)
4259584 10485632 2729472 6858323 2129920 )
5275712 1264640 3165222 665088 1582611 ;;; By Jimmy Bergmark
8453888 12582784 5481984 8169043 4227072 ;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
6324288 2509824 3755046 1254912 1910291 ;;; Website: www.jtbworld.com
12582656 14679936 8168960 9545299 6324224 ;;; E-mail: info@jtbworld.com
7372864 3755008 4410406 1910272 2172435 (vl-load-com)
16776960 16777088 10921472 10921555 8421376 ;;; get the viewportcenter
8421440 5000192 5000230 2500096 2500115 (setq viewportcenter
16760576 16768896 10910720 10916179 8413184 (vlax-safearray->list
8417344 4995328 4997926 2497792 2498835 (vlax-variant-value
16744448 16760704 10900224 10910803 8404992 (vla-get-center
8413248 4990464 4995366 2495232 2497811 (vla-get-activepviewport
16728064 16752512 10889472 10905683 8396800 (vla-get-activedocument
8409152 4985600 4993062 2492928 2496531 (vlax-get-acad-object))))))
16711680 16744576 10878976 10900307 8388608 )
8405056 4980736 4990502 2490368 2495251
16711744 16744607 10879017 10900328 8388640
8405072 4980755 4990512 2490378 2495256 ;;; viewsIO.lsp
16711808 16744639 10879059 10900348 8388672 ;;;
8405088 4980774 4990521 2490387 2495261 ;;; Export and import views
16711871 16744671 10879100 10900369 8388704 ;;;
8405104 4980793 4990531 2490397 2495265 ;;; c:ExportViews
16711935 16744703 10879142 10900390 8388736 ;;; c:ImportViews
8405120 4980812 4990540 2490406 2495270 ;;; c:-ExportViews
12517631 14647551 8126630 9524134 6291584 ;;; c:-ImportViews
7356544 3735628 4400716 1900582 2167590 ;;;
8388863 12550399 5439654 8147878 4194432 ;;; By Jimmy Bergmark
6307968 2490444 3745356 1245222 1905446 ;;; Copyright (C) 1997-2008 JTB World, All Rights Reserved
4194559 10453247 2687142 6837158 2097280 ;;; Website: www.jtbworld.com
5259392 1245260 3155532 655398 1577766 ;;; E-mail: info@jtbworld.com
5526612 5987163 10000536 12303291 14540253 ;;;
16777215 ;;; 2000-06-27
) ;;;
) ;;; Tested on AutoCAD 2000-2004
;;;
;;; Only for AutoCAD 2004 ;;; Modified by Marko Ribar 2012-04-21
(defun RGBtoACI (RGB-codes) ;;;
(vl-load-com) ;;; Tested on AutoCAD 2012
(setq ColorObj (vla-GetInterfaceObject
(vlax-get-acad-object) (vl-load-com)
"AutoCAD.AcCmColor.16"
) (defun c:ExportViews (/ fn)
) (if (setq fn
(vla-setRGB ColorObj (car RGB-codes) (cadr RGB-codes) (caddr RGB-codes)) (getfiled "Export views to"
; alternatively done as below (strcat (vl-filename-base (getvar "dwgname")) ".txt")
; (vlax-invoke-method ColorObj 'setRGB (car RGB-codes) (cadr RGB-codes) "txt"
(caddr RGB-codes)) 1
(vla-get-ColorIndex ColorObj) )
) )
(ExportViews fn)
(defun RGBtoOLE_color2 (RGB-codes) )
(+ (* (car RGB-codes) 65536) (princ)
(* (cadr RGB-codes) 256) )
(caddr RGB-codes)
) (defun c:ImportViews (/ fn)
) (if (setq fn
(getfiled "Import views from"
(defun OLEtoRGB_color2 (OLE_color / a b c) (strcat (vl-filename-base (getvar "dwgname")) ".txt")
(setq a (fix (/ OLE_color 65536.0))) "txt"
(setq b (fix (/ (- OLE_color (* a 65536)) 256.0))) 16
(setq c (- OLE_color (* a 65536) (* b 256))) )
(list a b c) )
) (ImportViews fn)
)
;; Convert TrueColor into a list of RGB (princ)
(defun OLEtoRGB_color (OLE_color / r g b) )
(setq r (lsh OLE_color -16))
(setq g (lsh (lsh OLE_color 16) -24)) (defun c:-ExportViews (/ fn x)
(setq b (lsh (lsh OLE_color 24) -24)) (setq fn (strcat (vl-filename-base (getvar "dwgname")) ".txt"))
(list r g b) (if (setq fn
) (findfile
(if (= ""
;; Convert a list of RGB to TrueColor (setq nn (getstring
;;; (RGBtoOLE_color '(118 118 118)) T
(defun RGBtoOLE_color (RGB-codes) (strcat "Enter filename <"
(setq r (lsh (car RGB-codes) 16)) fn
(setq g (lsh (cadr RGB-codes) 8)) ">: "
(setq b (caddr RGB-codes)) )
(+ (+ r g) b) )
) )
)
; For AutoCAD 2004 fn
; (OLE_colorToACI 5987163) returns 251 nn
(defun OLE_colorToACI (OLE_color) )
(RGBtoACI (OLEtoRGB_color OLE_color)) )
) )
(progn
(defun C:getColor(/) (initget "Yes No")
(setq ename (car (entsel "\nPick an object with true color:"))) (setq x (getkword "\nFile exists. Overwrite? [Yes/No] <No>: "))
(setq edata (entget ename)) (if (= x "Yes") (ExportViews fn))
;; we have a true color. )
(setq tcol (cdr (assoc 420 edata))) (princ "\nFile not found.")
(princ "\n true color = ")(princ tcol) )
;; convert it to a list of RGB. (princ)
(setq rgb (OLEtoRGB_color tcol)) )
(princ "\n rgb = ")(princ rgb)
(princ) (defun c:-ImportViews (/ fn)
) (setq fn (strcat (vl-filename-base (getvar "dwgname")) ".txt"))
(if (setq fn
(defun C:setColor(/) (findfile
(setq ename (car (entsel "\nPick an object to set a true color:"))) (if (= ""
(setq edata (entget ename)) (setq nn (getstring
;; set a true color from a list of rgb values.(R=10 G=100 B=200) T
(setq rgb (list 10 100 200)) (strcat "Enter filename <"
(setq tcol (RGBtoOLE_color rgb)) fn
;; and set it. ">: "
(setq edata (subst (cons 420 tcol) (assoc 420 edata) edata)) )
(entmod edata) )
(princ "\n rgb = ")(princ rgb) )
(princ "\n true color = ")(princ tcol) )
(princ) fn
) nn
)
)
;;; (ACItoRGB 123) )
(defun ACItoRGB (aci) (ImportViews fn)
(if (and (>= aci 0) (<= 255)) (princ "\nFile not found.")
(nth aci RGB_list) )
) (princ)
) )

(setq RGB_list '( (defun ExportViews (fn / e tl f ed)


(0 0 0) (while (setq e (tblnext "VIEW" (null e)))
(255 0 0) (setq tl (cons (cdr (assoc 2 e)) tl))
(255 255 0) )
(0 255 0) (setq f (open fn "w"))
(0 255 255) (if f
(0 0 255) (progn
(255 0 255) (princ "Following views exported:\n")
(255 255 255) (foreach view tl
(128 128 128) (setq ed (entget (tblobjname "view" view)))
(192 192 192) (if (assoc 348 ed) (prin1 (cons (cons 0 "VISUALSTYLE") (member (assoc 100
(255 0 0) (entget (cdr (assoc 348 ed)))) (entget (cdr (assoc 348 ed))))) f))
(255 127 127) (if (assoc 348 ed) (princ "\n" f))
(165 0 0) (prin1 (cons (cons 0 "VIEW") (if (assoc 348 ed) (reverse (cdr (reverse (member
(assoc 100 ed) ed)))) (member (assoc 100 ed) ed))) f)
(165 82 82)
(princ "\n" f)
(127 0 0)
(prin1 view)
(127 63 63)
(terpri)
(76 0 0)
)
(76 38 38)
(close f)
(38 0 0)
)
(38 19 19)
)
(255 63 0)
)
(255 159 127)
(165 41 0)
(defun ImportViews (fn / tl assoc348 assoc330 en330 en348 f)
(165 103 82)
(setq f (open fn "r"))
(127 31 0)
(if f
(127 79 63)
(progn
(76 19 0)
(princ "Following views imported:\n")
(76 47 38)
(while (setq tl (read-line f))
(38 9 0)
(setq tl (read tl))
(38 23 19)
(if (eq (cdr (assoc 0 tl)) "VIEW")
(255 127 0)
(progn
(255 191 127)
(entmake tl)
(165 82 0)
(print (cdr (assoc 2 tl)))
(165 124 82)
)
(127 63 0)
)
(127 95 63)
(if (eq (cdr (assoc 0 tl)) "VISUALSTYLE")
(76 38 0)
(progn
(76 57 38)
(vlax-for di (vla-get-dictionaries (vla-get-activedocument (vlax-get-
(38 19 0)
acad-object))) (if (eq (vl-catch-all-apply 'vla-get-name (list di))
(38 28 19) "ACAD_VISUALSTYLE") (setq en330 (vlax-vla-object->ename di))))
(255 191 0) (setq assoc330 (cons 330 en330))
(255 223 127) (setq assoc348 (cons 348 (setq en348 (entmakex tl))))
(165 124 0) (entmod (subst assoc330 (assoc 330 (entget en348)) (entget en348)))
(165 145 82) (setq tl (read-line f))
(127 95 0) (setq tl (read tl))
(127 111 63) (setq tl (reverse (cons assoc348 (reverse tl))))
(76 57 0) (entmake tl)
(76 66 38) (print (cdr (assoc 2 tl)))
(38 28 0) )
(38 33 19) )
(255 255 0) )
(255 255 127) (close f)
(165 165 0) )
(165 165 82) )
(127 127 0) )
(127 127 63)
(76 76 0)
(76 76 38) (princ)
(38 38 0) ;;;---------------------------------------------------------------------------;
(38 38 19) ;;;
(191 255 0) ;;; VPlayers.lsp
(223 255 127) ;;;
(124 165 0) ;;; By Jimmy Bergmark
(145 165 82) ;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
(95 127 0) ;;; Website: www.jtbworld.com
(111 127 63) ;;; E-mail: info@jtbworld.com
(57 76 0) ;;;
(66 76 38) ;;; 2000-09-07 - First release
(28 38 0) ;;; Tested on AutoCAD 2000
(33 38 19) ;;;
(127 255 0) ;;;---------------------------------------------------------------------------;
(191 255 127) ;;; DESCRIPTION
(82 165 0) ;;;
(124 165 82) ;;; c:SaveVPlayers - Save frozen viewport layers to file
(63 127 0) ;;; c:LoadVPlayers - Load and restore frozen viewport layers from file
(95 127 63) ;;; c:CopyVPlayers - Select one viewport and get the layersettings
(38 76 0) ;;; then select the destination viewport(s) to inherit these
(57 76 38) ;;;---------------------------------------------------------------------------;
(19 38 0) (vl-load-com)
(28 38 19) (defun dxf (n ed) (cdr (assoc n ed)))
(63 255 0)
(159 255 127) ;;; return a list of frozen layers in current viewport
(41 165 0) ;;; ex. (viewport-frozen-layer-list) -> ("Layer3" "Layer4")
(103 165 82) ;;; alt. with Express Tools (ACET-VIEWPORT-FROZEN-LAYER-LIST (ACET-
(31 127 0) CURRENTVIEWPORT-ENAME))
(79 127 63) (defun viewport-frozen-layer-list (/ cvp)
(19 76 0) (if (= 0 (getvar "tilemode"))
(47 76 38) (if (/= 1 (setq cvp (getvar "cvport")))
(9 38 0) (apply
(23 38 19) 'append
(0 255 0) (mapcar
(127 255 127) '(lambda (x)
(0 165 0) (if (= 1003 (car x))
(82 165 82) (list (cdr x))
(0 127 0) )
(63 127 63) )
(0 76 0) (cdadr
(38 76 38) (assoc
(0 38 0) -3
(19 38 19) (entget
(0 255 63) (ssname
(127 255 159) (ssget "_X"
(0 165 41) (list (cons 69 cvp) (cons 410 (getvar "ctab")))
(82 165 103) )
(0 127 31) 0
(63 127 79) )
(0 76 19) '("acad")
(38 76 47) )
(0 38 9) )
(19 38 23) )
(0 255 127) )
(127 255 191) )
(0 165 82) )
(82 165 124) )
(0 127 63) )
(63 127 95)
(0 76 38) (defun GetVPlayers (/ ss ent vpno)
(38 76 57) (command "._pspace")
(0 38 19) (princ "\nSelect source viewport: ")
(19 38 28) (setq ss (ssget ":E:S" '((0 . "VIEWPORT"))))
(0 255 191) (if ss
(127 255 223) (progn
(0 165 124) (setq ent (ssname ss 0))
(82 165 145) (setq ss nil)
(0 127 95) (setq vpno (dxf 69 (entget ent)))
(63 127 111) (command "._mspace")
(0 76 57) (setvar "cvport" vpno)
(38 76 66) (viewport-frozen-layer-list)
(0 38 28) )
(19 38 33) )
(0 255 255) )
(127 255 255)
(0 165 165)
(82 165 165) (defun c:SaveVPlayers (/ fn oldcmdecho VAL f *error* restore layers)
(0 127 127) (defun *error* (str)
(63 127 127) (restore)
(0 76 76) (if str
(38 76 76) (prompt (strcat "Error: " str))
(0 38 38) )
(19 38 38) (princ)
(0 191 255) )
(127 223 255) (defun restore ()
(0 124 165) (command "._undo" "_E")
(82 145 165) (setvar "cmdecho" oldcmdecho)
(0 95 127) )
(63 111 127)
(0 57 76) (setq oldcmdecho (getvar "cmdecho"))
(38 66 76) (setvar "cmdecho" 0)
(0 28 38) (command "._UNDO" "_BE")
(19 33 38) (cond
(0 127 255) ((not (equal 0 (getvar "tilemode")))
(127 191 255) (princ
(0 82 165) "\n Command not allowed unless TILEMODE is set to 0 "
(82 124 165) )
(0 63 127) )
(63 95 127) ((> 2
(0 38 76) (sslength
(38 57 76) (ssget "_x"
(0 19 38) (list (cons 0 "VIEWPORT") (cons 410 (getvar "ctab")))
(19 28 38) )
(0 63 255) )
(127 159 255) )
(0 41 165) (princ "\n Command works with one or more viewports only "
(82 103 165) )
(0 31 127) )
(63 79 127) ((not (setq fn
(0 19 76) (getfiled "Save ViewPort layer list as"
(38 47 76) (vl-filename-base (getvar "dwgname"))
(0 9 38) "vpl"
(19 23 38) 1
(0 0 255) )
(127 127 255) )
(0 0 165) )
(82 82 165) )
(0 0 127) ((not (setq f (open fn "w")))
(63 63 127) (princ "\n Cannot write to file!")
(0 0 76) )
(38 38 76) (T
(0 0 38) (setq layers (GetVPlayers))
(19 19 38) (if layers
(63 0 255) (prin1 layers f)
(159 127 255) (princ "\n There are no frozen VP layers.")
(41 0 165) )
(103 82 165) (command "._pspace")
(31 0 127) (close f)
(79 63 127) )
(19 0 76) )
(47 38 76) (restore)
(9 0 38) (princ)
(23 19 38) )
(127 0 255)
(191 127 255) (defun PutVPlayers (layers / VAL ss)
(82 0 165) (if layers
(124 82 165) (progn
(63 0 127) (princ "\nSelect destination viewport: ")
(95 63 127) (command "._pspace")
(38 0 76) (setq ss (ssget ":E" '((0 . "VIEWPORT"))))
(57 38 76) (if ss
(19 0 38) (progn
(28 19 38) (command "_.vplayer" "_thaw" "*" "_select" ss "")
(191 0 255) (foreach VAL layers (command "_freeze" VAL "_select" ss ""))
(223 127 255) (setq ss nil)
(124 0 165) (command "")
(145 82 165) )
(95 0 127) )
(111 63 127) )
(57 0 76) )
(66 38 76) )
(28 0 38)
(33 19 38) (defun c:LoadVPlayers (/ oldcmdecho fn tl lst *error* restore)
(255 0 255) (defun *error* (str)
(255 127 255) (restore)
(165 0 165) (if str
(165 82 165) (prompt (strcat "Error: " str))
(127 0 127) )
(127 63 127) (princ)
(76 0 76) )
(76 38 76) (defun restore ()
(38 0 38) (command "._undo" "_E")
(38 19 38) (setvar "cmdecho" oldcmdecho)
(255 0 191) )
(255 127 223)
(165 0 124) (setq oldcmdecho (getvar "cmdecho"))
(165 82 145) (setvar "cmdecho" 0)
(127 0 95) (command "._UNDO" "_BE")
(127 63 111) (cond
(76 0 57) ((not (equal 0 (getvar "tilemode")))
(76 38 66) (princ
(38 0 28) "\n Command not allowed unless TILEMODE is set to 0 "
(38 19 33) )
(255 0 127) )
(255 127 191) ((> 2
(165 0 82) (sslength
(165 82 124) (ssget "_x"
(127 0 63) (list (cons 0 "VIEWPORT") (cons 410 (getvar "ctab")))
(127 63 95) )
(76 0 38) )
(76 38 57) )
(38 0 19) (princ "\n Command works with one or more viewports only "
(38 19 28) )
(255 0 63) )
(255 127 159) ((not (setq fn
(165 0 41) (getfiled "Open ViewPort layer list"
(165 82 103) (vl-filename-base (getvar "dwgname"))
(127 0 31) "vpl"
(127 63 79) 0
(76 0 19) )
(76 38 47) )
(38 0 9) )
(38 19 23) )
(0 0 0) ((not (setq f (open fn "r")))
(51 51 51) (princ "\n Cannot read file!")
(102 102 102) )
(153 153 153) (T
(204 204 204) (setq lst (read (read-line f)))
(255 255 255) (if (= (type lst) 'LIST)
) (PutVPlayers lst)
) )
(command "._pspace")
;;; Examples (close f)
;;; )
;;; (RGBtoACI '(91 91 91)) returns 251 )
;;; (RGBtoACI '(118 118 118)) returns 8 safe
;;; (RGBtoOLE_color '(118 118 118)) gives OLE_color=7763574 (restore)
;;; (OLEtoRGB_color 7763574) gives (118 118 118) (princ)
;;; (RGBtoOLE_color '(91 91 91)) gives OLE_color=5987163 )
;;; (OLEtoRGB_color 5987163) gives (91 91 91)
;;; (RGBtoACI '(101 101 101)) returns 8 (defun c:CopyVPlayers (/ oldcmdecho *error* restore layers)
;;; (OLEtoRGB_color 6645093) returns (101 101 101) (defun *error* (str)
;;; (ACItoRGB 123) (restore)
(if str
;;; Missing is conversion from ACI to RGB or ACI to OLE_color (prompt (strcat "Error: " str))
;;; DisplayProperties.LSP )
;;; Miscellaneous commands related to the Display tab on the Options dialog (princ)
;;; By Jimmy Bergmark )
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved (defun restore ()
;;; Website: www.jtbworld.com (command "._undo" "_E")
;;; E-mail: info@jtbworld.com (setvar "cmdecho" oldcmdecho)
;;; 2000-03-29 - First release )
;;; Tested on AutoCAD 2000
(setq oldcmdecho (getvar "cmdecho"))
(vl-load-com) (setvar "cmdecho" 0)
(command "._UNDO" "_BE")
; Get Model Space Background Color (cond
(defun getMoBgColor() ((not (equal 0 (getvar "tilemode")))
(ole_color (princ
(vla-get-GraphicsWinModelBackgrndColor "\n Command not allowed unless TILEMODE is set to 0 "
(vla-get-display (vla-get-preferences (vlax-get-acad-object))))) )
) )
((> 3
; Get Layout Space Background Color (sslength
(defun getLaBgColor() (ssget "_x"
(ole_color (list (cons 0 "VIEWPORT") (cons 410 (getvar "ctab")))
(vla-get-GraphicsWinLayoutBackgrndColor )
(vla-get-display (vla-get-preferences (vlax-get-acad-object))))) )
) )
(princ "\n Command works with two or more viewports only "
; Put Model Space Background Color )
(defun putMoBgColor(bgc) )
(vla-put-GraphicsWinModelBackgrndColor (T
(vla-get-display (vla-get-preferences (vlax-get-acad-object))) (setq layers (GetVPlayers))
bgc (if layers
) (PutVPlayers layers)
) (princ "\n There are no frozen VP layers.")
)
; Put Layout Space Background Color (command "._pspace")
(defun putLaBgColor(bgc) )
(vla-put-GraphicsWinLayoutBackgrndColor )
(vla-get-display (vla-get-preferences (vlax-get-acad-object))) (restore)
bgc (princ)
) )
)
(princ)
(defun ole_color(olec) ;;; vp-outline.lsp
(vlax-variant-value ;;;
(vlax-variant-change-type olec vlax-vbDouble) ;;; Creates a polyline in modelspace that
) ;;; has the outline of the selected viewport.
) ;;; Supports clipped viewports. polyline is supported
;;; ellipse, spline, region and circle not supported at this point
; Get the display of the Plot Setup dialog when a new layout is created. ;;; If vp-outline is called when in mspace it detects
(defun getLayoutShowPlotSetup() ;;; the active viewport.
(vla-get-LayoutShowPlotSetup ;;;
(vla-get-display (vla-get-preferences (vlax-get-acad-object)))) ;;; c:vp-outline
) ;;;
;;; By Jimmy Bergmark
; Put the display of the Plot Setup dialog when a new layout is created. ;;; Copyright (C) 1997-2013 JTB World, All Rights Reserved
(defun putLayoutShowPlotSetup(state) ;;; Website: www.jtbworld.com
(vla-put-LayoutShowPlotSetup ;;; E-mail: info@jtbworld.com
(vla-get-display (vla-get-preferences (vlax-get-acad-object))) state) ;;;
) ;;; 2000-04-10
;;; 2003-11-19 Added support for drawing the outline in other ucs/view than
; Toggles the display of the Plot Setup dialog when a new layout is created. world/current
(defun toggleLayoutShowPlotSetup() ;;;
(if (= (getLayoutShowPlotSetup) :vlax-true) ;;; 2006-04-06 Added support for twisted views Tom Beauford
(putLayoutShowPlotSetup :vlax-false) ;;; 2013-06-08 Added support for circular viewports
(putLayoutShowPlotSetup :vlax-true) ;;;
) ;;; Should work on AutoCAD 2000 and newer
) (vl-load-com)

(defun dxf (n ed) (cdr (assoc n ed)))


;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved (defun ax:List->VariantArray (lst)
;;; Website: www.jtbworld.com (vlax-Make-Variant
;;; E-mail: info@jtbworld.com (vlax-SafeArray-Fill
(vl-load-com) (vlax-Make-SafeArray
; (setq ad (vla-get-activedocument (vlax-get-acad-object))) vlax-vbDouble
(cons 0 (- (length lst) 1))
(defun GetCanonicalMediaNames (ad) )
(vla-RefreshPlotDeviceInfo lst
(vla-get-activelayout ad)) )
(vlax-safearray->list )
(vlax-variant-value )
(vla-GetCanonicalMediaNames
(vla-item (vla-get-layouts ad) "Model")))) (defun c:vp-outline (/ ad ss ent pl plist xy n vpbl vpur msbl msur ven vpno ok
) circ)
(setq ad (vla-get-activedocument (vlax-get-acad-object)))
(defun GetLocaleMediaNames (ad / mn mnl) (if (= (getvar "tilemode") 0)
(setq la (vla-item (vla-get-layouts ad) "Model")) (progn
(foreach mn (GetCanonicalMediaNames ad) (if (= (getvar "cvport") 1)
(setq mnl (cons (vla-GetLocaleMediaName la mn) mnl)) (progn
) (if (setq ss (ssget ":E:S" '((0 . "VIEWPORT"))))
(reverse mnl) (progn (setq ent (ssname ss 0))
) (setq vpno (dxf 69 (entget ent)))
(vla-Display (vlax-ename->vla-object ent) :vlax-true)
(defun GetPlotDevices (ad) (vla-put-mspace ad :vlax-true) ; equal (command
"._mspace")
(vla-RefreshPlotDeviceInfo
(vla-get-activelayout ad)) ; this to ensure trans later is working on correct viewport
(vlax-safearray->list (setvar "cvport" vpno)
(vlax-variant-value ; (vla-put-mspace ad :vlax-false) ; equal (command "._pspace")
(vla-getplotdevicenames (setq ok T)
(vla-item (vla-get-layouts ad) "Model")))) (setq ss nil)
) )
)
; Plot Device in active Layout )
(defun GetActivePlotDevice (ad) (setq ent (vlax-vla-object->ename (vla-get-activepviewport ad))
(vla-get-ConfigName ok T
(vla-get-ActiveLayout ad)) )
) )
(if ok
(defun GetPlotStyleTableNames (ad) (progn (setq circle nil)
(vla-RefreshPlotDeviceInfo (setq ven (vlax-ename->vla-object ent))
(vla-get-activelayout ad)) (if (/= 1 (logand 1 (dxf 90 (entget ent)))) ; detect perspective
(vlax-safearray->list (progn (if (= (vla-get-clipped ven) :vlax-false)
(vlax-variant-value (progn ; not clipped
(vla-getplotstyletablenames (vla-getboundingbox ven 'vpbl 'vpur)
(vla-item (vla-get-layouts ad) "Model")))) (setq vpbl (trans (vlax-safearray->list
) vpbl) 3 2)
msbl (trans vpbl 2 1)
(defun ListAllMediaNames(ad / al cn pd apmn) msbl (trans msbl 1 0)
(setq al (vla-get-activelayout ad)) vpur (trans (vlax-safearray->list
vpur) 3 2)
(setq cn (vla-get-configname al))
msur (trans vpur 2 1)
(foreach pd (GetPlotDevices ad)
msur (trans msur 1 0)
(if (/= pd "None")
vpbr (list (car vpur) (cadr vpbl) 0)
(progn
msbr (trans vpbr 2 1)
(vla-put-configname al pd)
msbr (trans msbr 1 0)
(setq apmn (cons pd apmn))
vpul (list (car vpbl) (cadr vpur) 0)
(setq apmn (cons (GetCanonicalMediaNames ad) apmn))
msul (trans vpul 2 1)
)
msul (trans msul 1 0)
)
plist (list (car msbl)
)
(cadr msbl)
(if (/= cn "None") (vla-put-configname al cn))
(car msbr)
(reverse apmn)
(cadr msbr)
)
(car msur)
(cadr msur)
; (ListAllLocalMediaNames (vla-get-activedocument (vlax-get-acad-object)))
(car msul)
(defun ListAllLocalMediaNames(ad / al cn pd apmn)
(cadr msul)
(setq al (vla-get-activelayout ad))
)
(setq cn (vla-get-configname al))
)
(foreach pd (GetPlotDevices ad)
)
(if (/= pd "None")
(progn ; clipped
(progn
(setq pl (entget (dxf 340 (entget ent))))
(vla-put-configname al pd)
(if (= (dxf 0 pl) "CIRCLE")
(setq apmn (cons pd apmn))
(setq circle T)
(setq apmn (cons (GetLocaleMediaNames ad) apmn))
(progn (setq plist (vla-get-coordinates
)
(vlax-ename-
)
>vla-object (dxf -1 pl))
)
)
(if (/= cn "None") (vla-put-configname al cn))
plist (vlax-safearray->list
(reverse apmn) (vlax-variant-value plist))
) n 0
pl nil
; (GetCanonicalMediaNamesOfConfigname ad "Acrobat PDFWriter") )
(defun GetCanonicalMediaNamesOfConfigname(ad cn / oldcn al cmn) (repeat (/ (length plist) 2)
(setq al (vla-get-ActiveLayout ad)) (setq xy (trans (list (nth n
(setq oldcn (vla-get-configname al)) plist) (nth (1+ n) plist)) 3 2)
(vla-put-configname al cn) xy (trans xy 2 1)
(vla-RefreshPlotDeviceInfo al) xy (trans xy 1 0)
(setq cmn (GetCanonicalMediaNames ad)) pl (cons (car xy) pl)
(if (/= oldcn "None") (vla-put-configname al oldcn)) pl (cons (cadr xy)
cmn pl)
) n (+ n 2)
)
; (GetLocalMediaNamesOfConfigname ad "Acrobat PDFWriter") )
(defun GetLocalMediaNamesOfConfigname(ad cn / oldcn al cmn) (setq plist (reverse pl))
(setq al (vla-get-ActiveLayout ad)) )
(setq oldcn (vla-get-configname al)) )
(vla-put-configname al cn) )
(vla-RefreshPlotDeviceInfo al) )
(setq cmn (GetLocaleMediaNames ad)) (if circle
(if (/= oldcn "None") (vla-put-configname al oldcn)) (vla-AddCircle
cmn (vla-get-ModelSpace ad)
) (ax:List->VariantArray
(trans (trans (trans (dxf 10 pl) 1 0) 2 1) 3 2)
)
;;; getvpscale.lsp (/ (dxf 40 pl) (caddr (trans '(0 0 1) 2 3)))
;;; )
;;; Get Viewport Scale in active viewport or in selected (vla-Put-Closed
;;; Supports viewports with clipping boundary (vla-AddLightWeightPolyline
;;; By Jimmy Bergmark (vla-get-ModelSpace ad)
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved (ax:List->VariantArray plist)
;;; Website: www.jtbworld.com )
;;; E-mail: info@jtbworld.com :vlax-True
;;; 2000-05-03 - First release )
;;; 2000-05-09 - Detects perspective view )
;;; Tested on AutoCAD 2000 )
(defun c:getvpscale (/ ss ent) )
(defun printscale (/ data cvsize cvhgt) )
(setq cvscale (vla-get-customscale (vlax-ename->vla-object ent))) )
(princ "\nPS:MS == ") )
(cond )
((> cvscale 1) (if ss
(princ (rtos cvscale 2)) (vla-put-mspace ad :vlax-false)
(princ ":1") ) ; equal (command "._pspace"))
) (princ)
(T )
(princ "1:") ;;;---------------------------------------------------------------------------;
(princ (rtos (/ 1 cvscale) 2)) ;;;
) ;;; vpsel.lsp
) ;;;
) ;;; By Jimmy Bergmark
(vl-load-com) ;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
(if (= (getvar "tilemode") 0) ;;; Website: www.jtbworld.com
(if (= (getvar "cvport") 1) ;;; E-mail: info@jtbworld.com
(if (/= (setq ss (ssget ":E:S" '((0 . "VIEWPORT")))) nil) ;;;
(if (/= 1 (logand 1 (cdr (assoc 90 (entget (setq ent (ssname ss 0))))))) ;;; 2000-04-14 - First release
(printscale) ;;; Tested on AutoCAD 2000
(princ "\n Command not allowed in perspective view.") ;;;
) ;;;---------------------------------------------------------------------------;
(princ " No viewport found.") ;;; DESCRIPTION
) ;;;
(progn ;;; Select all visible objects in selected or active paperspace viewport
(setq ent (vlax-vla-object->ename ;;; Works transparently when in modelspace and for polygonal viewports too
(vla-get-activepviewport ;;; Example1: ERASE ALL R 'VPC >>> Erase all in model except what is visible
(vla-get-activedocument (vlax-get-acad-object))))) ;;; Example2: (command "erase" "all" "r" (c:vpc) "")
(if (/= 1 (logand 1 (cdr (assoc 90 (entget ent))))) ;;; Example3: VPC ERASE >>> VPC is run previous the command and the objects
(printscale) ;;; are also in previous selection set
(princ "\n Command not allowed in perspective view.") ;;;
) ;;; c:vpc - select all visible objects with crossing in viewport
) ;;; c:vpw - select all visible objects with window in viewport
) ;;;---------------------------------------------------------------------------;
(princ "\n Command not allowed unless TILEMODE is set to 0.")
) (defun c:vpc ()
(setq ss nil) (vpsel "C")
(princ) (princ)
) )

;;; return viewport scale if allowed else nil (defun c:vpw ()


(defun getvpscale1 (/ ss ent) (vpsel "W")
(vl-load-com) (princ)
(if (= (getvar "tilemode") 0) )
(if (= (getvar "cvport") 1)
(if (/= (setq ss (ssget ":E:S" '((0 . "VIEWPORT")))) nil) (defun dxf (n ed) (cdr (assoc n ed)))
(if (/= 1 (logand 1 (cdr (assoc 90 (entget (setq ent (ssname ss 0)))))))
(vla-get-customscale (vlax-ename->vla-object ent)) (defun vpsel (typ / ad ss ent vpno ok vpbl vpur
) msbl msur msul mslr ss1 pl nlist x n
) )
(progn (vl-load-com)
(setq ent (vlax-vla-object->ename (setq ok t)
(vla-get-activepviewport (if (= (getvar "tilemode") 0)
(vla-get-activedocument (vlax-get-acad-object))))) (progn
(if (/= 1 (logand 1 (cdr (assoc 90 (entget ent))))) (setq ad (vla-get-activedocument (vlax-get-acad-object)))
(vla-get-customscale (vlax-ename->vla-object ent)) (if (= (getvar "cvport") 1)
) (if (and (= (getvar "cmdactive") 0)
) (/= (setq ss (ssget ":E:S" '((0 . "VIEWPORT")))) nil)
) )
) (progn
) (setq ent (ssname ss 0))
(setq vpno (dxf 69 (entget ent)))
;;; return viewport scale if allowed else nil (vla-Display (vla-get-activepviewport ad) :vlax-true)
;;; no support for perspective view (vla-put-mspace ad :vlax-true)
(defun getvpscale2 (/ ss vpno vpsc) (setvar "cvport" vpno)
(if (= (getvar "tilemode") 0) )
(if (= (getvar "cvport") 1) (progn
(if (/= (setq ss (ssget ":E:S" '((0 . "VIEWPORT")))) nil) (setq ok nil)
(progn )
(setq vpno (cdr (assoc 69 (entget (ssname ss 0))))) )
(command "_.mspace") (setq ent (vlax-vla-object->ename (vla-get-activepviewport ad)))
(setvar "cvport" vpno) )
(setq vpsc (caddr (trans '(0 0 1) 2 3))) (if (and ok (/= 1 (logand 1 (dxf 90 (setq ed (entget ent))))))
(command "_.pspace") (progn
vpsc (if (= (vla-get-clipped (vlax-ename->vla-object ent))
) :vlax-false
) )
(caddr (trans '(0 0 1) 2 3)) (progn
) (vla-getboundingbox
) (vla-get-activepviewport ad)
) 'vpbl
'vpur
;;; return viewport scale )
;;; no support for viewports with clipping boundary (setq msbl (trans (vlax-safearray->list vpbl) 3 2))
;;; no support for perspective view (setq msur (trans (vlax-safearray->list vpur) 3 2))
(defun getvpscale3(/ vpno vpsc) (setq msul (list (car msbl) (cadr msur)))
(setq vpno (cdr (assoc 69 (entget (car (entsel)))))) (setq mslr (list (car msur) (cadr msbl)))
(command "mspace") (setq ss1
(setvar "cvport" vpno) (ssget (strcat typ "P") (list msbl msul msur mslr))
(setq vpsc (caddr (trans '(0 0 1) 2 3))) )
(command "pspace") )
vpsc (progn
) (setq pl (entget (dxf 340 (entget ent))))
(setq nlist nil)
;;; return scale in active viewport (foreach x pl
;| (if (eq 10 (car x))
(caddr (trans '(0 0 1) 2 3)) (setq nlist (cons (trans (cdr x) 3 2) nlist))
|; )
)
(setq ss1 (ssget (strcat typ "P") nlist))
)
;;; By Jimmy Bergmark )
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved (sssetfirst nil ss1)
;;; Website: www.jtbworld.com (if ss1
;;; E-mail: info@jtbworld.com (setq n (sslength ss1))
; (setq n 0)
; 1999-12-22 First release )
; 2000-03-02 Simplified command entry and code (princ n)
; (princ " found ")
; This program moves the startpoint/snapbase for (if (and ss1 (= (getvar "cmdactive") 1))
; selected hatches base points independently. ss1
; Or it can be used to set the base point same for all selected hatches. )
; The program stops when pressing Enter/Rightclick at any point. )
; )
; Tested for AutoCAD 2000 )
)
(defun c:hm () (c:hatch_move)) (setq ss nil ss1 nil)
(defun c:hatch_move (/ ss1 fp tp loop )
ent oldsnapbase oldosmode oldsp
newsp contin oldgrips oldcmdecho (princ)
errexit restx restore (defun XrefRename (oldname newname newpath)
) (if (and (findfile (strcat newpath newname ".dwg"))
(defun errexit (msg) (ssget "X" (list '(0 . "INSERT") (cons 2 oldname))))
(restore) (progn
) ;_ end of defun ; rename the xref if it is found
(defun restx () (command "rename" "b" oldname newname)
(setvar "snapbase" oldsnapbase) ; change the path of the xref if it is found
(setvar "osmode" oldosmode) (command
(setvar "grips" oldgrips) "-xref"
(command "_.UNDO" "_E") "p"
(setvar "cmdecho" oldcmdecho) newname
(setq *error* olderr) (strcat newpath newname)
(princ) )
) ;_ end of defun )
(setq olderr *error* )
restore restx )
*error* errexit ;; XRP2004.lsp by Mark McDonough
) ;_ end of setq ;; V3.3 Oct.15, 1999
(setq oldcmdecho (getvar "cmdecho")) ;; Updated as XRP2004.lsp by Mark McDonough, 4/20/04
(setvar "cmdecho" 0)
(setq oldgrips (getvar "grips"))
(setvar "grips" 0) ;; Rev.1 05/03/99 updated to work for renamed XREFs and for AK2
(setq oldsnapbase (getvar "snapbase")) ;; Rev.2 10/10/99 updated to work for Image paths
(setq oldosmode (getvar "osmode")) ;; Rev 3 04/20/04 updated to remove restrictions on long filenames
(setq ss1 (cadr (sssetfirst nil (cadr (ssgetfirst))))) ;; Rev 4 12/14/06 updated to allow loading in running in AutoCAD 2007 (although
; get ssgetfirst before UNDO it's not been tested in 2007)
(command "_.UNDO" "_BE") ;; Rev 5 12/06/08 updated by Jimmy Bergmark
(graphscr) ;; updated to allow running in AutoCAD 2010
(if (setq ss1 (if ss1 ;; updated to be possible to run without user interaction
(if (setq ss1 (ssget "P" '((0 . "HATCH"))))
ss1 ; hatches found in previous sel set ;; This lisp utility searches the block table, finds all Xrefs, then
(ssget '((0 . "HATCH"))) ;; repaths the Xrefs (if needed) with shorter "relative paths", thus
; no hatches previously selected ;; enhancing drawing file portability. The program strips unneeded
) ;_ end of if ;; drive letter references and superfluous upper level directory path
(ssget '((0 . "HATCH"))) ; no previous sel set ;; information, using instead the old DOS CHDIR or "CD ..\.." syntax.
) ;_ end of if
) ;_ end of setq ;; This program is supplied "AS IS". The author specifically disclaims
(while ;; all warranties, expressed or implied, regarding the merchantability
(and ;; or fitness for any purpose. The author does not warrant that the
(not (initget 228 "Set")) ;; XRP program will be free of errors and assumes no liability for
(if ss1 ;; damages, direct or consequentail, which may result from the use of
(sssetfirst nil ss1) ;; XRP.
t
) ; show what is selected ;***new error definition
(setq fp ;-----------------------
(getpoint (defun xrperr (msg)
"\nBase point for displacement or set same base point for all [Set] (if ce (setvar "cmdecho" ce))
<exit>: " (if v_r (setvar "visretain" v_r))
) ;_ end of getpoint (if r_a (setvar "regenmode" r_a))
) ;_ end of setq (setq *error* orgerr) ;reset previous error def.
(progn (princ "\nCommand cancelled!")
(if (= fp "Set") (prompt "\n ")
(progn (initget 98) (princ)
(setq )
fp (getpoint "\nSet same base point for all <exit>: ")
) ;_ end of setq ;1 loop through block list, see if any regular xrefs, if so count them
(setq contin nil) ;---------------------------------------------------------------------
) ;_ end of progn (defun ifxref (/ flag)
(progn (initget 98) (setq cnt nil cnttot nil)
(setq tp (prompt "\n ")
(getpoint fp (princ "\n")
"\nSecond point for displacement <exit>: " ;(princ "\nXRP - XREF Relative Path Utility")
) ;_ end of getpoint
) ;_ end of setq (if (null (setq blkdat (tblnext "block" T)))
(setq contin t) (princ "\n 0 Xrefs in this drawing.")
) ;_ end of progn )
) ; end if (if (null (setq image_ss (ssget "X" '((0 . "IMAGE")))))
fp (princ "\n 0 Images in this drawing.")
) ; end progn )
) ; end and
(setvar "osmode" 0) (if blkdat
(setq loop 0) (progn
(while (setq ent (ssname ss1 loop)) (setq blkdat 1 cnt 0 flag 0)
(if contin (while blkdat
(progn (setq oldsp (list (cdr (assoc 43 (entget ent))) (if (= flag 0) (setq blkdat (tblnext "block" T))
(cdr (assoc 44 (entget ent))) (setq blkdat (tblnext "block"))
) ;_ end of list )
) ;_ end of setq (setq flag 1)
(setq newsp (list (- (+ (car oldsp) (car tp)) (car fp)) (if blkdat (if (member (cdr (assoc 70 blkdat)) '(4 12 36 44))
(- (+ (cadr oldsp) (cadr tp)) (cadr fp)) (setq cnt (1+ cnt))))
) ;_ end of list )
) ;_ end of setq )
) ;_ end of progn )
(setq newsp (list (car fp) (cadr fp))) (if (= cnt 0)
) ; end if (princ "\n 0 Xrefs in this drawing!")
(setvar "snapbase" newsp) (if cnt
(setvar "osmode" oldosmode) (progn
(sssetfirst nil) (princ (strcat "\n " (itoa cnt) " Xrefs in this drawing."))
(command ".hatchedit" ent "" "" "" "") )
(setq loop (1+ loop)) )
) ; end while )
) ; end while (if image_ss
) ; end if (progn
(setq ss1 nil) (setq flag 0)
(restore) (princ (strcat "\n " (itoa (sslength image_ss)) " Images in this drawing (some
) ;_ end of defun might be duplicates)."))
)
)
(if (>= cnt 1) (setq cnttot cnt))
;;; HATCHB.LSP ver 2.5 (if image_ss (setq imagetot (sslength image_ss)))
;;; Recreates hatch boundary by selecting a hatch ;;(princ "\n Hit any key to continue.")
;;; Known problem with some elipses and splines ;;(grread)
;;; By Jimmy Bergmark (princ)
;;; Copyright (C) 1997-2008 JTB World, All Rights Reserved )
;;; Website: www.jtbworld.com
;;; E-mail: info@jtbworld.com ;the following function is called by the "repath" function, used for the
;;; 2000-02-12 - First release ;summary message to indicate how many XREFs cannot be found (counts XREFs
;;; 2000-03-27 - Counterclockwise arc's and ellipse's fixed ;that are still attached but can't be found because someone has moved or
;;; Objects created joined to lwpolyline if possible ;renamed the XREF drawings.
;;; Error-handling, undo of command ;---------------------------------------------------------------------------
;;; Can handle PLINETYPE = 0,1,2 (defun ifnf (/ flag)
;;; 2000-03-30 - Integrating hatchb and hatchb14 (setq blkdat 1 flag 0)
;;; Selection of many hatches (while blkdat
;;; Splines supported if closed. (if (= flag 0) (setq blkdat (tblnext "block" T))
;;; 2001-04-02 - Fixed bug with entmake of line with no Z for r14 (setq blkdat (tblnext "block"))
;;; 2001-07-31 - Removed an irritating semicolon to enable polylines to be )
created. (setq flag 1)
;;; 2001-10-04 - Changed mail and homepage so it's easy to find when new (if blkdat
versions comes up.
(if (member (cdr (assoc 70 blkdat)) '(4 12)) (setq cntnf (1+ cntnf)))
;;; 2003-02-06 - Minor fix
)
;;; 2003-02-17 - Area returned if no islands is found since it's not consistant
)
;;; 2003-05-19 - Fix to take PEDITACCEPT variable used in AutoCAD 2004 into
)
account
;;; 2004-11-05 - Minor bugs fixed
;Step through block list, if item is an xref, determine its position
;;; 2006-03-18 - Nothing changed from 2.1 other that it's been confirmed to
work with AutoCAD 2007 ;relative to base drawing and then repath it.
;;; 2006-05-13 - Create the boundary on the same layer as the hatch using the ;------------------------------------------------------------------------
hbl command and (defun repath ()
;;; on current layer/color/linetype using the hb or hatchb command (setq blkdat 1 flag 0 xnam nil cnt 0 cnt6 0 cntnf 0 cntdr 0)
;;; 2007-02-08 - Fixed a bug with the hbl command (while blkdat
;;; 2008-02-29 - Support for hatches in non WCS thanks to xiaocai (if (= flag 0) (setq blkdat (tblnext "block" T))
;;; Tested on AutoCAD r14, 2000, 2000i, 2002, 2004, 2005, 2006, 2007, 2008, (setq blkdat (tblnext "block"))
2009 )
;;; should be working on older versions too. (setq flag 1 dpath (getvar "dwgprefix"))
(if blkdat
(defun c:hb () (hatchb nil)) ; this line can be commented out if there is an (if (member (cdr (assoc 70 blkdat)) '(4 12))
existing command called hb
(progn
(defun c:hbl () (hatchb T)) ; this line can be commented out if there is an
(setq xpath (strcase (cdr (assoc 1 blkdat)))
existing command called hbl
xnam (realxnam)
(defun c:hatchb () (hatchb nil))
xnam2 (strcase (cdr (assoc 2 blkdat)))
(defun hatchb (hl / es blay ed1 ed2 loops1 bptf part
)
et noe plist ic bul nr ang1 ang2 obj *ModelSpace* *PaperSpace*
(princ (strcat "\nXref " XNAM2 (pad) " **Not currently loaded, NOT
space cw errexit undox olderr oldcmdecho ss1 lastent en1 en2 ss lwp
REPATHED"))
list->variantArray 3dPoint->2dPoint A2k ent i ss2
)
knot-list controlpoint-list kn cn pos xv bot area hst noarea
)
)
)
(setq A2k (>= (substr (getvar "ACADVER") 1 2) "15"))
(if blkdat
(if A2k
(if (member (cdr (assoc 70 blkdat)) '(36 44))
(progn
(progn
(defun list->variantArray (ptsList / arraySpace sArray)
(setq xpath (strcase (cdr (assoc 1 blkdat)))
(setq arraySpace
xnam (realxnam)
(vlax-make-safearray
xnam2 (strcase (cdr (assoc 2 blkdat)))
vlax-vbdouble
(cons 0 (- (length ptsList) 1))
;;important revision
)
;;XNAM = real XREF dwg name, stripped from ASSOC 1 fullname, w/o
) ".dwg"
(setq sArray (vlax-safearray-fill arraySpace ptsList)) ;; = external XREF name
(vlax-make-variant sArray) ;;XNAM2 = XREF name grabed from ASSOC 2 (always has no ".dwg"
) extension)
(defun areaOfObject (en / curve area) ;; = internal XREF name (used for reporting to screen)
(if en ;;This revision accounts for renamed XREFs!
(if A2k )
(progn (if (and (/= (substr xpath 1 1) (strcase (substr dpath 1 1)))
(setq curve (vlax-ename->vla-object en)) (wcmatch xpath "*:*")
(if )
(vl-catch-all-error-p (progn
(setq (princ (strcat "\nXref " XNAM2 (pad) " **On different drive, NOT
area REPATHED"))
(vl-catch-all-apply 'vlax-curve-getArea (list curve)) (setq cntdr (1+ cntdr))
) )
) (progn
nil (trpath)
area (if (wcmatch xpath "*:*")
) (progn
) (compath)
(progn (if (member (cdr (assoc 70 blkdat)) '(4 12))
(command "._area" "_O" en) (princ (strcat "\nXref " XNAM2 (pad) " **Not currently loaded, NOT
REPATHED"))
(getvar "area")
)
)
(cond ;***condition for lateral path xrefs... the majority
)
;---------------------------------------------------
)
((and (> (strlen X1path) 0) (> (strlen d1path) 0))
)
(progn
)
(repeat (cntsteps d1path)
)
(setq x1path (strcat ".." (chr 92) x1path))
(if A2k
)
(defun 3dPoint->2dPoint (3dpt)
(setq x1path (strcase (strcat x1path (xnamful)) T))
(list (float (car 3dpt)) (float (cadr 3dpt)))
(if (findfile x1path)
)
(progn
)
(command "xref" "path" xnam2 x1path)
(princ (strcat "\nXref " XNAM2 (pad) " Repathed, lateral directory"))
(defun errexit (s)
(setq cnt (1+ cnt))
(princ "\nError: ")
)
(princ s)
(progn
(restore)
(princ (strcat "\nXref " XNAM2 (pad) " **NOT FOUND, NOT
)
REPATHED"))
(setq cntnf (1+ cntnf))
(defun undox ()
)
(command "._ucs" "_p")
)
(command "._undo" "_E")
(setq xnam nil xnam2 nil)
(setvar "cmdecho" oldcmdecho)
)
(setq *error* olderr)
)
(princ)
;***condition for xrefs directly above main drawing
)
;--------------------------------------------------
((and (= (strlen X1path) 0) (> (strlen d1path) 0))
(setq olderr *error*
(progn
restore undox
(repeat (cntsteps d1path)
*error* errexit
(setq x1path (strcat ".." (chr 92) x1path))
)
)
(setq oldcmdecho (getvar "cmdecho"))
(setq x1path (strcase (strcat x1path (xnamful)) T))
(setvar "cmdecho" 0)
(if (findfile x1path)
(command "._UNDO" "_BE")
(progn
(if A2k (progn
(command "xref" "path" xnam2 x1path)
(vl-load-com)
(princ (strcat "\nXref " XNAM2 (pad) " Repathed, above base
(setq *ModelSpace* (vla-get-ModelSpace directory"))
(vla-get-ActiveDocument (vlax-get-acad-object)) (setq cnt (1+ cnt))
) )
*PaperSpace* (vla-get-PaperSpace (progn
(vla-get-ActiveDocument (vlax-get-acad-object)) (princ (strcat "\nXref " XNAM2 (pad) " **NOT FOUND, NOT
) REPATHED**"))
)) (setq cntnf (1+ cntnf))
) )
)
(setq xnam nil xnam2 nil)
; Remove for testing purpose )
; (setq A2k nil) )
;***condition for xrefs at same level as main drawing
(if (/= (setq ss2 (ssget '((0 . "HATCH")))) nil) ;----------------------------------------------------
(progn ((and (= (strlen X1path) 0) (= (strlen d1path) 0))
(setq i 0) (progn
(setq area 0) ;(if (or (> (strlen xnam2) 8) (wcmatch xnam2 "* *"))
(setq bMoreLoops nil) ;(princ (strcat "\nXref " XNAM2 (pad) " **Long filename used, NOT
(while (setq ent (ssname ss2 i)) REPATHED"))
(setq noarea nil) (progn
(setq ed1 (entget ent)) (princ (strcat "\nXref " XNAM2 (pad) " Repathed, to base directory"))
(setq layer (cdr (assoc 8 ed1))) (command "xref" "path" xnam2 (xnamful))
; (if (not (equal (assoc 210 ed1) '(210 0.0 0.0 1.0))) (princ "\nHatch not in (setq xnam nil xnam2 nil cnt (1+ cnt))
WCS!")) ;modified by xiaocai )
; (setq xv (cdr (assoc 210 ed1))) ;modified by ;)
xiaocai )
(command "._ucs" "_w") )
(setq loops1 (cdr (assoc 91 ed1))) ; number of boundary paths (loops) ;***condition for xrefs below main drawing level
(if (and A2k (= (strcase (cdr (assoc 410 ed1))) "MODEL")) ;-----------------------------------------------
(setq space *ModelSpace*) ((and (> (strlen X1path) 0) (= (strlen d1path) 0))
(setq space *PaperSpace*) (progn
) (setq x1path (strcat (homepath) (chr 92) x1path))
(repeat loops1 (setq x1path (strcase (strcat x1path (xnamful)) T))
(setq ed1 (member (assoc 92 ed1) ed1)) (if (findfile x1path)
(setq bptf (cdr (car ed1))) ; boundary path type flag (progn (command "xref" "path" xnam2 x1path)
(setq ic (cdr (assoc 73 ed1))) ; is closed (princ (strcat "\nXref " XNAM2 (pad) " Repathed, below base
(setq noe (cdr (assoc 93 ed1))) ; number of edges directory"))
(setq bot (cdr (assoc 92 ed1))) ; boundary type (setq cnt (1+ cnt))
(setq hst (cdr (assoc 75 ed1))) ; hatch style )
(setq ed1 (member (assoc 72 ed1) ed1)) (progn
(setq bul (cdr (car ed1))) ; bulge (princ (strcat "\nXref " XNAM2 (pad) " **NOT FOUND, NOT
(setq plist nil) REPATHED**"))
(setq blist nil) (setq cntnf (1+ cntnf))
(cond )
((> (boole 1 bptf 2) 0) ; polyline )
(repeat noe (setq xnam nil xnam2 nil)
(setq ed1 (member (assoc 10 (cdr ed1)) ed1)) )
(setq plist (append plist (list (trans (cdr (assoc 10 ed1)) ent 0) ))) )
;;add trans by xiaocai );end cond
(setq blist (append blist ) ;end progn
(if (> bul 0) (progn ;***else, no drive letter and path is already localized
(list (cdr (assoc 42 ed1))) ;------------------------------------------------------
nil (princ (strcat "\nXref " XNAM2 (pad) " *does not need repathing*"))
) (setq cnt6 (1+ cnt6))
) )
) ) ;end if wcmatch xpath *.*
) ))
(if A2k (progn );end progn
(setq polypoints )
(apply 'append )
(mapcar '3dPoint->2dPoint plist) )
) )
)
(setq VLADataPts (list->variantArray polypoints)) ;***This function lines up Xref path messages... just for looks
(setq obj (vla-addLightweightPolyline space VLADataPts)) ; Numeric value can be increased to accomodate longer names
(setq nr 0) ;--------------------------------------------------------------
(repeat (length blist) (defun pad (/ spacer)
(if (/= (nth nr blist) 0) (setq spacer " ")
(vla-setBulge obj nr (nth nr blist)) (if (< (strlen XNAM2) 24)
) (repeat (- 24 (strlen XNAM2)) (setq spacer (strcat " " spacer)))
(setq nr (1+ nr)) )
) (eval spacer)
(if (= ic 1) )
(vla-put-closed obj T)
) ;***Chops path off of DWGPREFIX, isolating name of single base subdirectory
(if hl (vla-put-layer obj layer)) ;--------------------------------------------------------------------------
) (defun homepath ( / cnt4)
(progn (setq rchr nil cnt4 (strlen dpath))
(setq ne (append (list '(0 . "POLYLINE")) (list (cons 66 1)))) (if (= (substr dpath cnt4 1) "\\")
(if (= ic 1) (setq ne (append ne (list (cons 70 1))))) (setq dpath (substr dpath 1 (- (strlen dpath) 1)) cnt4 (1- cnt4))
(if hl (setq ne (append ne (list (cons 8 layer))))) )
(entmake ne) (while cnt4
(setq nr 0) (setq rchr (substr dpath cnt4 1))
(repeat (length plist) (if (= rchr "\\")
(if (= bul 0) (setq dpath (strcat ".." (substr dpath cnt4)) cnt4 nil)
(entmake (list (cons 0 "VERTEX") (setq cnt4 (1- cnt4))
(cons 10 (trans (nth nr plist) ent 0) );;add trans by xiaocai )
) )
) (eval dpath)
(entmake (list (cons 0 "VERTEX") )
(cons 10 (trans (nth nr plist) ent 0) );;add trans by xiaocai
(cons 42 (nth nr blist)) ;***Gets real (external) XREF name by parsing ASSOC 1 of the
) ; full xref pathname, (w/o the ".dwg" extension) = XNAM2
) ;-----------------------------------------------------------
) (defun realxnam ( / cnt5)
(setq nr (1+ nr)) (setq rchr nil temp xpath cnt5 (strlen xpath))
) (if (wcmatch temp "*\\*")
(entmake '((0 . "SEQEND"))) (while cnt5
) (setq rchr (substr temp cnt5 1))
) (if (= rchr "\\")
) (setq temp (strcat (substr temp (1+ cnt5))) cnt5 nil)
(t ; not polyline (setq cnt5 (1- cnt5))
(setq lastent (entlast)) )
(setq lwp T) )
(repeat noe )
(setq et (cdr (assoc 72 ed1))) (if (wcmatch (strcase temp) "*.DWG")
(cond (setq temp (substr temp 1 (- (strlen temp) 4)))
((= et 1) ; line )
(setq ed1 (member (assoc 10 (cdr ed1)) ed1)) (eval temp)
(if A2k )
(progn
(setq obj (vla-AddLine
space ;***Trims xref path by removing xref drawing name
(vlax-3d-point (trans (cdr (assoc 10 ed1)) ent 0) ) ;;add trans by ; This function is a necessary test in R12 & R13
xiaocai ;-------------------------------------------------
(vlax-3d-point (trans (cdr (assoc 11 ed1)) ent 0) ) ;;add trans by (defun trpath ()
xiaocai
(if (wcmatch (strcase xpath) "*.DWG")(setq xpath (substr xpath 1 (- (strlen xpath)
)) 4))))
(if hl (vla-put-layer obj layer)) (setq xpath (substr xpath 1 (- (strlen xpath) (strlen xnam))))
) )
(progn
(setq ne (append (list (cons 0 "LINE")) ;***Important function to determine xref's position relative to main dwg,
(list (list 10 (car (trans (cdr (assoc 10 ed1)) ent 0) ) (cadr (trans (cdr ; chops off path common to xref & base dwg, leaving unique path remainder.
(assoc 10 ed1)) ent 0)) 0)) ;;add trans by xiaocai
; The symbol "slashcnt" is used to backtrack the path, to ensure the common
(list (list 11 (car (trans (cdr (assoc 11 ed1)) ent 0) ) (cadr (trans (cdr
; path is a whole path that's truncated at a path delimitor, not at a
(assoc 11 ed1)) ent 0)) 0)) ;;add trans by xiaocai
; similar named directory.
;(cons 210 xv)
; ----------------------------------------------------------------------
)
(defun compath (/ cnt2)
)
(setq d1path (strcase (substr dpath 3))
(if hl (setq ne (append ne (list (cons 8 layer)))))
x1path (strcase (substr xpath 3))
(entmake ne)
cnt2 (strlen d1path)
)
slashcnt 0
)
)
(setq ed1 (cddr ed1))
(while (/= cnt2 0)
)
(if (= (substr d1path 1 1) (substr x1path 1 1))
((= et 2) ; circular arc
(progn
(setq ed1 (member (assoc 10 (cdr ed1)) ed1)) (setq d1path (substr d1path 2) x1path (substr x1path 2))
(setq ang1 (cdr (assoc 50 ed1))) (if (or (= (strlen d1path) 0) (= (strlen x1path) 0))
(setq ang2 (cdr (assoc 51 ed1))) (setq cnt2 0)
(setq cw (cdr (assoc 73 ed1))) )
(if (and (equal ang1 0 0.00001) (equal ang2 6.28319 0.00001)) (if (wcmatch (substr x1path 1 1) "\\")
(progn (setq slashcnt 0) (setq slashcnt (1+ slashcnt))
(if A2k )
(progn )
(setq obj (vla-AddCircle (setq cnt2 0)
space )
(vlax-3d-point (trans (cdr (assoc 10 ed1)) ent 0) ) )
(cdr (assoc 40 ed1)) ; (setq zzz x1path)
)) (if (not (wcmatch (substr x1path 1 1) "\\"))
(if hl (vla-put-layer obj layer)) (progn
) (setq x1path
(progn (strcat
(setq ne (append (substr xpath (- (strlen xpath) (+ slashcnt (- (strlen x1path)2))) (1- slashcnt))
(list (cons 0 "CIRCLE")) x1path
(list (cons 8 layer)) )
(list (cons 10 (trans (cdr (assoc 10 ed1)) ent 0)));;;add trans )
by xiaocai )
(list (assoc 40 ed1)) )
) )
)
(if hl (setq ne (append ne (list (cons 8 ;***Counts # of backslashes in remainder path, thus determining
layer)))))
; number of steps to apply DOS CD ..\ syntax
(entmake ne)
; -----------------------------------------------------------
)
(defun cntsteps (x / cnt3)
)
(setq cnt3 0 slash 0 rchr nil)
(setq lwp nil)
(while (/= cnt3 (strlen x))
)
(setq cnt3 (1+ cnt3) rchr (substr x cnt3 1))
(if A2k
(if (= rchr "\\") (setq slash (1+ slash)))
(progn
)
(setq obj (vla-AddArc
(eval slash)
space
)
(vlax-3d-point (trans (cdr (assoc 10 ed1)) ent 0) );;;add trans by
xiaocai
;***Ensures repathed xref has a ".dwg" extension, for consistency
(cdr (assoc 40 ed1))
; -------------------------------------------------------------
(if (= cw 0)
(defun xnamful ()
(- 0 ang2)
(if (not (wcmatch XNAM "*.dwg"))
ang1
(strcase (strcat XNAM ".dwg") T)
)
)
(if (= cw 0)
)
(- 0 ang1)
ang2
)
;Step through IMAGE selection set, determine its position
))
;relative to base drawing and then repath it.
(if hl (vla-put-layer obj layer))
;------------------------------------------------------------------------
)
(defun image_repath ()
(progn
(setq flag 0 xnam nil imgcnt 0 imgok 0 imgnf 0 imgdr 0 #images 0
(setq ne (append (list (cons 0 "ARC"))
image_elist1 (entget (ssname image_ss 0))
(list (cons 10 (trans (cdr (assoc 10 ed1)) ent 0) ));;add trans
by xiaocai image_elist2 (entget (cdr (assoc 340 image_elist1)))
(list (assoc 40 ed1)) image_elist3 (entget (cdr (assoc 330 image_elist2)))
(list (cons 50 image_names (member (assoc 3 image_elist3) image_elist3)
(if (= cw 0) dpath (getvar "dwgprefix")
(- 0 ang2) )
ang1 (while (/= imgcnt (length image_names));maybe should be less than <
) (progn
)) (setq xnam2 (strcase (cdr (nth imgcnt image_names)))
(list (cons 51 xpath (strcase (cdr (assoc 1 (entget (cdr (nth (1+ imgcnt)
image_names))))))
(if (= cw 0)
image_wholepath xpath
(- 0 ang1) istat (cdr (assoc 280 (entget (cdr (nth (1+ imgcnt) image_names)))))
ang2 ) ;if istat = 0, not loaded
) ;XNAM gets set via the (img_path) function below
)) (img_path) ;delivers xnam, and modified xpath
) (if (= istat 0)
) (progn
(if hl (setq ne (append ne (list (cons 8 layer))))) (princ (strcat "\nImage " XNAM2 (pad) " **Not currently loaded, NOT
(entmake ne) REPATHED"))
) (setq imgnf (1+ imgnf))
) )
) (progn ;eei
(setq ed1 (cddddr ed1)) (if (and (/= (substr xpath 1 1) (strcase (substr dpath 1 1)))
) (wcmatch xpath "*:*")
((= et 3) ; elliptic arc )
(setq ed1 (member (assoc 10 (cdr ed1)) ed1)) (progn
(setq ang1 (cdr (assoc 50 ed1))) (princ (strcat "\nImage " XNAM2 (pad) " **On different drive, NOT
REPATHED"))
(setq ang2 (cdr (assoc 51 ed1)))
(setq imgdr (1+ imgdr))
(setq cw (cdr (assoc 73 ed1)))
(setq xnam nil xnam2 nil)
(if A2k (progn
)
(setq obj (vla-AddEllipse
(progn ;xyz
space
(if (wcmatch xpath "*:*")
(vlax-3d-point (trans (cdr (assoc 10 ed1)) ent 0) )
(progn ;aai
(vlax-3d-point (trans (cdr (assoc 11 ed1)) ent 0) );;add trans by
xiaocai (compath)
(cdr (assoc 40 ed1)) (cond
) ;***condition for lateral path images...the majority
) ;---------------------------------------------------
(vla-put-startangle obj (if (= cw 0) (- 0 ang2) ang1)) ((and (> (strlen X1path) 0) (> (strlen d1path) 0)) ;1st cond
(vla-put-endangle obj (if (= cw 0) (- 0 ang1) ang2)) (progn
(if hl (vla-put-layer obj layer)) (repeat (cntsteps d1path)
) (setq x1path (strcat ".." (chr 92) x1path))
(progn )
(princ "\nElliptic arc not supported!") (setq x1path (strcase (strcat x1path xnam)))
(setq noarea T) (if (findfile x1path)
) (progn
) (princ (strcat "\nImage " XNAM2 (pad) " Repathed, lateral
directory"))
(setq lwp nil)
(command "_image" "path" XNAM2 x1path)
)
(setq #images (1+ #images))
((= et 4) ; spline
)
(setq ed1 (member (assoc 94 (cdr ed1)) ed1))
(progn
(setq knot-list nil)
(princ (strcat "\nImage " XNAM2 (pad) " **NOT FOUND, NOT
(setq controlpoint-list nil)
REPATHED"))
(setq kn (cdr (assoc 95 ed1)))
(setq imgnf (1+ imgnf))
(setq cn (cdr (assoc 96 ed1)))
)
(setq pos (vl-position (assoc 40 ed1) ed1))
)
(repeat kn
(setq xnam nil xnam2 nil)
(setq knot-list (cons (cons 40 (cdr (nth pos ed1))) knot-list))
)
(setq pos (1+ pos))
) ;end 1st COND
)
;***condition for images directly above main drawing
(setq pos (vl-position (assoc 10 ed1) ed1))
;---------------------------------------------------
(repeat cn
((and (= (strlen X1path) 0) (> (strlen d1path) 0));2nd cond
(setq controlpoint-list (cons (cons 10 (trans (cdr (nth pos ed1)) ent 0)
(progn
) controlpoint-list));;add trans by xiaocai
(repeat (cntsteps d1path)
(setq pos (1+ pos))
(setq x1path (strcat ".." (chr 92) x1path))
)
)
(setq knot-list (reverse knot-list))
(setq x1path (strcase (strcat x1path xnam)))
(setq controlpoint-list (reverse controlpoint-list))
(if (findfile x1path)
(setq ne (append
(progn
(list '(0 . "SPLINE"))
(princ (strcat "\nImage " XNAM2 (pad) " Repathed, above base
(list (cons 100 "AcDbEntity"))
directory"))
(list (cons 100 "AcDbSpline"))
(command "_image" "path" xnam2 x1path)
(list (cons 70 (+ 1 8 (* 2 (cdr (assoc 74 ed1))) (* 4 (cdr (assoc 73
(setq #images (1+ #images))
ed1)))))) )
(list (cons 71 (cdr (assoc 94 ed1)))) (progn
(list (cons 72 kn)) (princ (strcat "\nImage " XNAM2 (pad) " **NOT FOUND, NOT
(list (cons 73 cn)) REPATHED**"))
knot-list (setq x xnam y xpath x2 xnam2)
controlpoint-list (setq imgnf (1+ imgnf))
) )
) )
(if hl (setq ne (append ne (cons 8 layer)))) (setq xnam nil xnam2 nil)
(entmake ne) )
(setq ed1 (member (assoc 10 ed1) ed1)) );end 2nd cond
(setq lwp nil) ;***condition for images at same level as main drawing
) ;-----------------------------------------------------
) ; end cond ((and (= (strlen X1path) 0) (= (strlen d1path) 0))
) ; end repeat noe (progn
(if lwp (progn ;(if (or (> (strlen xnam2) 8) (wcmatch xnam2 "* *"))
(setq en1 (entnext lastent)) ;(princ (strcat "\nImage " XNAM2 (pad) " **Long filename used, NOT
REPATHED"))
(setq ss (ssadd))
(progn
(ssadd en1 ss)
(princ (strcat "\nImage " XNAM2 (pad) " Repathed, to base
(while (setq en2 (entnext en1))
directory"))
(ssadd en2 ss)
(command "_image" "path" xnam2 xnam)
(setq en1 en2)
(setq xnam nil xnam2 nil #images (1+ #images))
)
)
(if (= (getvar "peditaccept") 1)
;)
(command "_.pedit" (entlast) "_J" ss "" "")
)
(command "_.pedit" (entlast) "_Y" "_J" ss "" "")
)
)
;***condition for images below main drawing level
))
;------------------------------------------------
((and (> (strlen X1path) 0) (= (strlen d1path) 0))
) ; end t
(progn
) ; end cond
(setq x1path (strcat (homepath) (chr 92) x1path))
; Tries to get the area on islands but it's not clear how to know if an
(setq x1path (strcase (strcat x1path xnam)))
island is filled or not
(if (findfile x1path)
; and if it should be substracted or added to the total area.
(progn
; (if (or (= bot 0) (= (boole 1 bot 1) 1)) (setq area (+ area (areaOfObject
(entlast))))) (princ (strcat "\nImage " XNAM2 (pad) " Repathed, below base
directory"))
; (if (and (/= hst 1) (/= bot 0) (= (boole 1 bot 1) 0)) (setq area (- area
(areaOfObject (entlast))))) (command "_image" "path" xnam2 x1path)
; (princ "\n") (princ bot) (princ "\n") (princ hst) (princ "\n") (setq #images (1+ #images))
; (princ (areaOfObject (entlast))) )
) ; end repeat loops1 (progn
(if (and (= noarea nil) (= loops1 1)) (setq area (+ area (areaOfObject (princ (strcat "\nImage " XNAM2 (pad) " **NOT FOUND, NOT
(entlast)))) (setq bMoreLoops T)) REPATHED**"))
(setq i (1+ i)) (setq x xnam y xpath x2 xnam2)
) (setq imgnf (1+ imgnf))
) )
) )
(setq ss2 nil) (setq xnam nil xnam2 nil)
(if (and area (not bMoreLoops)) (progn )
(princ "\nTotal Area = ") )
(princ area)
)) ) ;end Whole COND
(restore) ) ;end progn aai
(princ) (progn ;***else, no drive letter and path is already localized
) ;------------------------------------------------------
;;; By Jimmy Bergmark (princ (strcat "\nImage " XNAM2 (pad) " *does not need repathing*"))
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved (setq imgok (1+ imgok))
;;; Website: www.jtbworld.com )
;;; E-mail: info@jtbworld.com ) ;end if wcmatch
;;; ) ;end progn xyz
;;; Change the hatch base point on one or many hatches
;;;
;=======
(defun c:hatchbase (/ oldos oldsn oldcmdecho i ent ss)
(setq oldos (getvar "osmode")) );end if
(setq oldsn (getvar "snapbase")) ) ;end progn eei
(setq oldcmdecho (getvar "cmdecho")) ) ;end if istat
(setvar "osmode" 47) (setq imgcnt (+ 2 imgcnt))
(princ "\nSelect point you wish Hatch(s) to start from...") ) ;end progn
(command "._snapbase" pause) ) ;end while
(princ "\nSelect Hatch(s) to adjust snapbase") ) ;end defun
(if (not (setq ss (ssget)))
(alert "\n No Entities selected..... Please try again.") (defun img_path ( / imgcnt2)
(progn (setq rchr nil imgcnt2 (strlen xpath))
(setq i 0) (if (= (substr xpath imgcnt2 1) "\\")
(while (setq ent (ssname ss i)) (setq xpath (substr xpath 1 (- (strlen xpath) 1)) imgcnt2 (1- imgcnt2))
(command "._hatchedit" ent "" "" "" "") ) ;this will probably never be used
(setq i (1+ i)) (while (> imgcnt2 0)
) (setq rchr (substr xpath imgcnt2 1))
) (if (= rchr "\\")
) (setq xnam (strcase (substr xpath (1+ imgcnt2)))
(setq ss nil) ;img_pathnam (strcat (strcase (substr xpath 1 (1- imgcnt2))) "\\")
(setvar "snapbase" oldsn) xpath (strcase (substr xpath 1 imgcnt2))
(setvar "osmode" oldos) imgcnt2 nil)
(setvar "cmdecho" oldcmdecho) (setq imgcnt2 (1- imgcnt2))
(princ) )
) )
)

;;; HISTORYLINES.LSP
;;; Change the number of command history lines. ;Main xref repath function
;;; Saves into profile. ;-------------------------
;;; By Jimmy Bergmark (defun xrp ( )
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved (setq sca "scale" orgerr *error* *error* xrperr v# "v3")
;;; Website: www.jtbworld.com (if (or (wcmatch (getvar "acadver") "*14*")(wcmatch (getvar "acadver") "*15*")
;;; E-mail: info@jtbworld.com (wcmatch (getvar "acadver") "*16*")(wcmatch (getvar "acadver") "*17*")
;;; 1999-09-25 - First release (wcmatch (getvar "acadver") "*18*")
;;; To be run on AutoCAD 2000 )
(progn
(defun c:PutHistoryLines (/ hl) (ifxref)
(vl-load-com) (if (or image_ss (> cnt 0))
(if (setq hl (progn
(getint (setq ce (getvar "cmdecho"))
(strcat "\nNumber of History Lines <" (setvar "cmdecho" 0)
(itoa (setq r_a (getvar "regenmode"))
(vla-get-HistoryLines (setq v_r (getvar "visretain"))
(vla-get-display (setvar "regenmode" 0)
(vla-get-preferences (setvar "visretain" 1)
(vlax-get-acad-object))))) (repath)
">: "))) (if image_ss (image_repath))
(if (or (< hl 25) (> hl 2048)) (if (>= cnt 1) (command "regen"))
(prompt "\nOnly between 25 and 2048.") (setvar "regenmode" r_a)
(vla-put-HistoryLines (vla-get-display (vla-get-preferences (vlax-get-acad- ;;(textscr)
object))) hl) (xrp_report)
) (princ "\n ")
) (princ "\n ")
(princ) ;;(princ "\nHit any key")
) ;;(grread)
(princ "\r ")
;;; another way to do it by someone else ;;(graphscr)
(defun c:cmdhistlines ( / chl) (if v_r (setvar "visretain" v_r))
(if (setq chl (getint (strcat "\nNew value for CMDHISTLINES <" (getenv (if ce (setvar "cmdecho" ce))
"CmdHistLines") ">: "))) (setq v_r nil ce nil cnt nil r_a nil flag nil rchr nil)
(if (or (< chl 25) (> chl 2048)) )
(progn )
(prompt "\nRequires and integer between 25 and 2048.") )
(c:cmdhistlines) (alert "This version of XRP is designed for AutoCAD R14 - 2010 only")
) )
(setenv "CmdHistLines" (itoa chl)) (setq *error* orgerr orgerr nil)
) ;;(princ "\n Done with XRP - Xref Relative Path Utility v3.2 by MMcD")
) (princ)
(princ) )
)
(defun xrp_report ()
(if (>= cnt 1) ;***If xrefs exist, report status of repath operations
;;; By Jimmy Bergmark (progn
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved (prompt "\n ")
;;; Website: www.jtbworld.com (princ (strcat "\n" (if (< cnttot 10) " " "") (itoa cnttot) " Xrefs Total"))
;;; E-mail: info@jtbworld.com (princ (strcat "\n-" (if (< cnt 10) "-" "") "-------------"))
;;; Tested on AutoCAD 2000 (princ (strcat "\n" (if (< cnt 10) " " "") (itoa cnt) " Xrefs repathed"))
;;; (if (>= cnt6 1)
;;; 2 versions of Insert block with attribute with ActiveX (princ (strcat "\n" (if (< cnt6 10) " " "") (itoa cnt6)
;;; attributes are rotated to specified angle " Xrefs did not need repathing"))
(vl-load-com) )
(defun c:ax-insrot (/ doc blk_name ins x y (ifnf)
z rt rot blk atts ent ent2 (if (>= cntdr 1)
promptStr i default txt (princ (strcat "\n" (if (< cntdr 10) " " "") (itoa cntdr)
) " Xrefs on different drive, NOT REPATHED"))
(defun list->variantArray (ptsList / arraySpace sArray) )
(setq arraySpace (if (>= cntnf 1)
(vlax-make-safearray (princ (strcat "\n" (if (< cntnf 10) " " "") (itoa cntnf)
vlax-vbdouble " Xrefs could not be found, NOT REPATHED"))
(cons 0 (- (length ptsList) 1)) )
) (prompt "\n ")
) (setq cnttot nil cnt6 nil cntdr nil cntnf nil)
(setq sArray (vlax-safearray-fill arraySpace ptsList)) )
(vlax-make-variant sArray) )
) (if (> #images 0)
(initget 1) (progn
(setq blk_name (getstring T "\nEnter block name: ")) (prompt "\n ")
(initget 1) (princ (strcat "\n" (if (< (/(length image_names)2)10) " " "") (itoa (/(length
(setq ins (list->variantArray image_names)2))
(getpoint "\nSpecify insertion point: ") " Different Images Total"))
) (princ (strcat "\n-" (if (< #images 10) "-" "") "-----------------------"))
x (getdist "\nEnter X scale factor <1>: ") (princ (strcat "\n" (if (< #images 10) " " "") (itoa #images) " Images repathed"))
y (getdist "\nEnter Y scale factor <use X scale factor>: ") (if (>= imgok 1)
z (getdist "\nEnter Z scale factor <use Y scale factor>: ") (princ (strcat "\n" (if (< imgok 10) " " "") (itoa imgok)
rt (getangle "\nSpecify rotation angle <0.0>: ") " Images did not need repathing"))
rot (getangle "\nSpecify rotation angle for attributes <0.0>: ") )
) (if (>= imgdr 1)
(if (= x nil) (princ (strcat "\n" (if (< imgdr 10) " " "") (itoa imgdr)
(setq x 1) " Images on different drive, NOT REPATHED"))
) )
(if (= y nil) (if (>= imgnf 1)
(setq y x) (princ (strcat "\n" (if (< imgnf 10) " " "") (itoa imgnf)
) " Images could not be found, NOT REPATHED"))
(if (= z nil) )
(setq z y) (prompt "\n ")
) ;(setq image_ss nil #images nil imgok nil imgdr nil imgnf nil)
(if (= rt nil) )
(setq rt 0) )
) )
(if (= rot nil)
(setq rot 0) (defun c:xrp () (xrp))
)
(setq doc (vla-get-activedocument (vlax-get-acad-object))) ; Remove the ; in the row below to have the function automatically run when the
lisp is loaded.
(setq blk (vla-insertblock
(vla-get-paperspace doc) ;(xrp)
ins (princ)
blk_name ;;; zoome.lsp
x ;;;
y ;;; Zoom extents in all viewports
z ;;;
rt ;;; By Jimmy Bergmark
) ;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
) ;;; Website: www.jtbworld.com
;;; E-mail: info@jtbworld.com
(if (and ;;; 2000-08-29
(= (vla-get-hasattributes blk) :vlax-true) ;;; Tested on AutoCAD 2000
(safearray-value
(setq atts (defun c:zoome (/ oldcmdecho vplist curcvport nr vpss ms en x)
(vlax-variant-value (setq oldcmdecho (getvar "cmdecho"))
(vla-getattributes blk) (setvar "cmdecho" 0)
) (setq vplist (mapcar 'car (vports)))
) (setq curcvport (getvar "cvport"))
) (if (= (getvar "tilemode") 0)
) (progn
(progn (if (= (setq ms (getvar "cvport")) 1)
(vlax-for ent (vla-get-blocks doc) (command "._mspace")
(if (= (vla-get-name ent) (vla-get-name blk)) )
(vlax-for ent2 ent (setq vpss (ssget "_x"
(if (= (vla-get-objectname ent2) "AcDbAttributeDefinition") (list '(-4 . "<AND")
(setq promptStr '(0 . "VIEWPORT")
(cons (cons 410 (getvar "ctab"))
(list (vla-get-PromptString ent2) '(-4 . "<NOT")
(vla-get-TextString ent2) '(69 . 1)
(vla-get-TagString ent2) '(-4 . "NOT>")
) '(-4 . "AND>")
promptStr )
) )
) )
) (setq nr 0)
) (if vpss ; in case there are no viewports
) (repeat (sslength vpss)
) (setq en (entget (ssname vpss nr)))
(setq i (1- (length promptStr))) (if (and (= 0 (logand 1 (cdr (assoc 90 en))))
(princ "\nEnter attribute values\n") ; not perspective
(foreach tag (vlax-safearray->list atts) (< 0 (cdr (assoc 68 en))) ; on and active
(vla-put-TextString (/= 16384 (logand 16384 (cdr (assoc 90 en))))
tag ; not locked
(if (= (setq )
txt (getstring (progn
T (setvar "cvport" (cdr (assoc 69 en)))
(strcat (if (= (setq default (car (nth i promptStr))) "") (command "._zoom" "_e")
(setq default (caddr (nth i promptStr))) )
default )
) (setq nr (+ 1 nr))
" <" )
(setq default (cadr (nth i promptStr))) )
">: " (if (= ms 1) (command "._pspace"))
) )
) (foreach x vplist
) (setvar "cvport" x)
"" (command "._zoom" "_e")
) )
default )
txt (setq vpss nil)
) (setvar "cvport" curcvport)
) (setvar "cmdecho" oldcmdecho)
(vla-put-Rotation tag rot) (princ)
(setq i (1- i)) )
)
)
)
(princ)
)

(defun c:insrot (/ cmdecho attdia insblk ent rt tag atts blk)


(setq cmdecho (getvar "CMDECHO"))
(setq attdia (getvar "ATTDIA"))
(setvar "ATTDIA" 1)
(setvar "CMDECHO" 1)
(initdia)
(command "_.-INSERT" "~")
(while (eq 1 (logand 1 (getvar "CMDACTIVE")))
(command pause)
)
(setq insblk (entlast))
(setq ent (cdar (entget insblk)))
(setq blk (vlax-ename->vla-object ent))
(if (and
(= (vla-get-hasattributes blk) :vlax-true)
(safearray-value
(setq atts
(vlax-variant-value
(vla-getattributes blk)
)
)
)
)
(progn
(setq rt
(getangle "\nSpecify rotation angle for attributes <0.0>: ")
)
(if (= rt nil)
(setq rt 0)
)
(foreach tag (vlax-safearray->list atts)
(vla-put-Rotation tag rt)
)
)
)
(setvar "ATTDIA" attdia)
(setvar "CMDECHO" cmdecho)
(princ)
)

;;; By Jimmy Bergmark


;;; Copyright (C) 1997-2007 JTB World, All Rights Reserved
;;; Website: www.jtbworld.com
;;; E-mail: info@jtbworld.com
;;; Tested on AutoCAD 2005 and ADT 2005 up to AutoCAD 2008
;;;

You might also like