Lisp block insertion problem

Lisp block insertion problem

strawberry12
Advocate Advocate
843 Views
4 Replies
Message 1 of 5

Lisp block insertion problem

strawberry12
Advocate
Advocate

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")
)
844 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

Insert is certainly not accepting 0 as a scale factor.  Set your current Dimension Style to one that is not annotative.  From Help for the DIMSCALE System Variable:

However, if the current dimension style is annotative, DIMSCALE is automatically set to zero and the dimension scale is controlled by the CANNOSCALE system variable. DIMSCALE cannot be set to a non-zero value when using annotative dimensions.

Kent Cooper, AIA
0 Likes
Message 3 of 5

strawberry12
Advocate
Advocate

Hi,

 

Thanks, I've fixed that. So DIMSCALE is now 1.0 . Unfortunately, it's still not working.

 

The command console states: "too many arguments", so I still think I've recently re-set some variable somewhere, but I just can't think what.

0 Likes
Message 4 of 5

strawberry12
Advocate
Advocate

Futher, I've just tested it on a colleague's machine and it works fine, so I really think I've stuffed up some setting somewhere.

0 Likes
Message 5 of 5

john.uhden
Mentor
Mentor

The first thing I see is that the author stipulated that the AREAZ.dwg should contain either 2 or 4 attributes.  Your INSERT command is calling for 5 attributes.  Explode the AREAZ block in your problem drawing and count how many attdefs it has (thaw and turn on all layers first).  Maybe it has none, and maybe the definition in your problem drawing is different from the stand-alone file.  Remember that AutoCAD will use the definition in the drawing before it goes looking for a dwg file of the same name.

John F. Uhden

0 Likes