AutoLISP: Convert 2D Solid to Polyline Outline

Since 2D solids aren’t very friendly after you place them and are hard to edit, you may need find this tool helpful for converting the solid into a polyline that represents the outline of the solid.

An example of its use is editing existing drawings… I have been adjusting blocks from an older block library where some parts of the blocks contain “arrowheads” but they are really just 2D solids. This is helpful so that the users don’t actually snap to these arrows. But a few of them no longer conform to our new CAD standards and sadly, some of the geometry was drawn incorrectly. So I have been using this routine to adjust these stubborn objects.

Here’s how:

  • OUTLINESOLID <enter>
  • Select the 2D Solid
Convert 2D Solid to Polyline

Convert 2D Solid to Polyline


;;; Select a 2D solid and this will delete the solid and replace its outline with a polyline
;;; http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Solid-object-to-Polyline/td-p/783079
;;; Posted By: Schamenek, Alex
(defun c:outlinesolid(/ solid pt1 pt2 pt3 pt4)
   (prompt "\nPlease select the solid you want to outline.")
   (WHILE (NOT (setq solid (ssget ":S" '((0 . "SOLID")))))
      (prompt "\nPlease select the solid you want to outline."))
      (SETQ pt1 (cdr (assoc 10 (entget (ssname solid 0))))
         pt2 (cdr (assoc 11 (entget (ssname solid 0))))
         pt3 (cdr (assoc 12 (entget (ssname solid 0))))
         pt4 (cdr (assoc 13 (entget (ssname solid 0))))
       );SETQ
   (COMMAND "_.PLINE" PT1 PT2 PT4 PT3 "C")
   (command ".erase" solid "")
);DEFUN
Posted in AutoLISP, AutoLISP: Modify, AutoLISP: Polylines | 8 Comments

View Fonts Used in Styles Without Opening A Drawing

Continuing the previous blog post concerning how to control what font is being used as the “Standard” text style – One issue that has come up is that upon opening a drawing that has the “Standard” text style defined as something other than what your machine has it set as, the text in the drawing is being changed  before the user has any control over it. Therefore they might not even know what the initial font was set as when the drawing was sent to them.

One way to check this is to use the Reference Manager tool that installs with AutoCAD.

This tool lets you see what a file’s needed references are and repath them if they are located in a different location without opening the file. (XREFs, .ctb files, Printer Configuration files [.pc3] fonts…

Here’s how:

Open the Reference Manager tool

Start > All Programs > Autodesk >  AutoCAD (version) > Refernce Manager

Opening the Reference Manager

Opening the Reference Manager

Upon opening, You are prompted to load all references (nested) or only the top level of references. If all you want to see is the drawing in question and it doesn’t have any references, use the bottom option.

Reference Manager Prompt

Reference Manager Prompt

When the Reference Manager loads – Simply “Add Drawings” and navigate to the drawing you need more information about. After “adding” the drawing. Notice that the font and the corresponding Text Style are shown. Simply jot this down and you now know what font goes with what Style.

Reference Manager for Text Style Fonts 2

 

Posted in Customization, Manage, Text, TIPS | 2 Comments

Change the “Standard” Font in AutoCAD Template

Some drafting standards require a text “font” that is something other than the “Arial” font, yet AutoCAD seems to keep reverting back to this font even after changing what font the text style is using. Some people almost have conniption fits because their text keeps changing…

Shown below: “Standard” text style using Arial.ttf

Standard Style using Arial.ttf

Standard Style using Arial.ttf

One reason is that the default acad.dwt  that is used for new drawings has this font defined for the “Standard” style. My first suggestion would be to not use a style named “Standard” as this can cause obvious conflicts. But even if you have no control over this, you can try the following:

Navigate to your AutoCAD Template folder and locate the “acad.dwt” file – The below screen shot is of the AutoCAD 2014 template folder.

AutoCAD 2014 Template location

AutoCAD 2014 Template location

Copy the file to another location as a back up in case something goes wrong.

Rename the file so that it is “acad.dwg” not a “.dwt” file

change file type to .dwg

change file type to .dwg

Open the in AutoCAD and change the Text Style in the “Text Style Manager” by using the command ST <enter>

Change the “Standard” style to the desired font under the “Font Name:” dropdown list.

Standard Style Set to "RomanS.shx"

Standard Style Set to “RomanS.shx”

  • Save and close the drawing. Note: Prior to closing, you may want to “SAVEAS” to an earlier version so that other AutoCAD users that use older version of AutoCAD can use this same file.
  • Change the file type from .dwg to .dwt so that it is once again a template file
  • Place the “acad.dwt” file back in the support folder.
Posted in Customization, Manage, Text, TIPS | 5 Comments

AutoCAD Self Adjusting Text Frame Using Multileaders

If you have ever had to add a frame around your text and then have had to edit that text and re-adjust or even recreate the frame, today’s tip will help save you the time from having to edit both the text and frame by simply editing the text.

The following tip has been tested successfully with AutoCAD 2013 and 2014. AutoCAD 2011 doesn’t have the controls to make this tip work as easily and adjustable and I don’t have a way to test this tip in AutoCAD 2012.

MLEADER TEXT BOX 1

Tip: after placing the multileader, adjust the width of the text column since multileaders width are collapsed…

MLEADER TEXT BOX 3

The first thing needed is to set up a multileader “Style” that has the desired text style and height defined

Open the MultiLeader style dialog by entering MLS <enter> in the command line or by clicking on the diagonal arrow in the bottom right of the “Leaders” oanel of the “Annotate” ribbon.

MLEADER TEXT BOX 2

Set the desired text style and heights to your new multileader style and make sure to apply the check mark next to “Frame text” under the “Content” tab. This applies the frame around your text that automatically adjusts.

MLEADER TEXT BOX 4

Apply the Multileader style to the desired multileaders. Notice that there is now a frame around the text. But also notice that there is a leader attached…

MLEADER TEXT BOX 5

To remove the leader:

  • Select the Multileader
  • Hover over the arrow endpoint of the Multileader
  • Select “Remove Leader”

MLEADER TEXT BOX 6

Enjoy your new auto-adjusting text box…

MLEADER TEXT BOX 7

Note: the size of the gap from the text to the frame is controlled by the “Landing gap” setting found in the “Content” tab of the Multileader “Style”

MLEADER TEXT BOX 8

 

Adding Background Mask to Hide background Objects:

  • Double click inside of the Multileader to activate the “Text Editor” contextual ribbon tab.
  • Click the “Background Mask” button that is found on the “Formatting” panel of the ribbon
  • In the Background Mask” dialog box, check the mark next to “Use background mask”
  • Also notice that the offset distance of the background mask is controlled from this dialog box.

Adding Background Mask To HideMLEADER Text Mask Done

Posted in Leaders, Text, TIPS, Uncategorized | 11 Comments

Raster Design Quick Start

A very cool AutoCAD add-on called “Raster Design” lets you easily incorporate raster images like .jpegs and .tif files in you drawing. The cool part about this software is that it lets you edits the images even though they are pixelated images. You can even convert these pixels into AutoCAD entities for editing using you normal AutoCAD commands and then when you need to present the edits in a PDF, you can change the AutoCAD entities back into the pixelated form so that they match the rest of the image.

Shown below is the Raster Design 2014 ribbon tab:

Raster Design 2014 Ribbon Tab

Raster Design 2014 Ribbon Tab

Let’s get started:

  • INSERT AN IMAGE – Using the “Insert…” tool located on the far left of the ribbon, you can navigate to the image that is to be brought into the drawing. The command line version for this tool is IINSERT <enter>

Note: The terminology is a little confusing because usually images are brought into AutoCAD with the ATTACH command and blocks are usually the only things that are “inserted”…

IINSERT 1

 

  • Browse to the image.

Notice the options at the bottom of the screen. The 2 shown below are asking how you want to be prompted for various settings while inserting the image. If you want to take the default settings, click “Quick Insert”

INSERT IMAGE DIALOG 1

 

Once the image is in your drawing, you may need to re-position and scale the image to fit your needs. You can scale it by using the SCALE command or by dragging one of its corners to shrink or expand the image. To move the image, use the MOVE command.

IMAGE TO BITONAL – Many of the tools in Raster Design only work if the image is “bitonal” (black & white). Shades of grey or color images simply wont work well in Raster Design. To make the image “bitonal” click on the “Process Image” drop-down > then click “Change Color Depth” > then B <enter> in the command line to choose the “Bitonal” option.

IMAGE TO BITONAL

 

INVERT COLORS – Now that the image is in your drawing in black & white, you can change the colors so that you are working in a more familiar color scheme. You can easily invert the colors so that the lines are white and the background is your normal AutoCAD background.

Click on the “Cleanup” drop-down > then click “Invert”

IMAGE INVERT COLORS 1

 

(shown below: image colors inverted)

IMAGE INVERT COLORS 2

 

DESPECKLE – The little speckles that are present in the drawing from the image can be easily cleaned up and make your editing look that much cleaner (and easier to edit).

Click the “Cleanup” drop-down and then “Despeckle”

DESPCKLE 1

 

You are then asked to specify an area of the image that you wish to clean up. For this example I used I <enter> to clean the entire image.

Note: I did notice that on a few drawings, it erased some periods and commas in text that was in the image. So be aware that those may come across as “speckles” and may be cleaned.

DESPECKLE 2

 

You are then asked to specify the size of the speckle so that it will look for similar sized speckles and clean them up. You can do this by either picking within a speckle or by making a window selection. when you are done, the similar sized speckles that are found are highlighted in red and you are prompted to accept the selection set of what it is about to clean up.

MANUAL TOUCH UP – You may need to manually touch up the drawing. For this, the “Touchup” tool allows you to manually erase or draw sections of the image similar to Microsoft Paint allows you to draw with a few pixels at a time.

TOUCHUP1

  • Toggle the color of the “Touchup” tool to either black or white by clicking  “Toggle drawing color”
  • The shape of the brush can be defined by the tools on the left side of the tool bar.
  • The angle of the brush is also defined on the 3rd tool from the left
  • The size of the brush can be changed by clicking the button shown below. This will let you define the size by either dragging a window or by entering a number.

TOUCHUP BRUSH SIZE 1

 

To exit the Touchup tool, use the buttons on the toolbar to CANCEL or OK to accept the edits.

Exit Touchup tool

 

CONVERT PIXELATED LINES TO VECTOR LINES – This allows you to make edits with your familiar AutoCAD commands. In the example below I only show how to use the tool that recognizes lines. There are other tools that recognize arcs, circles, polylines and rectangles.

On the “Vectorize & Recognize Text” panel, click the “Primitives” drop-down and then select “Line”

Vecortize Lines

 

  • Place the cursor within a line in the image. If the line is recognized, a dashed line will appear that has a little yellow arrow (glyph). To accept this, hit <enter> and the pixelated line will be turned into an AutoCAD line and the pixelated line will be erased.

RASTER LINE CLEANUP

 

When using this to recognize lines that should meet at their corners, it may not work as precisely as you’d like, but you can clean them up by using FILLET with a ZERO radius.

You may also need to use the Touchup tool to clean up left over pixels…

Raster Line Cleanup 2

 

Once the edits have been made, you will need to plot the drawing but the AutoCAD lines will look so different from the rest of the image. To change the AutoCAD lines back into “Raster” simply select the AutoCAD objects and then right click > select “Merge Vector To Raster Image”

Vector to Ratser 1

 

The AutoCAD objects will now match the Raster objects in the image

Vector to Raster 2

 

MANAGING THE IMAGE FILE (EMBED) – When you bring an image into a drawing, AutoCAD treats the image as a reference. that means that there will be 2 files needed in order for someone else to see the same thing that you see. Luckily, you can easily embed the image so that it is in the .dwg file so you only need to send someone the one file.

On the “Insert & Write” panel, click the “EMBED” tool and in one click, the image is now embedded in your drawing.

Embed the Picture into the drawing

Posted in Raster Design | 12 Comments

AutoLISP: Print All Layout Tabs

Here is a simple routine that should help plot all of the layout tabs in a drawing.

Note: This routine will print all of the layouts with the same setups -so this is a limitation and shouldn’t be applied to drawings that have layout tabs with various sizes and or orientation (Landscape and Portrait).

Last tested and used with AutoCAD 2011.

~Greg


;; Prints All Layout Tabs and names the new PDFs with the name of the
;; drawing followed by the layout tab name.
;;
;; Adjust the paper size and .ctb file as needed.
;;
;; The PDFs will be placed in the folder where the drawing resides
;;
(defun c:PA ()
(foreach lay (layoutlist)
  (setvar 'CTab lay)
  (COMMAND 	"-PLOT"
		"Y"
		""
		"DWG To PDF.pc3"
		"ANSI full bleed A (8.50 x 11.00 Inches)"
		"Inches"
		"PORTRAIT"
		"N"
		"E"
		"f"
		"C"
		"Y"
		"monochrome.ctb"
		"Y"
		"N"
		"N"
		"N"
		""; Name of file
		"N"
		"y"      )
    )
)
Posted in AutoLISP, Printing - Plotting | 1 Comment

Express Tool: Save All Opened Drawings

If you have multiple drawings opened in AutoCAD at the same time and would like to save all the drawings before stepping away from your computer… you can easily save all the currently open drawings with one command.

Note: If there happens to be an unnamed drawing opened (like drawing1), you will prompted to give that file a name.

Here’s how:

  • SAVEALL <enter>

That’s it.

This command is an Express Tool so AutoCAD LT users will not be able to use this command.

I think that this tool should be a part of AutoCAD and not an Express Tool.

Multiple Drawings Open 1

http://autocadtips.wordpress.com/?p=2022

Posted in Express Tools, Manage | 4 Comments