AutoCAD/Linetypes with lisp

Advertisement


Question
I have little experience with lisp, but i know some basic things.  My company has a lisp that will create layers depending on the type of drawing  being worked on I.E. mechanical, structural, piping, etc.  But we have special linetypes that are associated with some of the layers.  So at the begining of the lisp i use the command function to have cad load all the special linetypes that are needed.  The problem i am having is when 1 or some of the the linetypes are already loaded into the drawing the lisp errors out.  I know this because using the linetype command in cad it if a linetype you are trying to load is already in a drawing it alerts you of this and asks you if you would like to overwrite it. What needs to be done in the routine to accout for this?

Answer
There is a function called tblsearch you can use to determine if the linetype you are about to load is already loaded.
So your code would be something like:
(if (not (tblsearch "linetype" "mylinetype"))
 (command "linetype" ...)
)

Look up tblsearch in the online help in the lisp function reference for further explanation and to check my syntax. I'm just going from memory here.

AutoCAD

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scott Cook

Expertise

I`ve been using AutoCAD since 1987 and programming AutoLISP nearly as long. I can answer questions about programming AutoCAD (except ARX) and production enhancement techniques. I cannot answer questions about AutoCAD crashes or DWG corruption. AutoCAD PROGRAMMING (menus, lisp) related questions only!

Experience

Since 1987. Author of Plot2000 software for for AutoCAD, http://www.plot2000.com. PROGRAMMING QUESTIONS ONLY PLEASE. Questions that are NOT related to programming or AutoCAD customization (menus and lisp only please) are outside the scope of my volunteer services and will NOT BE ANSWERED.

©2012 About.com, a part of The New York Times Company. All rights reserved.