jt6572 发表于 2022-7-5 16:53:09

set layer, text height, style,

hello,
sorry if this is an old question - i looked a bit for it but couldnt find just what i am after - but i am trying to have a command/button to create mtext and set the properties for it.
 
for example, i would like to be able to type in "35" and have the mtext window on screen but the layer set to "text 35" and the text style and height set to "standard" and "3.5".
 
i am working on this coding i found

(defun c:tstyle ()   (command "-style" "MR_ROMANS" "romans" "3.5" "1" "what" "are" "these" "values") )
 
but i dont know what the values in inverted commas after "3.5" are. i assume they are layer, etc., but i could be very wrong... probably.
 
thanks for your help.

jt6572 发表于 2022-7-5 17:01:00

okay, so i am almost there.
i have used the following:
 

(command "Layer" "M" "NEWLAYER" "")(command "Style" "MR ROMANS" "romans" "3.5" "" "" "" "" "")(command "mtext")
 
and it sets everything as i want (layer, style, size, etc.).
 
the only thing i would like now is that when the mtext comes in, i only get the small text input on screen. i will try to find out how to fix this, but if anyone knows, please add!

BIGAL 发表于 2022-7-5 17:11:48

Numbers work fine in lisp defuns
 

; 35 now maybe 35m for mtext 35t for text(defun c:35 ()(command "Layer" "M" "NEWLAYER" "")(command "Style" "MR ROMANS" "romans" "3.5" "" "" "" "" "")(command "mtext"))
or

(defun c:35 ()(command "Layer" "M" "NEWLAYER" "" "Style" "MR ROMANS" "romans" "3.5" "" "" "" "" "" "mtext"))

jt6572 发表于 2022-7-5 17:17:38

good morning BigAl!
 
here is exactly what i have
 

(defun c:t35 ()(command "Layer" "M" "MR_TXT_035" "")(command "Style" "MR ROMANS" "romans" "3.5" "" "" "" "" "")(command "mtext") )
 
the only issue i have is i am getting the command line input on screen type, whereas i want it to be the in place editor. i have no idea why mtext isnt running as usual?

jt6572 发表于 2022-7-5 17:26:24

got it! it was here:
 
http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/when-using-mtext-in-a-lisp-routine-text-can-only-be-entered-on/td-p/2630396
 
i needed this:
 

...(initdia)(command ".mtext")
 
thanks BigAl!

BIGAL 发表于 2022-7-5 17:36:13

You dont the the period (command "mtext") the initdia is the bit needed, sometimes you need to use a - eg -layer stops the dialog box from popping up.

jt6572 发表于 2022-7-5 17:43:31

excellent. thank you.

jt6572 发表于 2022-7-5 17:45:50

okay, more more more!
 
does anyone know how i can set the text to have a background mask? (i know the value after ((90 .is 2 to use the background and mask) also for leader text? i have two separate lisps i would like to combine, but i dont know how to integrate this
 

(defun c:mblank ( / js n dxf_ent)(setq js (ssget '((0 . "MTEXT"))))(cond        (js                (repeat (setq n (sslength js))                        (setq dxf_ent (entget (ssname js (setq n (1- n)))))                        (entmod (append dxf_ent '((90 . 2) (63 .(45 . 1.1) (441 . 0))))                )        )))
 
into this
 

    (defun c:t5 () (command "Layer" "M" "MR_TXT_050" "")(command "Style" "MR_ROMANS" "romans" "5" "" "" "" "" "")(initdia)(command "mtext")

David Bethel 发表于 2022-7-5 17:53:47

Since it is impossible to determine the number of parameters required for the STYLE table command without reading the shape's .shp definition file, I use this :
 

;++++++++++++ Set SHX or PFB Text Style ++++++++++(defun SetStyle (s)(and (or (/= 'STR (type s))(and (not (tblsearch "STYLE" s))       (and (not (findfile (strcat s ".SHX")))          (not (findfile (strcat s ".PFB"))))))   (princ (strcat "Cannot Access Text Style " s))   (exit))(command "_.STYLE" s s)(while (> (getvar "CMDACTIVE") 0)   (command "")))
 
I prefer an (exit) here due to the inaccurate expectations of the results.Therefore a robust *error* replacement is required.
 
-David
页: [1]
查看完整版本: set layer, text height, style,