TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Andrea on April 03, 2018, 01:05:14 PM

Title: MLEADER OPTIONS
Post by: Andrea on April 03, 2018, 01:05:14 PM
Hi guys,.

is there any way to get the status of these options ?

Command: MLEADER
Specify leader arrowhead location or [leader Landing first/Content first/Options] <Options>:



Command: MLEADER
Specify leader landing location or [leader arrowHead first/Content first/Options] <Options>:


the fact is that I can't use (command "_MLEADER"...) and don't have the courage to create prog to prevent this..... :glarestraight:

any help will be appreciated.
Thank you.
Title: Re: MLEADER OPTIONS
Post by: mjfarrell on April 03, 2018, 01:25:56 PM
IF the DXF codes for the objects will help they are listed in documentation.
Title: Re: MLEADER OPTIONS
Post by: Dlanor on April 03, 2018, 01:39:43 PM
MLeader Style has the DrawMLeaderOrderType property which can have two possible values

acDrawLeaderHeadFirst : draws line starting at arrowhead (default)

acDrawLeaderTailFirst : Starts with text entry prompt then starts line at the landing/vertex junction
Title: Re: MLEADER OPTIONS
Post by: Andrea on April 03, 2018, 01:44:58 PM
Thank you guys...very appreciated.. :)
Title: Re: MLEADER OPTIONS
Post by: Andrea on April 03, 2018, 01:51:43 PM
well,..after making tests...

the value seem to still same...
so I still stuck with this..
Title: Re: MLEADER OPTIONS
Post by: Crank on April 03, 2018, 03:10:42 PM
I think it's some kind of registry setting. You can download Process Monitor (https://docs.microsoft.com/nl-nl/sysinternals/downloads/procmon) to monitor registry changes. It works in real time and shows all system files, registry changes and processes/threads of your system  (many similar tools from other sources also exist).

If you don’t like using third-party software for performing system tasks, or any other tasks in Windows. Reg (or RegEdit) and FC are Windows’ built-in commands, which allow you to monitor and compare states of your registry.


Title: Re: MLEADER OPTIONS
Post by: Andrea on April 03, 2018, 04:22:22 PM
I think it's some kind of registry setting. You can download Process Monitor (https://docs.microsoft.com/nl-nl/sysinternals/downloads/procmon) to monitor registry changes. It works in real time and shows all system files, registry changes and processes/threads of your system  (many similar tools from other sources also exist).

If you don’t like using third-party software for performing system tasks, or any other tasks in Windows. Reg (or RegEdit) and FC are Windows’ built-in commands, which allow you to monitor and compare states of your registry.

Thank you,...
I've allready done that but no variable or reg key seem to be added or changed..
I tooked a look into xdata and sysvdlg..but no modification..  :|
Title: Re: MLEADER OPTIONS
Post by: Lee Mac on April 03, 2018, 06:46:10 PM
As far as I'm aware, the state of the MLeader options is not accessible through system variables or registry values (that are updated in real-time at least), nor is this information exposed to the LISP API.

However, one workaround to 'force' the MLeader command into a known state (e.g. Arrowhead First) is to issue the following prior to invoking the command:

