AutoCAD/Current CTB for Lisp

Advertisement


Question
How can lisp test if current drawing's CTB file is missing?
I plot other peoples drawings with a lisp and what to use their pen widths, when possible.
(Command "-plot" "Yes" "" "~11x17~" "11x17" "Inches" "Landscape" "No" "Extents" "Fit" "Center" "Yes" "" "Yes" "Yes" "No" "No" "No" "No" "Yes")
If I don't have their CTB, lisp crashes. If CTB is missing, lisp would use default CTB.

Answer
Well, there are two pieces to this puzzle - 1. find out what the CTB is currently set to, and 2. see if it exists on the system.
Findfile usually searches the ACAD path, not the plotters and plot styles folders. You can use findfile with the path and filename together, though - and it will tell you if the file exists on your system.
(findfile "c:\\path\\to\\your\\plot styles\\ctbfile.ctb") will return nil if it does not exist. You have to use two backslashes with lisp in between the folder names.

The hard part is figuring out what CTB the drawing wants - this delves into the autocad object model, which is accessible from lisp, but after 10 minutes of looking I don't have the answer for you just yet. It should be in the online help, developer documentation->ActiveX and VBA reference->Object model.  

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.