Lisp: Delete Extra Annotative Scales from Objects

This routine has helped me many times when receiving drawings from others that include annotative blocks and text, you may not need as many scales that are applied to these annotative objects.

Everything looks fine with the received file shown below. When I hover over the text and blocks it shows that there are more than one annotation scales applied to them. This is indicated by the two annotative symbols.

Annotative Scale 2

Then you go ahead and select the annotative objects and that’s when these extra annotation scales start their fun.

Annotative Scale 3

Annotative Scale 5

Annotative Scale 4 Even though you can manually delete scales from objects, it is time-consuming and can be prone to miss some objects. That is where this LISP routine comes in handy. provided by Irneb found [here].

When you are in model space, set your scale and then use this routine to purge out all of the scales except the current scale.

::: Delete Annotative Scale Execpt Current
;;; By Irneb

(defun c:ObjectScaleCurOnly (/ ss n scLst OSC:GetScales)
  (print "Select the objects you wish to modify: ")
  (if (or (setq ss (ssget "I")) (setq ss (ssget)))
      ;; Define helper function to get scales attached to an entity
      (defun OSC:GetScales (en / ed xn xd cdn cdd asn asd cn cd sn sd cannoscale)
        (setq ed (entget en))
        (if (and
              ;; Get the XDictionary attached to the object
              (setq xn (vl-position '(102 . "{ACAD_XDICTIONARY") ed))
              (setq xn (cdr (nth (1+ xn) ed)))
              (setq xd (entget xn))
              ;; Get the Context Data Management dictionary attached to the XDictionary
              (setq cdn (vl-position '(3 . "AcDbContextDataManager") xd))
              (setq cdn (cdr (nth (1+ cdn) xd)))
              (setq cdd (entget cdn))
              ;; Get the Annotation Scales dictionary attached to the CD
              (setq asn (vl-position '(3 . "ACDB_ANNOTATIONSCALES") cdd))
              (setq asn (cdr (nth (1+ asn) cdd)))
              (setq asd (entget asn))
              ;; Get the 1st scale attached
              (setq cn (assoc 3 asd))
              (setq cn (member cn asd))
          ;; Step through all scales attached
          (while cn
            (if (and (= (caar cn) 350) ;It it's pointing to a scale record
                     ;; Get the record's data
                     (setq cd (entget (cdar cn)))
                     ;; Get the Context data class
                     (setq sn (assoc 340 cd))
                     (setq sd (entget (cdr sn)))
                     (setq sn (assoc 300 sd))
                     ;; Check if the scale is already in the list
                     (not (vl-position (cdr sn) scLst))
              ;; Add it to the list
              (setq scLst (cons (cdr sn) scLst))
            (setq cn (cdr cn))

      ;; Find a list of scales used in selection
      (setq n (sslength ss))
      (while (>= (setq n (1- n)) 0)
        (OSC:GetScales (ssname ss n))

      ;; Add the current scale to the selection
      (setq cannoscale (getvar "CANNOSCALE"))
      (command "._ObjectScale" ss "" "_Add" cannoscale "")

      ;; Remove all other scales attached
      (command "._ObjectScale" ss "" "_Delete")
      (foreach n scLst
        (if (wcmatch (strcase n) (strcat "~" (strcase cannoscale)))
          (command n)
      (command "")

Posted in AutoLISP, AutoLISP: Text, Modifying | 5 Comments

Import PDF Geometery

New in AutoCAD 2017 is the much-needed ability to import PDFs. This new feature will import geometry and True Type Fonts (.ttf) only. If your PDF file contains fonts that use an .shx font, that text will be imported as linework. But either way, this is by far my favorite new feature.

There are two options to import the PDF:
1) Importing a PDF by browsing to a file.
2) With a PDF already attached to the drawing (like an XREF) – Importing a portion of the PDF or the entire PDF.

Here’s how:

Browsing to a PDF:
The Command to import a PDF is simply PDFIMPORT or the “PDF Import” button is found on the Insert tab > Import panel > Import Dropdown.

PDF Import

Notice the command line that asks you to “Select the PDF Underlay or [File]”. Click on the “File” option.
Select PDF or File

After you select the PDF, You will see the “Import PDF” dialog box.

Import PDF Dialog box

Make sure to check out the options in this dialog box. Something that I really like is that the line weights used in the PDF can be imported. The other great thing is that if the PDF was created using the option to create layers, those layers will be imported as well.

When you click on the “Options…” button of the dialog box, it will open the normal AutoCAD “Options” dialog box. Here you can specify where the PDF Import should place any Images that are in the PDF. These images will be imported and attached to the drawing like an XREF.

PDF Import Options Button

After you click the OK button back in the PDF Import dialog box, the progress bar will churn a little bit and then voila!!! your PDF is now imported as editable AutoCAD geometry.

PDF Import 1 Done

Importing an attached PDF:

You can use the PDFIMPORT command and button just like the above step.
Select PDF or FileThere is also a new button on the “PDF Underlay” Contextual ribbon that displays when you select the PDF that is currently in your drawing.

PDF Underlay Ribbon

When you start the command and select the PDF, you will see the options in the command line to select a portion of the PDF objects or All of the PDF.
Import all or someYou will then need to specify what should be done with the attached PDF after the import is completed.
Unload Detach or KeepThe Settings dialog box looks different but has the same settings as the “Import PDF” considering the PDF is already in your file.

Import PDF Dialog box

When you click OK it will churn away and your PDF will be imported.

Conversion Status

Attached PDF Imported

Posted in New in 2017, PDF, TIPS | 3 Comments

CAD Bloggers at Autodesk University

Once again I have been luck enough to attend Autodesk University. It is always a great time to meet fellow CAD nerds from around the world and especially catch up and meet fellow CAD bloggers. I thought it would be nice to show the bloggers that I have had the chance to catch up with this year. Hopefully some of your favorite bloggers are shown below.
P.S. – notice how many pictures are photo-bombed by R.K.

Lynn Allen
Twitter: @Lynn_Allen
Greg Lynn

Heidi Hewett
(my first AutoCAD Instructor)
Heidi Greg

Shaan Hurley
Twitter: @ShaanHurley
Blog: Hurley

Melanie Stone-Perry & Frank Mayfield

Twitter: @MistresDorkness

Twitter: @TheMadCadr
Frank and Melanie

Greg Battin
Twitter: @AutoCADTips1

Paul Munford
Twitter: @CadSetterOut

Donnie Gladfelter
Twitter: @thecadgeek
The CAD Geek

Kean Walmsley
Twitter: @keanw

R.K. McSwain
Twitter: @cadpanacea
RK McSwain

Kurt Moreno
Twitter: @wkfd

Shaun Bryant
Twitter: @notjustcad
Shaun Bryant

Patrick Hughes
Twitter: @Time_Trvlr
Patrick Hughes

Owen Wengerd
Outside The Box

Christopher Fugitt
Twitter: @C3DReminders
Chris Fugitt

Posted in Autodesk University | 8 Comments

Load A Linetype

Here is a simple explanation for how to load a linetype. I decided to demonstrate how to do so for an appropriate layer but a line type can be loaded from the “Properties” panel as well.

Here’s how:

  • In the Layer Dialog box, under the “Linetype” column, click on the linetype name that is set to your layer. In the example shown, it is set to “Continuous.”
  • A Dialog box “Select Linetype” will appear
  • Click the “Load” button
  • Another dialog box “Load or Reload Linetypes” will display. It is from this long list of linetypes that you need to select the specific linetype.
  • Click OK.
  • The linetype is loaded but it isn’t assign to the layer.
  • So now that you are back in the “Select Linetype” dialog box, select the newly loaded linetype and then click OK.
  • The linetype is now loaded in the drawing and assigned to a layer

Load Linetype for Layer

The loaded linetype can also be seen in the Properties palette and in the Properties panel of the ribbon on the Home tab of the ribbon.

Linetype in the Properties Panel 1

Linetype in the Properties Panel 2

Posted in Layers, Linetypes | 2 Comments

Revit Reorganize Revit Tabs

As I have been making my transition to Revit I have a few tips that you might find helpful even though there are plenty of other Revit blogs and resources to visit – I promise to keep this blog as AutoCAD-focused as possible but keep in mind that I am making the transition to Revit but my heart is truly in AutoCAD and these tips are for when you, as an AutoCAD user find yourself in the “World of Revit” and need some help.

I currently work for a structural engineering firm in Denver using Revit and occasional use AutoCAD. When I open Revit 2014 and newer, the various Revit “flavors” are all in one package. This package used to be called “Revit One Box” but that name faded away and it is simply called “Revit”.

When you open Revit in its default “out-of-the-box” settings the first panel of the ribbon is the Architectural tab – which is just fine if you are and Arch person. But for others like us Structural or MEP folks, it would be nice to be able to open Revit and have it open to the discipline in which we work. Thus the tips for today.

Simply Hold the CTRL button down and then drag the Ribbon tab to the front of the ribbon so that it opens when you open Revit. This also allows you to reorganize the other ribbon tabs that you have. Just be aware if your have many ad-ons, this could be messy, but worth it.

Structure Tab 1st baby

And to be honest, the lack of controls in Revit make me miss AutoCAD that much more everyday – like the CUI and customization… But Revit has its strengths in just doing what it does without having to need extra add-ons as much…


Posted in Customization, Revit | 7 Comments

Convert 3D Revit to DWG

Just in case you need to convert a 3D Revit model to 3D AutoCAD, here ya go. It is very simple but remember to click one button to make sure you work with ACAD solids…

Here is a snapshot of the Revit model:

3D view of Revit model

3D view of Revit model

With the Revit model open, Click the Application Menu (“Big R”) > “Export” > “CAD Formats” > Select “DWG“.

Revit 2 ACAD 2

In the “DWG Export” dialog box – Click on the ellipsis (button with 3 dots) to open the “Modify DWG/DXF Export Setup” dialog box.

  • Click the “Solids” tab
  • Select “ACIS solids
  • Click Next

Revit 2 ACAD 3

Click “Next…” to continue

Revit 2 ACAD 4

Define the folder where you would like the new DWG to reside and also give it a new name if desired. You can also define what DWG version to process it as. Click OK to proceed with the conversion.

Revit 2 ACAD 5

In the lower left of the Revit screen you will see a status bar showing you the progress of the conversion.

Revit 2 ACAD 6

Once it is done, notice the new DWG. I will warn you that the Revit File to DWG conversion will make the overall file larger. The Revit file used in this example was 58mb and after the conversion to DWG was 70mb.

Revit 2 ACAD 7

Now you can edit the converted file – Also note that the objects are AutoCAD solids.

Revit 2 ACAD 8

Posted in Revit | 4 Comments

Hurricane Batch Processor Review

AutoCAD batch scripts can be powerful by themselves, but if you couple that with the ability to apply them to a multitude of drawings then it can be really powerful. I first saw the power of scripting while using the “Core Console” in 2013 and made a post about it found here. But then realized that there was some limitations and one in particular was its inability to process OLE objects.

Script Pro is still pretty nice, but from my testing a batch processor called “Hurricane” I have grown fond of its built-in functions and scripts. There is a new version available called “Hurricane MX” but I have only used the older one which is just fine for me.

So I decided to try a batch of drawings using Hurricane and sharing the results with you.

Hurricane List of batch steps


A sneek peek into my “custom” script simply shows that the script loads a lisp routine (just to spice things up)

Script and LISP files


Shown below is the folder of drawings to be processed.

Hurricane 1



Shown below is the main interface of Hurricane. It is somewhat straight forward but takes time to get to learn just like everything. Specify the files (individual or entire folder)

Build the script in the ‘User Script” tab by selecting some pre-made scripts found in the “User Script List”. If you plan on selecting multiple pre-made scripts – DONT FORGET TO CHECK THE APPEND BUTTON.
Huricane 4


As shown below, the program builds a single script containing all of the steps that you define for the drawings that you selected to be processed.

NOTE – That you need to have a drawing currently open for the process to start. Just don’t have one of the drawings in the list of drawings that you are wanting to process open.

Hurricane 5


The results are shown below

Hurricane 6


And as a big relief – the drawing that contained an OLE object came out just fine.


Hurricane 7


Posted in Manage, OLE Objects, Scripts | Leave a comment