I wrote this lisp program a couple years ago while learning how to program a DCL.

This routine gives you XYZ data in a convent dialog box.
You can easily copy the data from the dialog box if needed.

The best part is it will display accurate coordinates up to 1/256th!
XYZ dialog2


;;;  XYZ.lsp								;;;
;;;  Created by Jonathan Norton						;;;
;;;						;;;
;;;									;;;
;;;  Copyright © 2016                                                   ;;;
;;;                                                                     ;;;
;;;  FUNCTION:                                                          ;;;
;;;  Identify coordinates/elev of a single point			;;;
;;;									;;;
;;;                                                                     ;;;
;;;  PLATFORMS:                                                         ;;;
;;;  Tested on 2012					                ;;;
;;;                                                                     ;;;
;;;									;;;
;;;                                                                     ;;;
;;;                                                                     ;;;
;;;									;;;

(defun c:XYZ ()
  (command-s "UCS" "WORLD")
  (setq os (getvar 'osmode))
  (setvar 'osmode 7)
  (setq flag 4)
  (setq PT1 ( getpoint "\nChoose a Point : ")
	  x (rtos (car   pt1))        
          y (rtos (cadr  pt1))        
          z (rtos (caddr pt1))         
  (setq dcl_id (load_dialog "XYZ.dcl"))
  (while (> flag 2)
  (if(not(new_dialog "XYZ" dcl_id))
	   (set_tile "X" x)
  	   (set_tile "Y" y)
  	   (set_tile "Z" z)
	   (action_tile "Pick" "(done_dialog 4)")
	   (action_tile "Cancel" "(done_dialog 0)")
  (setq flag (start_dialog))
    (if (= flag 4)
	(setq PT1 ( getpoint "\nChoose a Point : ")
	  x (rtos (car   pt1))        
          y (rtos (cadr  pt1))        
          z (rtos (caddr pt1))
  (unload_dialog dcl_id)
  (setvar 'osmode os)


edibx :edit_box {edit_limit=20; edit_width=20;}
but12 :button {width=12.0;}
spwh1 :spacer {width=1.0; height=1.0;}
:dialog {label="XYZ";
 :boxed_column {
  :edibx {label="EASTING:"; key="X";}
  :edibx {label="NORTHING:"; key="Y";}
  :edibx {label="ELEV:"; key="Z";}
  :row {fixed_width=true; alignment=centered;
   :but12 {label="PICK"; key="Pick"; mnemonic="P";}
   :but12 {label="CANCEL"; key="Cancel"; mnemonic="C"; is_default=true; is_cancel=true;}

Navisworks Freedom ~ Adjusting Clipping Plane

Have you ever been working in Navisworks Freedom and wanted to adjust your clipping plane but didn’t know how? I know I sure did!

I finally found out how to do just that!

In NWD press SHIFT+F11 and you will see a “File Options” Dialog box.


Changing the “Constraint Distance” will adjust your near clipping plane. I found that 12 worked best for me, but play around with that number until it meets your liking.

Setting it to “Automatic” didn’t work well and make the clipping plane too far.


Adding Lisp Files to a Tool Palette

AutoCAD Tips

If you have some lisp routines that you would like to have available when you are working in various drawings here is a way to have them available in all your drawings. This method of adding the .lsp files to a tool palette makes them available and will load them only when they are needed. Other methods like using an acad.lsp or acaddoc.lsp will load all the lisp files upon each drawing that you open and depending on how many lisp files you have may be a little slow.

First place your  lisp files and button images into a folder that will be a stable environment where it will not accidentally get moved or erased. Button images can be of various file types and sizes. In this example I have used 32×32 pixel bitmaps (.bmp).

Right click in the Tool Palette and select “New Palette” to place the new tools…

View original post 207 more words

Angled Text

I ran across this lisp over on the AutoDesk forums

It will basically place text at the angle of a selected object.


(defun c:gcs-textinline () (glt-textinline 0.09375) (princ))
(defun glt-textinline (standtext / _cmdecho _osmode lineent lineobj p1 lineangle textheight textent)
(defun rtd (a) (/ (* a 180.0) pi))
(defun dtr (a) (* pi (/ a 180.0)))
(setq _cmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq lineent (entsel "\nSelect Line at location of text string"))
(setq lineobj (vlax-ename->vla-object (car lineent)))
(setq p1 (cadr lineent))
(setq lineangle (rtd (vla-get-angle lineobj)))
(setq textheight (* (getvar "dimscale") standtext))
(command ".dtext" "j" "mc" p1 textheight (if (and (>= 270 lineangle) (> lineangle 90)) (- lineangle 180) lineangle))
(while (eq 1 (logand 1 (getvar "CMDACTIVE"))) (command pause))
(setq textent (entlast))
(command ".trim" textent "" lineent "")
(setvar "cmdecho" _cmdecho)


Control Location of .bak Files

I’m sure at one point or another you have debated turning off the .bak file. I’m sure some of you have actually done it, but sooner or later realized that was a bad idea.

Usually the reason for wanting to disable it, is because it clutters up your folder(s). At least that was my reason.

But did you know you can actually control the location of the .bak files?

By default, BAK files are created in the same folder as the drawing file.

You can use the MOVEBAK Express Tool to change the location where BAK files are stored. Follow these steps:

1. On the Express menu, click File Tools > Move Backup Files.
2. On the command line, enter the path location where you want the backup files to be stored.
Note: You must have Express Tools installed to access this command. Refer to the product installation documentation for details about installing Express Tools.


Layer Control ~ Lisp

I’m sure everyone has had an occasion where a layer was off/frozen/locked that you needed to re-activate, I know I sure have. Sometimes its takes you a minute to find the layer in the drop down or layer manager. Dont you wish you could speed up that process, and only show which layers are off/frozen/locked?

Then your in luck, because I have the perfect lisp for you!

This lisp was created by Phanaem found HERE on the AutoDesk community!
I only made a few minor edits to my liking.

This lisp will display a DCL that will allow you to select off/frozen/locked and turn them back on.



; Turn ON, Thaw ar Unlock layers
; Stefan M. - 04.06.2013
; Edited by Jonathan Norton

(defun C:LCON ( / *error* acDoc filen filew id l layers r c l_frz l_off l_lck selected_layers prop val)
  (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark acDoc)

  (defun *error* (m)
      (not (wcmatch (strcase m) "*CANCEL*,*QUIT*"))
      (princ (strcat "\nError: " m))
    (vla-endundomark acDoc)
  (defun prompt_list ()
    (start_list "a_list")
      (setq l (cond
                ((= "1" *tog1*) l_off)
                ((= "1" *tog2*) l_frz)
                ((= "1" *tog3*) l_lck)

  (vlax-for la (setq layers (vla-get-layers acDoc))
    (if (eq (vla-get-LayerOn la) :vlax-false)
      (setq l_off (cons (vla-get-Name la) l_off))
    (if (eq (vla-get-Freeze la) :vlax-true)
      (setq l_frz (cons (vla-get-Name la) l_frz))
    (if (eq (vla-get-Lock la) :vlax-true)
      (setq l_lck (cons (vla-get-Name la) l_lck))
  (setq l_off (acad_strlsort l_off)
        l_frz (acad_strlsort l_frz)
        l_lck (acad_strlsort l_lck)
  (if (or l_off l_frz l_lck) 
      (setq filew (open (setq filen (strcat (getvar 'dwgprefix) "temp_layer_dialog.dcl")) "w"))
        "layer_on_dialog : dialog {
       label = \"Layer Control\";
       : column {
       : list_box { label = \"Select Layer:\"; key = \"a_list\"; width = 40; height = 15; multiple_select = true; allow_accept = true;}
       : radio_column {
       : radio_button { label = \"Off Layers\";    key = \"tog1\"; }
       : radio_button { label = \"Frozen Layers\"; key = \"tog2\"; }
       : radio_button { label = \"Locked Layers\"; key = \"tog3\"; }}
       ok_cancel;}}" filew)
      (close filew)
        (>= (setq id (load_dialog filen)) 0)
           (new_dialog "layer_on_dialog" id)
              (or *tog1* (setq *tog1* "1"))
              (or *tog2* (setq *tog2* "0"))
              (or *tog3* (setq *tog3* "0"))
              (action_tile "a_list" "(setq selected_layers $value)")
              (action_tile "tog1"   "(setq *tog1* \"1\" *tog2* \"0\" *tog3* \"0\" selected_layers nil) (prompt_list)")
              (action_tile "tog2"   "(setq *tog1* \"0\" *tog2* \"1\" *tog3* \"0\" selected_layers nil) (prompt_list)")
              (action_tile "tog3"   "(setq *tog1* \"0\" *tog2* \"0\" *tog3* \"1\" selected_layers nil) (prompt_list)")
              (set_tile "tog1" *tog1*)
              (set_tile "tog2" *tog2*)
              (set_tile "tog3" *tog3*)
              (mode_tile "tog1" (if l_off 0 1))
              (mode_tile "tog2" (if l_frz 0 1))
              (mode_tile "tog3" (if l_lck 0 1))
              (setq r (start_dialog))
              (unload_dialog id)
            (princ "\nWrong dialog definition")
         (princ "\nDCL file not found")
      (if (findfile filen) (vl-file-delete filen))
        (and (= r 1) selected_layers)
           (setq prop (cond
                        ((= "1" *tog1*) 'LayerON)
                        ((= "1" *tog2*) 'Freeze)
                        ((= "1" *tog3*) 'Lock)
                 val  (cond
                        ((= "1" *tog1*) -1)
                        ((= "1" *tog2*) 0)
                        ((= "1" *tog3*) 0)
           (foreach x (read (strcat "(" selected_layers ")"))
             (vlax-put (vla-item layers (nth x l)) prop val)
      (vla-regen acDoc acActiveViewport)
    (Alert "All Layers On/Active")
  (*error* nil)

Lock All Viewports ~ Lisp

It never fails! Every time I have to work on somebody else’s drawings, their viewports are never locked! I got tired of click every viewport and locking them manually, so I created this lisp!

(defun c:vpl (/ kw kval doc adoc lao cnt inc cvprt blk pw)
   (initget 1 "LOCK UNLOCK")
   (setq kw (getkword "\nLOCK or UNLOCK ALL VPORTS [LOCK/UNLOCK]: "))
   (setq kw (strcase kw))
      (if (= kw "LOCK")
      (setq kval :vlax-true)
      (if (= kw "UNLOCK")
      (setq kval :vlax-false)
(setq doc (vlax-get-object "AutoCad.Application")
adoc (vla-get-ActiveDocument doc)
lao (vla-get-Layouts adoc)
cnt (vla-get-Count lao)
inc 0
(repeat cnt
(setq cvprt (vla-Item lao inc)
inc (+ inc 1)
blk (vla-get-Block cvprt)
(vlax-for itm blk
(vlax-property-available-p itm 'DisplayLocked)
(vla-put-DisplayLocked itm kval)
(vla-update itm)

Mtext Background Mask ~ Lisp

I hope everyone had a great Christmas and New years!

If you ever use a background mask for your text, you know how many steps it takes to turn the back ground mask on. Well here is a lisp to make it a lot easier!

Color: 8
Border: 1.1

(defun c:mblank ( / js n dxf_ent)
(setq js (ssget '((0 . "MTEXT"))))
(repeat (setq n (sslength js))
(setq dxf_ent (entget (ssname js (setq n (1- n)))))
(entmod (append dxf_ent '((90 . 1) (63 . 8) (45 . 1.1) (441 . 0))))

AutoLISP: Create a Roof Pitch Symbol

AutoCAD Tips

If you need to create a roof pitch symbol this routine will surely help.

Here’s how:

  • PS <enter> to start “Pitch Symbol”
  • Select a line that has the slope that you need to calculate
  • Specify the base length of the symbol. (This is the horizontal line of the triangle). this can be done by entering a value in the command line or by picking 2 points
  • Specify what side of the line you want the symbol to be placed on.
  • Move the symbol into place

Note that the symbol created is not a block, it is a group

 c:pitch_symbol  a b c f g h i j k l m n p oldosmode oldosmode  a  c  a b  c c 'or  '=  pi  pi  pi  pi  b b b b b PITCH_BASE PITCH_BASE  c  PITCH_BASE c PITCH_BASE PITCH_BASE c h  d
             e  b  a f  b a  e f  a

View original post 1,172 more words

AutoLISP: Polyline Direction preview

AutoCAD Tips

The simplicity of this routine is why I like it so much. You simply run the command and then select a polyline and it displays temporary arrows that show the direction of the polyline. Once you either zoom in or out, or even use RE [enter] for a REGEN, the temporary arrows will stop displaying.

All credit goes to Luis Esquival and RonJon from for sharing and editing this routine.

Below – Various polylines have their directions shown

PolyLine Direction

As an extra bonus, this routine works on 3DPOLYLINEs. Even though the arrows aren’t exactly aligned, it is still nice to have a way to show the direction…

PolyLine Direction 3DPOLY


 getarcsegment cen r fromvertex p2  a1 a2 d fromvertex p2 a1  cen fromvertex
		 a2  cen p2 a1 a2 a1 a2  d  r  a2 a1 d  r  a2 a1 d  r  getbulgedata bulge fromvertex p2  dir theta beta radio dat bulge

View original post 692 more words