Is it possible to create annotative mtext with ENTMAKE ? I've done research and can't find a clear answer. Assuming the current text style is annotative, the code below will create annotative mtext when I use the (command "_.mtext") method, but it won't work with ENTMAKE.
Also, when I include the rotation angle in the ENTMAKE it doesn't create any entities. I'm thinking it has something to do with the earlier line of code that says:
(setq txtang (angtos (- mang (/ pi 2))))
Is angtos being misused? It works in the (command "_.mtext") method, but not ENTMAKE ...
Here is the full code...
(defun c:rdt () (princ "\nLabels the Radius of Curb & Gutter...") (rdtMain 2.5)) (defun c:rdtt () (princ "\nLabels the Radius of Header Curb...") (rdtMain 0.5)) (defun rdtMain (rads_offset / ss styleht txtht txtpos count txtstr ang1 ang2 mang cenpt rads txtang stpt tPosition annoht txtlayer *error*) (if (setq ss (ssget '((0 . "ARC")))) (progn (ErrorHandler '("cmdecho" "osmode" "dimzin" "clayer" "useri1")) (setvar "cmdecho" 0) (setvar "osmode" 0) (setvar "dimzin" 8) (setq txtlayer "Sp-Pvmt-Curb-Radi-Text") (if (tblsearch "layer" txtlayer) (command "_.-layer" "t" txtlayer "on" txtlayer "s" txtlayer "") (prompt (strcat "\nLayer \"" txtlayer "\" not in drawing. Using current layer..."))) (setq styleht (cdr (assoc 40 (tblsearch "style" (getvar "textstyle"))))) (setq annoht (/ 1 (getvar "cannoscalevalue"))) ; 1/.025 = 40 (if (= styleht 0) (progn (initget 7) (setq txtht (getreal "\nEnter height of text: "))) (setq txtht styleht)) (initget "Outside Inside") (setq txtpos (getkword "\nPlace text [Outside/Inside] <Outside>: ") count 0) (cond ((null txtpos) (setq txtpos "Outside"))) (repeat (sslength ss) (setq txtstr (strcat (rtos (cdr (assoc 40 (entget (ssname ss count)))) 2 1) "'R") ang1 (cdr (assoc 50 (entget (ssname ss count)))) ang2 (cdr (assoc 51 (entget (ssname ss count))))) (if (< ang2 ang1) (setq ang2 (+ (* 2 pi) ang2))) (setq mang (/ (+ ang1 ang2) 2) cenpt (cdr (assoc 10 (entget (ssname ss count)))) rads (cdr (assoc 40 (entget (ssname ss count)))) count (+ count 1)) (if (>= mang (* 2 pi)) (setq mang (- mang (* 2 pi)))) (if (= txtpos "Outside") (setq rads (+ rads (+ rads_offset (* annoht txtht 0.50)))) (setq rads (- rads (+ rads_offset (* annoht txtht 0.50))))) (if (<= mang pi) (setq txtang (angtos (- mang (/ pi 2)))) (setq txtang (angtos (+ mang (/ pi 2))))) (setq stpt (polar cenpt mang rads)) (entmake (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") ;(cons 8 (getvar "CLAYER")) ;not required (cons 10 stpt) (cons 7 (getvar "TextStyle")) ; Current Style ;(cons 40 txt_ht) ; (getvar "TextSize")) ; Current height (cons 41 0) ; 0 Width = no wrap (cons 71 5) ; 5 = middle center ;(cons 50 txtang) ; rotation angle (cons 1 txtstr) )) ;(command "_.mtext" stpt "j" "mc" "r" txtang "w" 0 txtstr "")) (*error* nil) ) (princ) ) ) (princ "\n\"RDT 2.2\" is loaded...\nType \"RDT\" for Curb & Gutter and \"RDTT\" for Header Curb...\n") (princ) (defun ErrorHandler (varlist / echo) ;Error Handler (eval (append '(defun *error* (msg / echo)) (mapcar '(lambda (var) (list 'setvar var (getvar var))) varlist) '((setq echo (getvar "cmdecho")) (setvar "cmdecho" 0) (command "_.undo" "end")) '((setvar "cmdecho" echo) (princ)))) (setq echo (getvar "cmdecho")) (setvar "cmdecho" 0) (command "_.undo" "end") (command "_.undo" "begin") (setvar "cmdecho" echo) (princ))
@mjs9199 wrote:
Also, when I include the rotation angle in the ENTMAKE it doesn't create any entities. I'm thinking it has something to do with the earlier line of code that says:
(setq txtang (angtos (- mang (/ pi 2))))Is angtos being misused? It works in the (command "_.mtext") method, but not ENTMAKE ...
The DXF group code 50 for mtext is looking for angle in Radians. In entmake you cannot pass it a data type 'string' which is what (angtos... ) returns. Try (setq txtang (- mang (/ p1 2.0)))
Don't know about the annotative issue right now...