Professional Documents
Culture Documents
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.
;;; 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
;;; 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)
)