Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating a mleader from a lisp

20 REPLIES 20
SOLVED
Reply
Message 1 of 21
Anonymous
2611 Views, 20 Replies

Creating a mleader from a lisp

Hi, all I want to do is create an icon, in a new ribbon tab, that sets the layer to text, and launches the mleader command - so the user can create their mleader on the correct layer. I already have this functionality using the tool palette, but wanted to add it to the ribbon as well.

 

So I figured the easiest way to do it would be write a little lisp routine that makes the layer, then launches the mleader command. I could then call the routine from my icon on the ribbon.

 

It was all going well until the mleader command ran, and I couldn't add the text on-screen, like I normally would - it switched to the command line, and everytime I press space it finishes the command - no good.

 

My attempt:

 

(defun c:ml01(/ ml01)
  (command "cmdecho" "0")
(command "-layer" "m" "text" "c" "4" "" "" )
(command "cmleaderstyle" "text")
  (command "cmdecho" "1")
(command ".mleader"  pause)
(princ)
)

 

Any ideas?

 

Thanks.

 

20 REPLIES 20
Message 2 of 21
hmsilva
in reply to: Anonymous

Something like this perhaps

(defun c:ml01 ()
  (setvar 'CMDECHO 0)
  (command "-layer" "m"	"text" "c" "4" "" "" "cmleaderstyle" "text")
  (setvar 'CMDECHO 1)
  (command ".mleader")
  (while (> (getvar 'cmdactive) 0)
    (command pause)
  )
  (princ)
)

HTH

Henrique

EESignature

Message 3 of 21
Anonymous
in reply to: hmsilva

That does the same thing. It only lets me enter text at the command line, and when I press space it finishes the command.
Message 4 of 21
hmsilva
in reply to: Anonymous


@Anonymous wrote:
That does the same thing. It only lets me enter text at the command line, and when I press space it finishes the command.

Sorry, I didn't understood properly, try this revised code

(defun c:ml01 ()
  (setvar 'CMDECHO 0)
  (command "-layer" "m"	"text" "c" "4" "" "" "cmleaderstyle" "text")
  (setvar 'CMDECHO 1)
  (initcommandversion)
  (command ".mleader")
  (while (> (getvar 'cmdactive) 0)
    (command pause)
  )
  (princ)
)

HTH

Henrique

 

 

Henrique

EESignature

Message 5 of 21
Anonymous
in reply to: hmsilva

That's got it.
Henrique, you the man.
Thanks a lot.
Message 6 of 21
hmsilva
in reply to: Anonymous

You're welcome.
Glad I could help

Henrique

EESignature

Message 7 of 21
m_rogoff
in reply to: Anonymous

This is a great routine! I have multiple MLeader Styles and was hoping you could expand on your lisp. If you could PLEASE help and add another line to Set Current a pre-formatted ML Style, that would be great! Thanks and good work 

Message 8 of 21
Anonymous
in reply to: m_rogoff

Just alter "text" to whatever your mleader style is called.

(command "-layer" "m" "text" "c" "4" "" "" "cmleaderstyle" "text")

...if I understand your needs correctly 🙂

 

cmleaderstyle = current mleader style.

 

Message 9 of 21
Anonymous
in reply to: hmsilva

Incidentally, do you know how to add a background mask, at 1.5 and a specific colour, to the mleader at the same time?

Message 10 of 21
hmsilva
in reply to: Anonymous


@Anonymous wrote:

Incidentally, do you know how to add a background mask, at 1.5 and a specific colour, to the mleader at the same time?


Attach a sample dwg with the "before and after" MLeader...

 

Henrique

EESignature

Message 11 of 21
Anonymous
in reply to: hmsilva

Hi Henrique, I've attached a sample of what I was after.

Thanks for your time.

 

Message 12 of 21
hmsilva
in reply to: Anonymous


@Anonymous wrote:

Hi Henrique, I've attached a sample of what I was after.

 


Hi borderliner,

the attached code uses two sub-functions from Lee Mac's MaskV1.lsp   (Thanks Lee)

It should work as expected, minimally tested...

 

HTH

Henrique

EESignature

Message 13 of 21
Anonymous
in reply to: hmsilva

Hi Henrique, as ever - fantastic.

Hopefully I'll be able to brutalize it to do what I want, but it definately looks like it's 99% the way there already.

 

Thank you very much.

 

Are you addicted to kudos?

 

Message 14 of 21
Anonymous
in reply to: hmsilva

I spoke too soon, how do I change the colour of the text mask from 200,200,200?
I think I've found everything else, it's just that.
Thanks.
Message 15 of 21
hmsilva
in reply to: Anonymous


@Anonymous wrote:
I spoke too soon, how do I change the colour of the text mask from 200,200,200?
I think I've found everything else, it's just that.
Thanks.

From 200,200,200 to?

 

Henrique

 

EESignature

Message 16 of 21
Anonymous
in reply to: hmsilva

We have a couple of dozen different mleader styles, many have their own colours, so I was wondering what controls the mask colour.

Thanks

 

Message 17 of 21
hmsilva
in reply to: Anonymous


@Anonymous wrote:

We have a couple of dozen different mleader styles, many have their own colours, so I was wondering what controls the mask colour.


From the code:

(cons 091 -1027028792)

 

 -1027028792 is the color, to get the color number this post may be useful, see phanaem's or Lee's code...

 

HTH

Henrique

 

EESignature

Message 18 of 21
Anonymous
in reply to: hmsilva

Thanks man.

I'd manged to work out the codes for the other things.

I found a neat little lisp called color converter that lets you select an other in ACAD, and it list the RGB and true colour codes.

 

...I was just reading your link - now it makes a little more sense, it's not a true colour value 420. More reading is called for.

Who knew I'd be diggin' around in this on Monday.

 

Thanks again, you've been a huge help. I'm sure you've got better things to be doing.

 

Message 19 of 21
hmsilva
in reply to: Anonymous

You're welcome, borderliner

Henrique

EESignature

Message 20 of 21
Anonymous
in reply to: hmsilva

Holy cow, that was like pulling teeth - I've had more fun at the dentist.

 

But I've got it now, using phanaem's code to convert the numbers (thanks phanaem).

Have to remember to save it somewhere.

 

Smiley Happy

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost