Nice work. It seems to address the issue at hand.
BTW, I always assumed a custom mleader style with content type mtext would be used.
I'll have to study it further to fully understand. More later once I have a handle.
Regards
Joe
wrote in message news:5758766@discussion.autodesk.com...
Hi Joe,
I found another avenue to explore, partly inspired by your idea about trying to
modify the textstring property of mleaders. (It does indeed work, as I'll demonstrate
below.) I completely agree with you about the crappy documentation.
Anyway, try this:
Set up a mleader style with mtext content. This will NOT work if you set the mleader
content to none.
Draw a mleader. It doesn't matter whether you enter in mtext or leave it blank.
What's important is that the mleader understands that mtext COULD be attached.
Then run the following code at the autocad command line, which grabs the last entity
and then substitutes a new mleader textstring:
(setq obj (vlax-ename->vla-object (entlast)))
(vlax-put-property obj 'textstring "This is\\Ptest number 1.")
or alternatively for the second line:
(vla-put-TextString obj "This is\\Ptest number 2.")
Note that one can get the textstring contents of obj this way:
(vla-get-TextString obj)
Previously I had been stymied by the loss of the pop-up editor once the mleader
command was coupled with a "while command pause" loop. I've since found a workaround
that shows some promise. My biggest complaint with it is that it requires an extra
return or space at the prompt before the user sees the mtext pop up
editor. That can be confusing for users, especially since the command prompt
provides no clue. I'm still thinking about how I might get around that without
limiting the command in other ways.
Anyway, here's the latest, warts and all. I'll be adding some more stuff, but this
is the meat of it.
(defun c:mly (/ cc_echo cc_ss cc_texteval)
(prompt "\nImproved mleader mtext behavior")
(setq cc_texteval (getvar "texteval"))
(setvar "texteval" 1)
(setq cc_echo (getvar "cmdecho"))
(setvar "cmdecho" 1)
(command "_.acad_dim.mleader")
(while (= (logand (getvar "cmdactive") 1) 1)
(command pause)
)
(setvar "cmdecho" cc_echo)
(setvar "texteval" cc_texteval)
(setq cc_ss (entlast))
(if (= (vla-get-ContentType (vlax-ename->vla-object cc_ss)) 2) ;check availability
of mtext content
(command "_.ddedit" cc_ss "") ;edit text and exit
command
)
(princ)
)
One thing I like about the command pause loop approach is that it allows the mleader
command to function in lisp much as it would on the Autocad command line. Users may
change the mleader options at the command line as they see fit, and not be locked
into a predetermined pattern and number of responses in order to proceed with the
command.
Note that I ended up including the texteval variable, even though it doesn't control
the appearance of the pop up mtext editor in mleaders. I found it DOES have an
effect on the block content option when selected via the mleader command line. if
not set to 1, the routine will pass an endless stream of backslashes to the block
name prompt.