ERROR INSERT AREA

ERROR INSERT AREA

rolisonfelipe
Collaborator Collaborator
393 Views
3 Replies
Message 1 of 4

ERROR INSERT AREA

rolisonfelipe
Collaborator
Collaborator

;;; CADALYST 07/08 www.cadalyst.com/code
;;; PRODUCES TEXT CONTAINING AREA OF SELECTED CLOSED POLYLINES
;;; AND PUTS THEM IN AREARON LAYER
;;; CREATED BY RON MANEJA 31JAN08
;;; USER INPUTS: SCALE, POLYLINE SELECTION
;;;

 

(defun C:AAA(/ allx ally areaobj counter ctr
el entity-name entnamevla mysset
pt tst vertex x y
)
(vl-load-com)
(COMMAND "_.UNDO" "BE")
(set_var)

(if (= (tblsearch "LAYER" "AREA"))
(command "-LAYER" "M" "AREA" "c" "007" "" "LT" "Continuous" "" "LW" "0.00" "" ""))


; (if
; (tblsearch "Layer" "AREARON")
; (command "._layer" "_thaw" "AREARON" "_on"
; "AREARON" "_unlock" "AREARON" "_set"
; "AREARON" "" ) ;_ closes command
; (command "._layer" "_make" "AREARON" "_color" 1 "AREARON" "") ;_ closes command
; )


(if (null sch)
(setq sch 1.0)
)
(initget 6)
(setq temp (getreal (strcat "\nENTER SCALE <"
(rtos sch 2 2)
">: "
)
)
)
(if temp
(setq sch temp)
(setq temp sch)
)

(if (null precision)
(setq precision 1)
)
(initget 6)
(setq prec_temp (getint (strcat "\nHOW MANY DECIMAL PLACES?: <"
(rtos precision 2 2)
">: "
)
)
)
(if prec_temp
(setq precision prec_temp)
(setq prec_temp precision)
)
(prompt "\nSELECT CLOSED POLYLINES:> ")
(setq
mysset (ssget '((0 . "POLYLINE,LWPOLYLINE") (-4 . "&") (70 . 1)))
counter 0
)
(if mysset
(progn
(while (< counter (sslength mysset))
(setq allx 0
ally 0
ctr 0
tst 1
entity-name (ssname mysset counter)
EL (entget entity-name)
entnamevla (vlax-ename->vla-object entity-name)
areaobj (vla-get-area entnamevla))
(while (assoc 10 el)
(setq vertex (cdr (assoc 10 el))
ctr (+ ctr 1)
x (car vertex)
y (cadr vertex)
allx (+ allx x)
ally (+ ally y)
EL (cdr (member (assoc 10 el) el))))
(setq x (/ allx ctr)
y (/ ally ctr)
pt (list x y))
(command "text" "j" "mc" pt (* sch 2.5) "0" (rtos areaobj 2 precision))
(setq counter (+ counter 1)))
)
(alert "\nNO CLOSED POLYLINES/LWPOLYLINES IN YOUR SELECTION")
)
(reset_var)
(princ)
(COMMAND "_.UNDO" "END")
)
(princ)


(defun set_var ()
(setq oldlayer (getvar "clayer"))
(setq oldsnap (getvar "osmode"))
(setq temperr *error*)
(setq *error* traperror)
(setvar "osmode" 0)
(princ)
)


(defun traperror (errmsg)
(command nil nil nil)
(if (not (member errmsg '("console break" "Function Cancelled"))
)
(princ (strcat "\nError: " errmsg))
)
(setvar "clayer" oldlayer)
(setvar "osmode" oldsnap)
(princ "\nError Resetting Enviroment ")
(setq *error* temperr)
(princ)
)

 

(defun reset_var ()
(setq *error* temperr)
(setvar "clayer" oldlayer)
(setvar "osmode" oldsnap)
(princ)
)

 

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

ERROR: 

ENTER SCALE <50>:
HOW MANY DECIMAL PLACES?: <1>:
SELECT CLOSED POLYLINES:>
Select objects: Specify opposite corner: 2 found
Select objects:
Unknown command "1606". Press F1 for help.
Unknown command "1606". Press F1 for help.
nil

 

NO SUM AREA

NO INSERT LOCAL AREA

NO SUM TOTAL AREA.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

0 Likes
Accepted solutions (1)
394 Views
3 Replies
Replies (3)
Message 2 of 4

Kent1Cooper
Consultant
Consultant

Is the current Text Style one that is defined for a fixed height?  The code provides an answer to the Text height prompt, which will not be asked if the current Style has a fixed height, so subsequent inputs will be to the wrong prompts.

Kent Cooper, AIA
0 Likes
Message 3 of 4

rolisonfelipe
Collaborator
Collaborator

TEXT HEIGHT WILL BE DIRECT ENTRY WITHOUT SETTING TEXT STYLE


TYPE:
"n/SET THE SCALE OF PROJECT 1 : " 50
0.002*50=0.10
TEXT HEIGHT 0.10

0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

@rolisonfelipe wrote:

TEXT HEIGHT WILL BE DIRECT ENTRY WITHOUT SETTING TEXT STYLE

TYPE:
"n/SET THE SCALE OF PROJECT 1 : " 50
0.002*50=0.10
TEXT HEIGHT 0.10


That is fine if the current Text Style will always be one whose defined "height" is zero.  Then the Text command will ask for a height.  You haven't answered my question -- when you have the problem, does the current Text Style have a fixed [non-zero] height?  And the follow-up question is:  if you ensure that the current Style does not have a fixed height, does it work correctly?  [It did for me.]

 

If it works for you with a non-fixed-height Style, "without setting text style" could be your problem.  If you build in the setting of a Text Style that you know does not have a fixed height, then it should work consistently.

 

The alternative is to make the Text using (entmake) instead of a Text command.  It takes more code, but then it won't matter whether the current Style has a fixed height.

Kent Cooper, AIA