AutoLISP: Updated Join Dimensions for AutoCAD 2014 & 2015

I was made aware that the Join Dimensions routine previously posted [here] wasn’t working for AutoCAD 2014 & 2015 so here is an updated version.

Here’s how:

  • After loading JDIMS [enter] to start
  • Select the first dimension
  • Select the second dimension

Note: the two dimesnions have to be the same type of dimension (either both Aligned or both Rotated…)

JDIMS for 2014 & 2015


;Shusei Hayashi
;OffshoreCad&Management Inc.
;10F Jaka Bldg., 6780 Ayala Ave.,
;Makati, Philippines
; Slightly modified to work with AutoCAD 2014 & 2015
; Greg Battin

(defun c:JDIMS( /  Flag ObjName1 ObjName2 Ang Ang2 Pt1 Pt2 Pt3 Pt4)
	(princ "\n convert two dimensions to total Dimension on the same position")
	(princ "\n **********************************")
	(setq *error* *myerror*)   
	(setq LegLen 7.0)
	(setq Flag nil)
	(setvar "Clayer" Lay1)
	(setvar "Cecolor" Col1)
	(setvar "Celtype" LT1)
	(while (= Flag nil)
	   (setq ObjName1 (car (entsel "\n Select 1st Dimension :")))
		(if (and ObjName1(= (cdr (assoc 0 (setq Data1 (entget ObjName1)))) "DIMENSION"))
			(setq Flag T)
	(redraw ObjName1 3)
	(setq theStyle (SD3511 3 ObjName1))
	(setq Flag nil)
	(while (= Flag nil)
		(setq ObjName2 (car (entsel "\n Select 2nd Dimension :")))
		(if 	(and 	ObjName2 
				(= (cdr (assoc 0 (setq Data2 (entget ObjName2)))) "DIMENSION")
				(or	(equal (abs (- (cdr (assoc 50 Data1))(cdr (assoc 50 Data2)))) 0.0 0.0001)
					(equal (abs (- (cdr (assoc 50 Data1))(cdr (assoc 50 Data2)))) pi 0.0001)
			(setq Flag T)
				(princ "\n two dimensions should have same angle")
	(redraw ObjName1 4)
	(setq PList (list (cdr (assoc 13 Data1))(cdr (assoc 14 Data1))(cdr (assoc 13 Data2))(cdr (assoc 14 Data2))))
	(setq PList2 (list (cdr (assoc 10 Data1)) (cdr (assoc 10 Data2))))
	(if (/= (distance (cdr (assoc 14 Data1))(cdr (assoc 10 Data1))) 0)
		(setq Ang (angle (cdr (assoc 14 Data1))(cdr (assoc 10 Data1))))
		(setq Ang (+ (angle (cdr (assoc 13 Data1))(cdr (assoc 14 Data1))) (* 0.5 pi)))
	(setq Ang2 (+ Ang (* -0.5 pi)))
	(setq ItsLayer (cdr (assoc 8 Data1)))
	(setq PList_n (mapcar '(lambda(x)(SD1862 x Ang2))PList))
	(setq PList2_n (mapcar '(lambda(x)(SD1862 x Ang2))PList2))
	(setq PList_n_x (mapcar 'car PList_n))
	(setq PList2_n_y (mapcar 'cadr PList2_n))
	(setq Position1 (vl-position (apply 'min PList_n_x) PList_n_x))
	(setq Position2 (vl-position (apply 'max PList_n_x) PList_n_x))
	(setq Position3 (vl-position (apply 'max PList2_n_y) PList2_n_y))
	(setq Pt1 (nth Position1 PList))
;	(checkcircle Pt1 1.0 "A21")
	(setq Pt2 (nth Position2 PList))
;	(checkcircle Pt2 1.0 "A31")
	(setq Pt3 (nth Position3 PList2))
;	(checkcircle Pt3 1.0 "A51")
;	(setq Pt4 (polar Pt3 Ang (* LegLen Scale)))
;	(checkcircle Pt4 1.0 "A21")
	(setq 	Pt1 (trans Pt1 0 1)
			Pt2 (trans Pt2 0 1)
			Pt3 (trans Pt3 0 1)
;			Pt4 (trans Pt4 0 1)
	(setq UAng (angle '(0 0) (getvar "UCSXDIR")))
	(setq Ang2 (- Ang2 UAng))
	(command "._dimstyle" "RE" theStyle)
	(command "dimrotated" (* 180 (/ Ang2 pi)) Pt1 Pt2 Pt3)
	(command "change" (entlast) "" "P" "LA" ItsLayer "")
	(entdel ObjName1)(entdel ObjName2)
	(setq *error* nil)
(defun RegistryRead_1001()
	(setq Path1001 "HKEY_CURRENT_USER\\Software\\SpeedDraftLT\\SD_1001")
	(if (vl-registry-read Path1001 "LegLen" )
		(progn 	(set_tile "LegLen" (vl-registry-read Path1001 "LegLen"))
				(setq LegLen (atof (vl-registry-read Path1001 "LegLen")))
		(setq LegLen 7.0)
	(if (and (vl-registry-read Path1001 "Lay1" )(member (vl-registry-read Path1001 "Lay1") Laylist1))
		(progn 	(set_tile "Lay1" (itoa (vl-position (vl-registry-read Path1001 "Lay1") Laylist1)))
				(setq Lay1 (vl-registry-read Path1001 "Lay1"))
		(progn 	(setq Lay1 (getvar "Clayer"))(set_tile "Lay1" (itoa (vl-position Lay1 Laylist1))))
	(if (and (vl-registry-read Path1001 "LT1" )(member (vl-registry-read Path1001 "LT1") Laylist3))
		(progn 	(set_tile "LT1" (itoa (vl-position (vl-registry-read Path1001 "LT1") Laylist3)))
				(setq LT1 (vl-registry-read Path1001 "LT1"))
		(progn 	(setq LT1 "ByLayer")(set_tile "LT1" "0"))
	(if (and (vl-registry-read Path1001 "Col1" )(member (vl-registry-read Path1001 "Col1") Laylist2))
		(progn 	(set_tile "Col1" (itoa (vl-position (vl-registry-read Path1001 "Col1") Laylist2)))
				(setq Col1 (vl-registry-read Path1001 "Col1"))
		(progn 	(setq Col1 "ByLayer")(set_tile "Col1" "0"))
(defun SD1028 ()
  (setq OldCmdEcho (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (command "undo" "be")
  (setq OldOsmode (getvar "OSMODE"))
  (setq OldLayer (getvar "CLAYER"))
  (setq OldLType (getvar "CeLType"))
  (setq OldCeLWeight (getvar "CeLWeight"))
  (setq OldColor (getvar "CeColor"))
  (setq OldOrtho (getvar "ORTHOMODE"))
  (setq OldDStyle  (getvar "DIMSTYLE"))
  (setq OldExpert (getvar "Expert"))
  (setvar "EXPERT" 0)
  (setq Path_Lang "HKEY_CURRENT_USER\\Software\\SpeedDraftLT")
;  (if (vl-registry-read Path_Lang "SD_Language" )
;  	(setq SD:Lang (vl-registry-read Path_Lang "SD_Language" ))
;  	(progn	(setq SD:Lang "J")
;  			(vl-registry-write Path_Lang "SD_Language" "J")
;  	)
;  )
(defun SD2056 ()
  (setvar "OSMODE" OldOsmode)
  (command "undo" "end")
  (setvar "CLAYER" OldLayer)
  (setvar "CeLType" OldLType)
  (setvar "CeLWeight" OldCeLWeight)
  (setvar "CeColor" OldColor)
  (setvar "ORTHOMODE" OldOrtho)
  (setvar "Expert" OldExpert)
  (if (and (/= (getvar "DIMSTYLE") OldDStyle)(tblsearch "DIMSTYLE" OldDStyle))
  	(command "-dimstyle" "Restore" OldDStyle)
  (princ "\n (C)OffshoreCad&Management")
  (setvar "CMDECHO" OldCmdEcho)

(defun get_layer&ltype&color()
	(setq 	Lay (tblnext "LAYER" T)
			LT (tblnext "LTYPE" T)
			Laylist1 (list)
			Laylist2 (list "ByLayer" "Red" "Yellow" "Green" "Cyan" "Blue" "Magenta" "B/W")
			Laylist3 (list"ByLayer")
	(While Lay
		(setq lay1 (list (cdr (assoc 2 Lay)))
			  lay2 (cdr (assoc 62 Lay))
			  lay3 (list (cdr (assoc 6 Lay)))
			  Laylist1 (append Laylist1 lay1)
			  Laylist3 (append Laylist3 lay3)
			  Lay (tblnext "LAYER")
	  	(if (> lay2 7)(setq  lay2 (list (itoa lay2)) Laylist2 (append Laylist2 lay2)))
	(While LT
		(setq lay3 (list (cdr (assoc 2 LT)))
			  Laylist3 (append Laylist3 lay3)
			  LT (tblnext "LTYPE")
	(setq 	Laylist1 (RemoveOverlap Laylist1)
			Laylist2 (RemoveOverlap Laylist2)
			Laylist3 (RemoveOverlap Laylist3))
(defun RemoveOverlap (	List2	/	List1	)
	(while List2
		(setq List1 (append List1 (list (car List2))))
		(setq List2 (vl-remove (car List2) List2))

(defun SD8446 ( PointA PointB Ang / XA YA XB YB PointC)

	(setq 	XA2(- (car PointA) (car PointB))
			YA2(- (cadr PointA) (cadr PointB))
	(setq PointC (list (- (* XA2 (cos Ang))(* YA2 (sin Ang))) (+ (* XA2 (sin Ang))(* YA2 (cos Ang)))))
	(setq PointC (mapcar '+ PointC PointB))
(defun SD1862 (OldPt Ang / NewCs)
	(setq NewCs (SD8446 '(1 0) '(0 0) Ang))
	(setq NewPt (trans OldPt 0 NewCs))
	(setq NewPt (list (nth 2 NewPt)(nth 0 NewPt)))
(defun SD3511 (g e)
		((= (type e) 'ename) (cdr (assoc g (entget e))))
		((= (type e) 'list) (cdr (assoc g e)))
(defun *myerror* (msg)
	(setq *error* nil)
	(princ "\n Error in SpeedDraftLT")
	(princ "\n Command Name: JDIMS")
Posted in AutoCAD 2015, AutoLISP, AutoLISP: Dimensions, AutoLISP: Modify, Dimensions | Leave a comment

AutoLISP: ATTWIPE Clear Selected Attribute Values

Here is one that lets you easily clear the selected attribute tag(s).

This is especially helpful for when you are editing titleblocks that have populated attributes or when you copy a block (symbol) that already has attribute values already populated.

Here’s how:

(After loading of coarse)

  • ATTWIPE [enter]
  • Select the individual attributes that you would like to clear…
  • hit [enter] when finished to end the routine



;; ------------------------------------------------------------------------------
;; AttWipe - © 2005 by Chuck Chauvin
;; Posted at:;all
;; Clears (wipes) the value of a selected attribute
;; ------------------------------------------------------------------------------
(defun C:AttWipe (/ AttSel AttLoc)
  (defun *error* (msg)
    (princ "\nInvalid selection.")
  );_ end defun *error*

  (defun SelectIt (msg)
  (setq AttLoc (cadr (setq AttSel (entsel (strcat "\nPick " msg " to wipe: ")))))
    );_ end defun SelectIt

  (defun WipeIt (/)
    (command "-attedit" "y" "" "" "" AttLoc "" "v" "r" "" "n")
    );_ end defun WipeIt

  (setvar "cmdecho" 0)
  (SelectIt "attribute")
  (while AttSel
    (SelectIt "next attribute")
    (if	(= (type AttSel) 'list)
      (setq AttSel nil)
      ) ;_ end if
    ) ;_ end while
  );_ end defun AttWipe
;; ------------------------------------------------------------------------------
Posted in Attributes, AutoLISP, AutoLISP: Attributes, Blocks, Modifying | Leave a comment

AutoCAD 2015 Purge DGN Junk

That’s right, I called it “Junk”.

Recently we have been experiencing excessive bloating of files because somewhere in our project someone has either referenced in a drawing that was opened with Microstation or they have copied in something from a drawing that was used by Microstation.

Below is an example of a drawing that was almost 14 megabytes in size and needed to email it to someone out “in the field” but because of its file size, it was too large to email.


When you start the PURGE command in AutoCAD 2015, you now have the option to purge “Orphaned data.” AutoCAD apparently handles Microstation linestyles and text styles differently so the info that defines these objects becomes “orphaned” and can bloat drawings severely.

Check the box as shown below



If you have any of this purge-able data, the progress of the purge will be shown in the lower right of the AutoCAD screen (shown below)



To purge the “Orphaned” DGN junk from your drawings using the command line version of PURGE command in a script or macro, use the O (letter O) after issuing -PURGE from the command line.



Note: after purging what could be a lot of data from a drawing, it is a good idea to AUDIT your drawing. In the command line, enter AUDIT [enter] Y [enter]

For more info about how to purge unused DGN info from your drawings, check out these links:

Autodesk’s hotfix for AutoCAD 2013 & 2014:

Kean’s explanations:

Posted in AutoCAD 2015, Manage, New in 2015 | 1 Comment

Fix Install or Uninstall Errors

Here is a possible fix for fixing errors that might have occurred during an install of AutoCAD (or any other program) that is preventing you from doing a “repair” or “Re-install.”

Scenario: An issue that has happened at work a few times recently was that a user updated to a new version of AutoCAD but for some reason it doesn’t open. I would then check to see if the files seemed to be copied correctly and tried to manually launch the acad.exe but that didn’t work either. I then went to the computer’s “Control Panel” to do a “Repair” or “Reinstall” of the new version of AutoCAD. The version of AutoCAD seems to be listed in the list of programs but once it is selected, the “Control Panel” says that it can’t be repaired because there was an error during installation.

Once these frustrating steps were tried over and over again, the common fix was to have the user’s machine re-imaged so that a fresh install could be applied. That is, until we found this useful link from Microsoft:

It is a free utility from Microsoft that finds errors of an install that will hopefully allow the program to be successfully uninstalled and then re-installed.

I hope that this utility can help


Microsoft Repair 1

Posted in Manage, TIPS | 1 Comment


We recently were given some 3D models by a subcontractor that needed to be incorporated into our drawings. There was one model in particular that was rather large in file size considering that it was only a small part of our overall design for the project. And to top it off, the 3D model from the subcontractor was to be placed about 11 times throughout the overall model. Even when the large file was brought into the drawing as an XREF, many of the AutoCAD designers experienced loading times of about 10 minutes.

The file size of the large model is almost 50 megabytes even after trying many methods to reduce its size. The method that we found that worked wonders was to use a FLATSHOT representation of the 3D model as a substitute for the 3D model.

Here’s how:

Below is a view of the piece of equipment that is 50 megabytes.

3D view of 50 megabyte file

3D view of 50 megabyte file

Below is a top view of the large file. This view is all that a majority of the designers needed to see in their drawings

Flatshot 2 Top View

The FLATSHOT command can be used at the command line or the tool can be found on the ribbon under the “3D Modeling” workspace under the “Home” tab > “Section” panel (dropdown) > “FLATSHOT

Note: that the view that is currently being shown on-screen will be used to produce the FLATSHOT version of the model. Think of this command as you orient your view of a 3D model and then take a picture with a camera. That picture is now the flattened 2d representation of the 3D model.
Keeping that in mind, if needed we could go to the side elevation views of the 3D model and produce FLATSHOT versions of those views so that they could be incorporated into someone’s drawing as well – thus reducing the time of opening the larger file.

Flatshot 3 Flatshot on ribbon


For this instance, I used the following settings to produce the FLATSHOT.

I suggest playing with the various settings to meet the needs of your particular project.

Flatshot  settings1

Once the FLATSHOT file is created it is a good idea to open the file and try to clean it up further. Some commands that might help are: OVERKILL, PURGE, JOIN, AUDIT

Below is a file size comparison of the large 3D model, the FLATSHOT version and the cleaned up FLATSHOT

Flatshot 4  File shize comparison

Now that we have a 2D version of the 3D model, the designers simply unload or detach the larger model from the XREF Manager in AutoCAD and load the FLATSHOT version.

Note: it is important to assign a person to take resposibility of keeping the 3D model and the FLATSHOT version in synch. If the 3D model was to be altered or moved in some way, the FLATSHOT would need to be updated so that everyone is using the most current data. In our instance at work, the large 3D model was not going to change through the project so it was an easy 1-time solution.


Flatshot 5 XREF manager unloaded

Posted in Manage, Modifying, TIPS, XREFs | 5 Comments

AutoCAD 2015 Resize Model Space Viewports

AutoCAD 2015 now makes resizing model space viewports intuitive and easy.

If you use multiple model space viewports, you’ll love this feature.

A special note needs to be made that the frame of the model space viewports has 2 areas. The area where the plus sign + resides is meant for adding a new viewport. The other area consists of the rest of the viewport edge and has the symbol with 2 lines.

Viewport frame picture 2

Resize a viewport by simply left-click and dragging the edge of the viewport within the “2 line” area.

The intersection of multiple viewports can be dragged to adjust the size all of the intersecting viewports.

Viewport Frame 1To add a new model space viewport, you can left-click and drag the plus sign + near the top or right side of the viewport edges.

You can also left-click and drag anywhere along the viewport edge and hold the Ctrl key to make a new viewport.

If you would like te delete a viewport, you can simply drag a viewport edge  until it collapses.

Viewport Frame 2


Viewport Frame picture 1

Posted in AutoCAD 2015, New in 2015 | 2 Comments

AutoLISP: Dynamic Text Align

With AutoCAD 2015’s new TEXTALIGN tool, comes the question of “what about those of us that don’t have AutoCAD 2015”?

Luckily, Lee Mac has a LISP version that accomplishes many of the same functions and even adds a few others.


Lee Mac’s Dynamic Text Align

Posted in AutoLISP: Modify, AutoLISP: Text, Modifying, Text | 1 Comment