;;;;Custom Commands
;;;;This AutoLisp file should be placed in a common access location for all users, and the acad.lsp file should link to this file
;;;;This command deletes current layout, and any layouts named "Layout1"
;;
(Defun C:readme ()
(alert "
LIST OF COMMANDS AVAILABLE DUE TO ACADDOC.LSP
README::
ISD::Insert Source Document, this command will insert a generic template layout.
LD:: Deletes current Layout
LN:creates New Layout, prompts for name of new layout.
LC::creates Copy of current Layout
LR::Rename Layout
PAL::Print All Layouts of all of the drawings that are currently open in autocad.
ZO::Zooms to Objects
PGRID::places a predefined grid in the standard location with original page numbers
Z1::Zooms to a predefined Grid space 1 (Z2 Z3....work for each space respectively)
SK:::Sketch Pen Down
CDP:: Clear document properties")
(princ)
)
(Defun C:isd ()
(command "_.layout" "T" "\\\\server\\file\\path\\your template.dwg" "Blank" )
(command "_.style" "romant" "romantic" "" "" "" "" "")
(command "_.style" "romand" "romantic" "" "" "" "" "")
(command "_.style" "standard" "arial" "" "" "" "" "")
(command "_.purge" "all" "" "n") ;HELPS TO MINIMIZE FILE SIZE BY REMOVING UNUSED LAYERS/FONTS/EMPTY BLOCKS
(command "_.layout" "set" "Your Template")
(command "_.pspace")
(command "_.zoom" "e")
(princ)
)
(Defun C:pgrid ()
(command "_.pspace")
(command "_.mspace")
(command "_.insert" "\\\\server\\file\\path\\Grid.dwg" "0,0,0" "1" "1" "0")
(command "_.insert" "\\\\server\\file\\path\\Original.dwg" "0,0,0" "1" "1" "0")
(command "_.draworder" "last" "" "back")
(princ)
)
;;;;;;;;; command prompt: CDP = Clear Document Properties, removes all custom drawing properties and purges unused layers
(Defun C:cdp ()
(command "_.style" "romant" "romantic" "" "" "" "" "")
(command "_.style" "romand" "romantic" "" "" "" "" "")
(command "_.style" "standard" "arial" "" "" "" "" "")
(command "_.purge" "all" "" "n")
(command "_.propulate" "remove" "current")
(princ)
)
(Defun C:pdp ()
(command "_.style" "romant" "romantic" "" "" "" "" "")
(command "_.style" "romand" "romantic" "" "" "" "" "")
(command "_.style" "standard" "arial" "" "" "" "" "")
(command "_.purge" "all" "" "n")
(command "_.propulate" "remove" "current")
;;;;;;;;;;; following line imports properties from a file.
(command "_.propulate" "active" "\\\\\server\\file\\path\\your properties file.prp" "update" "")
(princ)
)
;;;;;;;;; command prompt :ld = delete current layout
(Defun C:ld ()
(command "_.layout" "delete" "")
(princ)
)
;;;;;;;;; command prompt :ln = New layout
(Defun C:ln ()
(command "_.layout" "new" "")
(princ)
)
;;;;;;;;; command prompt :lc = copy current layout
(Defun C:lc ()
(command "_.layout" "copy" "")
(princ)
)
;;;;;;;;; command prompt :lr = layout rename
(Defun C:LR ()
(command "_.layout" "rename" "")
(princ)
)
;;;;;;;;;;command prompt :PAL = Print All Layouts in all open drawings
(Defun C:pal ()
(alert "Open and save all layouts or sheetsets\n you plan on printing prior to running PAL!")
(command "_.publishallsheets" "1")
(command "_.qsave")
(command "_.PUBLISHCOLLATE" "1")
(command "_.publish")
(command "_.publishallsheets" "0")
(princ)
)
(Defun C:zo ()
(command "_.zoom" "o")
(princ)
)
(Defun C:sk ()
(command "_.sketch")
(princ)
)
(Defun C:apl ()
(command "_.appload")
(princ)
)
;;;;;;;;; command prompt :Z1 - Z32= Zoom to grid space 1 through 9 respectively.
(Defun C:z1 ()
(command "mspace" "_.zoom" "0,316.0006" "83.9432,239.4916")
(princ)
)
(Defun C:z2 ()
(command "mspace" "_.zoom" "87.2648,316.0006" "171.2081,239.4916")
(princ)
)
(Defun C:z3 ()
(command "mspace" "_.zoom" "174.5296,316.0006" "258.4729,239.4916")
(princ)
)
(Defun C:z4 ()
(command "mspace" "_.zoom" "261.7944,316.0006" "345.7377,239.4916")
(princ)
)
(Defun C:z5 ()
(command "mspace" "_.zoom" "349.0593,316.0006" "433.0025,239.4916")
(princ)
)
(Defun C:z6 ()
(command "mspace" "_.zoom" "436.3241,316.0006" "520.2673,239.4916")
(princ)
)
(Defun C:z7 ()
(command "mspace" "_.zoom" "523.5889,316.0006" "607.5321,239.4916")
(princ)
)
(Defun C:z8 ()
(command "mspace" "_.zoom" "610.8537,316.0006" "694.797,239.4916")
(princ)
)
(Defun C:z9 ()
(command "mspace" "_.zoom" "0,236.1701" "83.9432,159.6611")
(princ)
)
(Defun C:z10 ()
(command "mspace" "_.zoom" "87.2648,236.1701" "171.2081,159.6611")
(princ)
)
(Defun C:z11 ()
(command "mspace" "_.zoom" "174.5296,236.1701" "258.4729,159.6611")
(princ)
)
(Defun C:z12 ()
(command "mspace" "_.zoom" "261.7944,236.1701" "345.7377,159.6611")
(princ)
)
(Defun C:z13 ()
(command "mspace" "_.zoom" "349.0593,236.1701" "433.0025,159.6611")
(princ)
)
(Defun C:z14 ()
(command "mspace" "_.zoom" "436.3241,236.1701" "520.2673,159.6611")
(princ)
)
(Defun C:z15 ()
(command "mspace" "_.zoom" "523.5889,236.1701" "607.5321,159.6611")
(princ)
)
(Defun C:z16 ()
(command "mspace" "_.zoom" "610.8537,236.1701" "694.797,159.6611")
(princ)
)
(Defun C:z17 ()
(command "mspace" "_.zoom" "0,156.3396" "83.9432,79.8306")
(princ)
)
(Defun C:z18 ()
(command "mspace" "_.zoom" "87.2648,156.3396" "171.2081,79.8306")
(princ)
)
(Defun C:z19 ()
(command "mspace" "_.zoom" "174.5296,156.3396" "258.4729,79.8306")
(princ)
)
(Defun C:z20 ()
(command "mspace" "_.zoom" "261.7944,156.3396" "345.7377,79.8306")
(princ)
)
(Defun C:z21 ()
(command "mspace" "_.zoom" "349.0593,156.3396" "433.0025,79.8306")
(princ)
)
(Defun C:z22 ()
(command "mspace" "_.zoom" "436.3241,156.3396" "520.2673,79.8306")
(princ)
)
(Defun C:z23 ()
(command "mspace" "_.zoom" "523.5889,156.3396" "607.5321,79.8306")
(princ)
)
(Defun C:z24 ()
(command "mspace" "_.zoom" "610.8537,156.3396" "694.797,79.8306")
(princ)
)
(Defun C:z25 ()
(command "mspace" "_.zoom" "0,76.5091" "83.9432,0")
(princ)
)
(Defun C:z26 ()
(command "mspace" "_.zoom" "87.2648,76.5091" "171.2081,0")
(princ)
)
(Defun C:z27 ()
(command "mspace" "_.zoom" "174.5296,76.5091" "258.4729,0")
(princ)
)
(Defun C:z28 ()
(command "mspace" "_.zoom" "261.7944,76.5091" "345.7377,0")
(princ)
)
(Defun C:z29 ()
(command "mspace" "_.zoom" "349.0593,76.5091" "433.0025,0")
(princ)
)
(Defun C:z30 ()
(command "mspace" "_.zoom" "436.3241,76.5091" "520.2673,0")
(princ)
)
(Defun C:z31 ()
(command "mspace" "_.zoom" "523.5889,76.5091" "607.5321,0")
(princ)
)
(Defun C:z32 ()
(command "mspace" "_.zoom" "610.8537,76.5091" "694.797,0")
(princ)
)
;;;;;;;;;
;;;;;;;;;This Following is designed to load quick commands for 3d editing views----------------------------
(defun C:iso ()
(command "-view" "seiso")
(princ)
)
(defun C:isw ()
(command "-view" "swiso")
(princ)
)
(defun C:ine ()
(command "-view" "neiso")
(princ)
)
(defun C:inw ()
(command "-view" "nwiso")
(princ)
)
(defun C:vft ()
(command "-view" "front")
(princ)
)
(defun C:vbk ()
(command "-view" "back")
(princ)
)
(defun C:vbt ()
(command "-view" "bottom")
(princ)
)
(defun C:vtp ()
(command "-view" "top")
(princ)
)
(defun C:vrt ()
(command "-view" "right")
(princ)
)
(defun C:vlf ()
(command "-view" "left")
(princ)
)
;;
;;;; --------------------------------------------------------------------------
;
;;; DESCRIPTION
;;;
;;; THIS COMMAND CONVERTS A SELECTED SPLINE INTO
;;; a POLY LINE TO ALLOW FOR OFFSETTING
;;;
;;;
;;; --------------------------------------------------------------------------;
;;
(defun c:spline2pl (/ segs doc spc ss sglen i pt ptlst nPoly)
(vl-load-com)
(setq segs 100)
(setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object))
spc (if (zerop (vla-get-activespace doc))
(if (= (vla-get-mspace doc) :vlax-true)
(vla-get-modelspace doc)
(vla-get-paperspace doc))
(vla-get-modelspace doc)))
(if (setq ss (ssget '((0 . "SPLINE"))))
(progn
(foreach Obj (mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp
(mapcar 'cadr (ssnamex ss))))
(setq sglen (/ (- (vlax-curve-getDistatParam Obj
(vlax-curve-getEndParam Obj))
(vlax-curve-getDistatParam Obj
(vlax-curve-getStartParam Obj))) segs) i -1 ptlst nil)
(while (and (setq pt (vlax-curve-getPointatDist Obj (* sglen (setq i (1+ i)))))
(>= (distance pt (vlax-curve-getEndPoint Obj)) sglen))
(setq ptlst (cons pt ptlst)))
(setq ptlst (apply 'append
(mapcar '(lambda (x) (list (car x) (cadr x)))
(mapcar '(lambda (x) (trans x 0 1)) ptlst)))
nPoly (vla-addLightweightPolyline spc
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbDouble
(cons 0 (1- (length ptLst)))) ptlst))))
(vla-put-layer nPoly (vla-get-layer Obj))
(vla-put-linetype nPoly (vla-get-linetype Obj))
(vla-put-linetypescale nPoly (vla-get-linetypescale Obj))
(vla-put-color nPoly (vla-get-color Obj))
(vla-delete Obj)))
(princ "\n<!> No Splines Selected <!>"))
(princ))
;;; 3DSPIRAL THE Cpoyright APPLIES TO THE FOLLOWING CODE
; Copyright (C) 1992 by Autodesk, Inc.
;
; Permission to use, copy, modify, and distribute this software
; for any purpose and without fee is hereby granted, provided
; that the above copyright notice appears in all copies and that
; both that copyright notice and this permission notice appear in
; all supporting documentation.
;
; THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
; WARRANTY. ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
; PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;; --------------------------------------------------------------------------
;
;;; DESCRIPTION
;;;
;;; This is a programming example.
;;;
;;; Designed and implemented by Kelvin R. Throop in January 1985
;;;
;;; This program constructs a spiral. It can be loaded and called
;;; by typing either "spiral", "3dspiral" or the following:
;;; (cspiral <# rotations> <base point> <horiz growth per rotation>
;;; <points per circle> <start radius>
;;; <vert growth per rotation>).
;;;
;;; --------------------------------------------------------------------------;
(defun myerror (s) ; If an error (such as CTRL-C) occurs while this command is active...
(if (/= s "Function cancelled")
(princ (strcat "\nError: " s))
)
(setvar "cmdecho" ocmd); Restore saved modes
(setvar "blipmode" oblp)
(setq *error* olderr) ; Restore old *error* handler
(princ)
)
(defun cspiral (ntimes bpoint hfac lppass strad vfac
/ ang dist tp ainc dhinc dvinc circle dv)
(setvar "blipmode" 0) ; turn blipmode off
(setvar "cmdecho" 0) ; turn cmdecho off
(setq circle (* 3.141596235 2))
(setq ainc (/ circle lppass))
(setq dhinc (/ hfac lppass))
(if vfac (setq dvinc (/ vfac lppass)))
(setq ang 0.0)
(if vfac
(setq dist strad dv 0.0)
(setq dist 0.0)
)
(if vfac
(command "3dpoly") ; start spiral ...
(command "pline" bpoint) ; start spiral from base point and...
)
(repeat ntimes
(repeat lppass
(setq tp (polar bpoint (setq ang (+ ang ainc))
(setq dist (+ dist dhinc))
)
)
(if vfac
(setq tp (list (car tp) (cadr tp) (+ dv (caddr tp)))
dv (+ dv dvinc)
)
)
(command tp) ; continue to the next point...
)
)
(command "") ; until done.
(princ)
)
;;;
;;; Interactive spiral generation
;;;
(defun C:SPIRAL (/ olderr ocmd oblp nt bp cf lp)
;;;;(setq olderr *error*
;;;; *error* myerror)
(setq ocmd (getvar "cmdecho"))
(setq oblp (getvar "blipmode"))
(setvar "cmdecho" 0)
(initget 1) ; bp must not be null
(setq bp (getpoint "\nCenter point: "))
(initget 7) ; nt must not be zero, neg, or null
(setq nt (getint "\nNumber of rotations: "))
(initget 3) ; cf must not be zero, or null
(setq cf (getdist "\nGrowth per rotation: "))
(initget 6) ; lp must not be zero or neg
(setq lp (getint "\nPoints per rotation <30>: "))
(cond ((null lp) (setq lp 30)))
(cspiral nt bp cf lp nil nil)
(setvar "cmdecho" ocmd)
(setvar "blipmode" oblp)
(setq *error* olderr) ; Restore old *error* handler
(princ)
)
;;;
;;; Interactive spiral generation
;;;
(defun C:3DSPIRAL (/ olderr ocmd oblp nt bp hg vg sr lp)
;;;;(setq olderr *error*
;;;; *error* myerror)
(setq ocmd (getvar "cmdecho"))
(setq oblp (getvar "blipmode"))
(setvar "cmdecho" 0)
(initget 1) ; bp must not be null
(setq bp (getpoint "\nCenter point: "))
(initget 7) ; nt must not be zero, neg, or null
(setq nt (getint "\nNumber of rotations: "))
(initget 7) ; sr must not be zero, neg, or null
(setq sr (getdist bp "\nStarting radius: "))
(initget 1) ; cf must not be zero, or null
(setq hg (getdist "\nHorizontal growth per rotation: "))
(initget 3) ; cf must not be zero, or null
(setq vg (getdist "\nVertical growth per rotation: "))
(initget 6) ; lp must not be zero or neg
(setq lp (getint "\nPoints per rotation <30>: "))
(cond ((null lp) (setq lp 30)))
(cspiral nt bp hg lp sr vg)
(setvar "cmdecho" ocmd)
(setvar "blipmode" oblp)
(setq *error* olderr) ; Restore old *error* handler
(princ)
)
;;; --------------------------------------------------------------------------;
(princ)