Author Topic: MLeader with block  (Read 3745 times)

0 Members and 1 Guest are viewing this topic.

dkh007

  • Guest
MLeader with block
« on: August 31, 2008, 09:43:19 PM »
I'm trying to put together an annotative keynote using MLeader with a block. The MLeader command is always triggered last so I can't change the block attribute after I place the MLeader. I have snipped out the core of the routine that is giving me the problem. Any suggestions on a different approach or am I missing something? Attached is the block for use with the routine shown below...

Code: [Select]
(defun c:keynote ()
  (if (>= (substr (getvar "acadver") 1 4) "17.2")
    (initcommandversion 2)
  )
  (setvar "cmdecho" 1)
  (command "_.mleader" "O" "C" "B" "key_h" "X")
  (while (> (logand (getvar "CMDACTIVE") 0) 1)
    (command pause )
  )
  (command "_ddedit" "l")
  (princ)
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10369
Re: MLeader with block
« Reply #1 on: September 01, 2008, 09:03:37 AM »
Welcome to the Swamp. :-)

Have you tried
Code: [Select]
(command "_attedit" "l")
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10369
Re: MLeader with block
« Reply #2 on: September 01, 2008, 12:41:58 PM »
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Crank

  • Swamp Rat
  • Posts: 1441
Re: MLeader with block
« Reply #3 on: September 01, 2008, 01:15:03 PM »
Hi Daniel, Welcome to the Swamp!

I wonder what you're trying to do with the (undocumented) function (initcommandversion)... This should only be needed where you need a macro to use a new version of a command, and that's not the case here, because there exists only one version of the MLEADER command.
A usefull example for (initcommandversion) could be:
Code: [Select]
(setq ss (ssget))
(sssetfirst ss ss)
[color=blue](initcommandversion 2)[/color]
(command "_.explode")
In this case pickfirst will work, because you use the right version of the EXPLODE command.

If you modify this code a bit, you can use it also for mleaders with blocks.

 Vault Professional 2018     /      Building Design Suite Ultimate 2017     /     AEC Collection 2018 + 2019 +2020

dkh007

  • Guest
Re: MLeader with block
« Reply #4 on: September 01, 2008, 07:22:26 PM »
Welcome to the Swamp. :-)

Have you tried
Code: [Select]
(command "_attedit" "l")

Thanks for the Welcome! Because the block is part of a MLeader, _ATTEDIT doesn't work. No matter where the MLeader command is in the LISP, it always excutes last. I also posted this in the ACAD customization group and the suggestion of using "cmdnames" instead of "cmdactive". That seems to have done the trick.

Code: [Select]
(defun c:keynote ()
  (if (>= (substr (getvar "acadver") 1 4) "17.2")
    (initcommandversion 2)
  )
  (setvar "cmdecho" 1)
  (command "_.mleader" "O" "C" "B" "key_h" "X")
  (while (/= (getvar "cmdnames") "")
    (command pause)
  )
  (command "_ddedit" "l")
  (princ)
)

dkh007

  • Guest
Re: MLeader with block
« Reply #5 on: September 01, 2008, 07:26:41 PM »
Hi Daniel, Welcome to the Swamp!

I wonder what you're trying to do with the (undocumented) function (initcommandversion)... This should only be needed where you need a macro to use a new version of a command, and that's not the case here, because there exists only one version of the MLEADER command. <SNIP>


You are correct in this usage of MLeader it appears I don't need to use (initcommandversion). It was left over from my MLeader with MText, which is different in 2008 & 2009. This has allowed for backwards compatability of the routine.

ronjonp

  • Needs a day job
  • Posts: 7050
Re: MLeader with block
« Reply #6 on: September 01, 2008, 09:52:36 PM »
Daniel,

What are you trying to accomplish here? When I use the last version you posted, it inserts the mleader and continues to prompt for attrib input?


Ron

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

dkh007

  • Guest
Re: MLeader with block
« Reply #7 on: September 01, 2008, 11:35:40 PM »
Daniel,

What are you trying to accomplish here? When I use the last version you posted, it inserts the mleader and continues to prompt for attrib input?

Ron
Hi Ron,
I was just updating the forum with a solution of having the MLeader in the middle of a LISP and continuing through with other commands. The final will actually use a dialog for entering the attribute first. But I have already worked through that part of the LISP. The first post was just a simple example of something that did not work, similar to what I was trying to accomplish. Hope that clears things up.