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)

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 the.swamp.org 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

Space Dimensions With DimSpace

With the DimSpace command, you simply select your baseline dimensions, then use this command to evenly space them so they look great!

(In case you didn’t know, the dimensions should be spaced 3/8″ apart)

Here’s the sequence:

  • Command: DimSpace
  • Select base dimension:
  • Select dimensions to space: (Select the rest of the dimensions.)
  • Enter value or [Auto] < Auto >: (AutoCAD selects a value to space them, or you can input your own specific value.)

Spacing Value Tip:
You can use a spacing value of 0 (zero) to align the dimension lines of selected linear and angular dimensions end to end.

AutoLisp Tip:
If your like me, you want to automate the process as much as possible. This syntax will automatically input the distance for you. The only negative to this, is you can only select one dimension at a time instead of windowing multiple.

(Command "dimspace" pause pause "" ".375")

Startup Variable

Did you know you can control how AutoCAD starts up?

For most people when you open AutoCAD, it automatically starts a blank drawing with a template that has been set in the OPTIONS menu.

But did you know you can control whether AutoCAD opens a blank drawing or prompts you to open a drawing or template?

The system variable is STARTUP

0:    Displays the Select Template dialog box, or uses a default drawing template file set in the OPTIONS dialog box, on the files tab.

1:    Starts without opening a drawing template file, and displays the Startup or the Create New Drawing dialog box

2:    Starts without opening a drawing template file. If available in the application a custom dialog box is displayed


Tip: When Tracking Doesn’t Seem to Work

AutoCAD Tips

Here is one of the quirky things that AutoCAD does that might throw you for a loop. It involves “Tracking” whether it is “Object Snap Tracking” or “Polar Tracking” they seem to behave differently when Dynamic Input is turned onn or off. This is especially true for Object Snap Tracking. I have heard it said and taught, that these functions DO NOT work when Dynamic Input (DYN) is turned off. I am here to show you that they do.
When Dynamic Input is toggled on (as shown below) when you establish the reference point which has the green “glyph”, you pull away and see the dashed line and enter your tracking distance and you are just fine.

DYN Mode turned on OSNAP Tracking DYN Mode turned on OSNAP Tracking

The trouble seems to be when Dynamic Input is turned off and you establish the same reference point. You see the green “glyph” and dashed line as…

View original post 162 more words

CHANGE command

Do you find yourself having to clean up drawings that were poorly drawn? Maybe ends don’t meet or the lines are not orthogonal.  Did you know that the CHANGE command is a handy tool that can help you fix them?

The CHANGE command changes the endpoint of a line and the radius of a circle. The CHANGE command works differently, depending on whether you select lines or circles, so it’s best not to choose lines and circles at the same time.

Note: You can use the CHANGE command to change the rotation of blocks. The Properties option of this command can change many object properties, but it’s generally easier to use the Properties palette.



Dimension Overrides

Have you ever overrode a dimension outside the Dimension Style Manager and wished you could add the changes to your dimension style?

I’m going to show you how to do just that!

After you have finished tweaking the dimension simply select the dimension > right click > Dimension Style > Save as New Style > Select existing Dimstyle (or create a new one if needed).



How to simplify AutoCAD plotter list

This tip comes from CAD-notes.com

When you plot your drawing from AutoCAD, you may find too many plotters in plotter list. You’ll see Windows printers and AutoCAD default printers in the list.


If your computer is connected to several printers, this list can be long. You can simplify this list and display only printers you need in AutoCAD. Let’s find out how to do this.

Hide Windows system printers

You can hide Windows printers in AutoCAD. Go to AutoCAD options, Plot and Publish tab. Check Hide system printers in general plot option.


Now only AutoCAD plotters are displayed. How can we plot to a plotter registered as Windows printer? You will need to create PC3 file for that plotter. Let’s see how to do that.

To use Autodesk Plotter Manager

AutoCAD plotters are defined in Autodesk Plotter Manager. You can find it by opening Windows control panel and click Autodesk Plotter Manager.


Windows will open a folder. These are PC3 files for AutoCAD plotters.


To remove AutoCAD plotters

To remove plotters is easy. Create backups first. Copy all files as backup.

Now you can remove plotters you never use. If you ever need them again, copy them back to this location.

To add AutoCAD plotters

By hiding system printers, now the printer/plotter is may not in the list. You need to create it with Autodesk Plotter Manager.

Double click Add-A-Plotter Wizard.

Follow the steps in this wizard and choose System Printer for this plotter.


Change the configuration if necessary. After you finish, the wizard created a PC3 file for that plotter.

To plot with the new plotter

If you try to plot now, you can see shorter list of the plotters. Now you can choose the plotter you created before from the list.