Author Topic: Aligning multileaders  (Read 18625 times)

0 Members and 1 Guest are viewing this topic.

Chris

  • Swamp Rat
  • Posts: 548
Aligning multileaders
« on: September 05, 2008, 07:43:23 AM »
Ok, I have been somewhat frustrated with AutoCAD's inability to properly align multileaders.  It is the only thing I believe is holding up our office from using them instead of our current standard Qleader.  Currently the MLEADERALIGN command moves the text to line up, disregarding the length of the landing.  I am trying to develop a program that will modify the length of the landing, so the leader does not change angle or locations, the text moves, and the tail gets longer or shorter as necessary. here is what I have so far, it doesnt do anything, maybe someone else can assist with it.
Code: [Select]
(defun c:multileaderalign (/        ss    ss2
   ent2        entdata2    textlocx
   ssno        count    mleader
   entdata1    textlocy1   textlocz1
   leglength   textlocx2   textlocx3
   textlocy3   textlocz3   extail
   proptail
  )
  (prompt "\nSelect multileaders:\n")
  (setq ss (ssget '((0 . "MULTILEADER"))))
  (if (/= ss nil)
    (progn
      (prompt "\nSelect multileader to align to:\n")
      (setq ss2 (ssget ":S" '((0 . "MULTILEADER"))))
      (if (/= ss2 nil)
(progn
  (setq ent2   (ssname ss2 0)
entdata2  (entget ent2)
textlocx  (car (cdr (assoc 12 entdata2)))
textlocx2 (car (cdr (assoc 10 entdata2)))
leglength (cdr (assoc 41 (reverse entdata2)))
ssno   (sslength ss)
count   0
  ) ;_ end of setq
  (while (< count ssno)
    (setq mleader   (ssname ss count)
  entdata1  (entget mleader)
  textlocx1 (car (cdr (assoc 12 entdata1)))
  textlocy1 (cadr (cdr (assoc 12 entdata1)))
  textlocz1 (caddr (cdr (assoc 12 entdata1)))
  textlocx3 (car (cdr (assoc 10 entdata1)))
  textlocy3 (cadr (cdr (assoc 10 entdata1)))
  textlocz3 (caddr (cdr (assoc 10 entdata1)))
  entdata1  (subst
      (assoc 12 entdata1)
      (cons 12 (list textlocx textlocy1 textlocz1))
      entdata1
    ) ;_ end of subst
  )
    (entmod Entdata1)
    (setq
   
  entdata1  (subst
      (assoc 10 entdata1)
      (cons 10 (list textlocx2 textlocy3 textlocz3))
      entdata1
    ) ;_ end of subst
  )
    (entmod Entdata1)
    (setq
  extail    (cdr (assoc 40 (reverse entdata1)))
  proptail  (+ extail (- textlocx textlocx1))
  entdata1  (subst (assoc 40 (reverse entdata1))
   (cons 40 proptail)
   entdata1
    ) ;_ end of subst
  )
    (entmod Entdata1)
    (setq
  entdata1  (subst (assoc 41 (reverse entdata1))
   (cons 41 proptail)
   entdata1
    ) ;_ end of subst
    ) ;_ end of setq
    (entmod Entdata1)
    (entupd mleader)
    (setq count (1+ count))
  ) ;_ end of while
) ;_ end of progn
      ) ;_ end of if
    ) ;_ end of progn
  ) ;_ end of if
) ;_ end of defun



Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Aligning multileaders
« Reply #1 on: September 05, 2008, 09:08:42 AM »
I only have ACAD2006 so no MultiLeaders.
Looks like you want to pick one leader text & align the selection set of leaders to that text x-axis position
and adjust all the leader tails. Is that it?
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.

Chris

  • Swamp Rat
  • Posts: 548
Re: Aligning multileaders
« Reply #2 on: September 05, 2008, 09:13:17 AM »
that's exactly it, you would think that the entmod and entupd would change the data, but when i run an entget on the entity after the fact, the data has not changed.  Does anyone know if entmod does not work on multileaders?
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Aligning multileaders
« Reply #3 on: September 05, 2008, 10:45:30 AM »
You might be fighting a reactor.
Why don't you try to use the MOVE command to move the text as needed & see if the reactor fixes the
leader line for you?
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.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Aligning multileaders
« Reply #4 on: September 05, 2008, 10:49:58 AM »
This could definitely be improved upon...but I think it does what you want:

Code: [Select]
(defun c:alignlandings (/ ss al alxpt el lp cp1 cp2)
  (if (and (setq ss (ssget '((0 . "MULTILEADER"))));;gets leader selection set
   (setq al (car (entsel "\nSelect leader to align to: ")));;gets leader to align to ename
   (setq alxpt (cdr (assoc 10 (entget al))));;(cdr strips the first item 10 and just returns the landing endpoint
      )
    (foreach ml (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)));;convert the selection set to a list of enames
      (setq el (entget ml);;converts ename to entity list
    lp (cdr (assoc 10 el));;(cdr strips the first item 10 and just returns the landing endpoint
    cp1 (polar lp 5.497 0.1);;bottom right diagonal point from landing point
    cp2 (polar lp 2.356 0.1);;upper left diagonal point from landing point
      )
      (command ".stretch" "box" cp1 cp2 "" lp alxpt);;stretch using box selection from lp to alxpt
    )
  )
  (princ)
)
« Last Edit: September 05, 2008, 11:14:44 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Chris

  • Swamp Rat
  • Posts: 548
Re: Aligning multileaders
« Reply #5 on: September 05, 2008, 11:06:12 AM »
This could definitely be improved upon...but I think it does what you want:

Code: [Select]
(defun c:alignlandings (/ ss al alxpt el lp)
  (if (and (setq ss (ssget '((0 . "MULTILEADER"))))
   (setq al (car (entsel "\nSelect leader to align to: ")))
   (setq alxpt (cdr (assoc 10 (entget al))))
      )
    (foreach ml (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq el (entget ml)
    lp (cdr (assoc 10 el))
    cp1 (polar lp 5.497 0.1)
    cp2 (polar lp 2.356 0.1)
      )
      (command ".stretch" "box" cp1 cp2 "" lp alxpt)
    )
  )
  (princ)
)
I think that will work, I'm not that familar with the mapcar and entsel commands, could you possibly explain what each part of the program is doing so I can learn from it and use this in the future?
here is my understanding:
select all the multileaders you wish to align
select the multileader you want to align to (entsel selects a single object, provides the object itself, and the selection point which is not necessary, hence the reason for the car)
grabs the point location information from the end of the tail
I'm guessing the foreach cycles through the selection set looking at each item
lp gets the current value of the end of the tail
cp1 and cp2 are your selection windows for the stretch command
and the stretch command, selects the objects, stretching the objects from lp to alxpt.

correct?
are there any limitations that you are aware of?
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Aligning multileaders
« Reply #6 on: September 05, 2008, 11:16:56 AM »
I commented the code above. You're take on what the routine does was pretty close :).

As far as limitations...I don't know other than it will not stretch the mleader if the stretched landing space is too small.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Chris

  • Swamp Rat
  • Posts: 548
Re: Aligning multileaders
« Reply #7 on: September 05, 2008, 11:20:08 AM »
well I'm sure if I find any limitations, I will be back to help try to solve them.
as a small side note, do you have any clue how to change the default prompt on ssget from "Select objects:"  with dynamic input on, it would be nice if you could see "Select multileaders:" instead
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

Chris

  • Swamp Rat
  • Posts: 548
Re: Aligning multileaders
« Reply #8 on: September 05, 2008, 11:29:35 AM »
I have found a limitation
if the leaders are coming from the opposite direction, the end of the tail lines up with the insert of the text.

this would be alleviated by using the 12 dxf instead of the 10 dxf.

there is another limitation, that I find difficult to describe, but I could see it happening.  A pictures worth a thousand words, so take a look.

I cant get "here to" to align with "testing this to see if it works"

I think it may have something to do with the crossing window, the points would need to be flopped in this situation for it to select it, correct?
« Last Edit: September 05, 2008, 11:35:58 AM by Chris »
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Aligning multileaders
« Reply #9 on: September 05, 2008, 11:36:11 AM »
If you post a drawing with possible scenarios, that would help. I have never used mleaders before so I'm having trouble picturing problems.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Chris

  • Swamp Rat
  • Posts: 548
Re: Aligning multileaders
« Reply #10 on: September 05, 2008, 11:40:02 AM »
If you post a drawing with possible scenarios, that would help. I have never used mleaders before so I'm having trouble picturing problems.

I think these would be the 4 major scenarios I would want to account for.
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Aligning multileaders
« Reply #11 on: September 05, 2008, 11:48:17 AM »
Sorry..I'm still not getting it  :? So what is the desired alignment point for each scenario?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Aligning multileaders
« Reply #12 on: September 05, 2008, 11:50:49 AM »
I suspect that you will need to use the MOVE for each mLeader Text to the x-axis target.
my 2 cents.
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.

Chris

  • Swamp Rat
  • Posts: 548
Re: Aligning multileaders
« Reply #13 on: September 05, 2008, 11:52:10 AM »
in the first 2 try to align the top text with the bottom text
in the 3rd one try to align the bottom text with the top text
and the 4th one already works fine as is, it's just a scenario that needs to work in the completed program.
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

Chris

  • Swamp Rat
  • Posts: 548
Re: Aligning multileaders
« Reply #14 on: September 05, 2008, 11:57:16 AM »
I suspect that you will need to use the MOVE for each mLeader Text to the x-axis target.
my 2 cents.
See the attached picture, move on a multileader moves the entire entity.
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10