Code - Auto/Visual Lisp: [Select]
  1. (defun NormaliseMLeader ( / cmd ent tmp )
  2.     (setq cmd (getvar 'cmdecho)
  3.           ent (entlast)
  4.     )
  5.     (while (setq tmp (entnext ent)) (setq ent tmp))
  6.     (setvar 'cmdecho 0)
  7.     (vl-cmdf "_.mleader" "_h") ;; Force arrowhead first
  8.     (while (= 1 (logand 1 (getvar 'cmdactive))) (vl-cmdf "0,0"))
  9.     (if (not (eq ent (setq ent (entlast)))) (entdel ent))
  10.     (setvar 'cmdecho cmd)
  11.     t
  12. )

However this isn't the cleanest solution, yielding an unavoidable "Invalid Input" should the 'Arrowhead First' option already be enabled.

I believe this solution was first suggested by Stefan at some point - so all credit to him.
Title: Re: MLEADER OPTIONS
Post by: cmwade77 on April 03, 2018, 07:21:17 PM
There are still some minor bugs that some people run up against with my code, but you could take a look at my ULEADER command for some inspiration. The code is massive and is definitely geared toward our company standards, but I think a lot could be learned there. Pay special attention to all of the sections that Lee Mac and several others from The Swamp have contributed.

NOTE: Be sure to put the uleader.dwg file in a path that AutoCAD will search in.

As you can see, programming ULeaders is definitely not for the faint of heart and honestly I am sure that someone like Lee Mac could go through my code, add better error handling and probably cut the number of lines of code in half.

But using these methods would eliminate the issues you are having because it would eliminate the use of (command "._uleader").
Title: Re: MLEADER OPTIONS
Post by: ribarm on April 04, 2018, 04:26:35 AM
As far as I can recall, version 3.0k that was posted here was last one... Your attachment is little bigger - you changed something, right?

https://www.theswamp.org/index.php?topic=46576.msg539760#msg539760
Title: Re: MLEADER OPTIONS
Post by: roy_043 on April 04, 2018, 02:24:55 PM
FYI:
With BricsCAD this setting is available is the registry, and, contrary to many other settings, is updated in real-time.
Code: [Select]
(defun Mleader_ArrowHeadFirst_P ()
  (/=
    0
    (vl-registry-read
      (strcat
        "HKEY_CURRENT_USER\\"
        (vlax-product-key) "\\"
        "Profiles\\"
        (getvar 'cprofile) "\\"
        "MLeader\\"
      )
      "Mode"
    )
  )
)
Title: Re: MLEADER OPTIONS
Post by: Lee Mac on April 04, 2018, 02:48:38 PM
With BricsCAD this setting is available is the registry, and, contrary to many other settings, is updated in real-time.
Code: [Select]
(defun Mleader_ArrowHeadFirst_P ()
  (/=
    0
    (vl-registry-read
      (strcat
        "HKEY_CURRENT_USER\\"
        (vlax-product-key) "\\"
        "Profiles\\"
        (getvar 'cprofile) "\\"
        "MLeader\\"
      )
      "Mode"
    )
  )
)

An equivalent key exists in AutoCAD (though named 'CreatedMode' in lieu of 'Mode'), however such key is not updated in real-time but only when AutoCAD is closed, rendering it useless for this task  :|

BricsCAD wins again.  :lol:
Title: Re: MLEADER OPTIONS
Post by: Andrea on April 04, 2018, 03:48:03 PM
Thank you guys,...

the problem comes when using MLEADER without LEADER !
so the selection ask only to enter 1 coordinate point instead of leader arrow point and text location..
Title: Re: MLEADER OPTIONS
Post by: Lee Mac on April 04, 2018, 05:22:43 PM
Thank you guys,...

the problem comes when using MLEADER without LEADER !
so the selection ask only to enter 1 coordinate point instead of leader arrow point and text location..

You can account for this by checking the MLeader Style properties.
Title: Re: MLEADER OPTIONS
Post by: Dlanor on April 04, 2018, 07:09:50 PM
If you want to create a leader tail first, create a new temp style with the DrawMLeaderOrderType property set to acDrawLeaderTailFirst. Mleaders created with this style using command  _mleader will default to startiing at the tail. I don't think this applies to creating the object via AddMLeader though, unless you reverse the point order in the safe array (not tested). Once the leader is formed you can change it's style and it will take on the properties of the new style i.e. leader will disappear if leader type in new style is none.
Title: Re: MLEADER OPTIONS
Post by: Andrea on April 05, 2018, 10:09:48 AM
Thank you guys,..

I finally solve this issue by putting this code before creating Mleader.:

Code: [Select]
(command "_.mleader" "_H")(command)
 :knuppel2:
Title: Re: MLEADER OPTIONS
Post by: cmwade77 on April 05, 2018, 02:27:07 PM
As far as I can recall, version 3.0k that was posted here was last one... Your attachment is little bigger - you changed something, right?

https://www.theswamp.org/index.php?topic=46576.msg539760#msg539760
I believe that version has some of our company specific stuff removed, which would explain why this file is larger, but I don't think anything else changed, but I could be wrong.