Message 1 of 5
Lisp block insertion problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm using AutoCAD 2012 (still). I have a lisp routine from decades ago that inserts a block identifying the area of a given polyline in sqm and sq.ft.
Recently, it's stopped working. I suspect it's because I've changed some setting related to the dimscale (I cannot now change dimscale to anything other than 0, nor set cannoscale to 'none', say). The block uses the dimscale variable to determine its insertion scale size (well, it seemed like a good idea at the time).
I guess I could use a variable other than dimscale to determine the block insertion size, but I'm not sure what would be sensible. Anyway, any thoughts on that, or otherwise how to re-set the dimscale greatly appreciated.
Here's the lisp in full, and the block attached...
;;; Adapted from 'getarea.lsp by Omura Illustration (C) 1995 by Bill DeShawn & are_e.lsp by
;;; Jim (dedalos_2000@hotmail.com). Further, tiny
;;; modifications by Zac Carey (ZJC), 2002.
;;; Program to simultaneously place metric and imperial area information in a drawing.
;;; Make sure that the the block 'areaz.dwg' is located in the support directory.
;;; This block should contain, as a minimum, two attribute definitions, for metric and
;;; imperial data which, when writing the block, should be selected in that order.
;;; Ideally, each of these attribute definitions should be on different, and readily,
;;; identifiable layers. My block contains a third attribute definition for specifying the
;;; function that the given area is to be used for - and a fourth for specifying the floor
;;; no. or no. of floors to which the area data pertains. This is expressly for the purpose
;;; of exporting the area data to a spreadsheet.
;;; If you create a block with only two attribute definitions then the line;
;;; (command "insert" "areaz" pt sc "" "" ar mar "" "")
;;; should read
;;; (command "insert" "areaz" pt sc "" "" ar mar )
;;; To use, the area must first have a polyline outline
;;; Start plarea, then pick the polyline. Next, pick a point at which
;;; to locate the note. The area is then displayed in square metres and square feet.
(defun plareaerr ()
(setvar "cmdecho" 1)
(print "ERROR - Command aborted")
(command "_.undo" "_end")
)
(defun c:plarea (/ a ar mar pt sc pt1)
(command "_.undo" "_g")
(setq *error* olderr *error* plareaerr)
(setvar "cmdecho" 0)
(setq sc (getvar "dimscale"))
(setq os1 (getvar "osmode"))
(setvar "osmode" 512)
(setq pt1 (getpoint "Pick a closed polyline: "))
(command "area" "e" pt1)
(setq ar (getvar "area"))
(setq ar (/ ar 1000000))
(setq mar (strcat (rtos (* ar 10.7639104) 2 0)))
(setq ar (strcat (rtos ar 2 1)))
(setq pt (getpoint "select location for area note: "))
(command "insert" "areaz" pt sc "" "" ar mar "" "" "" )
(setvar "osmode" os1)
(setq *error* olderr)
(command "_.undo" "_end")
)