Author Topic: Multileader: Move but keep original placement of leader points  (Read 4972 times)

0 Members and 1 Guest are viewing this topic.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
I needed/wanted a way to select a MLeader with additional objects around it (text, lines marking through text in MLeader, etc.), move to new location but keep original placement of leader points.

I scratched this out last night and tested in '08 to find that it worked perfectly. However, when I got to work today and tested it in '09, it refused to entmod my Multileader.

The extraction data still works to retrieve each leader end point, but I can't make it entmod in '09. Without this option, it's garbage to me. Thought I'd share the data anyway...

Code: [Select]
;;;( (lambda (lst n)
;;;    (vl-remove nil
;;;      (mapcar
;;;        (function
;;;          (lambda (x)
;;;            (setq n (1+ n))
;;;            (if (and (eq (car x) 10)
;;;                     (eq (cdr (nth (1- n) lst)) "LEADER_LINE{"))
;;;              (cons n (AT:DrawX (cdr x) 1))))) lst)))
;;;  (entget (car (entsel)))
;;;  -1)
;;;
;;;
;;;
;;;
;;;
;;;
;;;( (lambda (lst n)
;;;      (mapcar
;;;        (function
;;;          (lambda (x)
;;;            (setq n (1+ n))
;;;            (if (and (eq (car x) 10)
;;;                     (eq (cdr (nth (1- n) lst)) "LEADER_LINE{"))
;;;              (cons n (AT:DrawX (cdr x) 1))))) lst))
;;;  (entget (car (entsel)))
;;;  -1)


(defun c:Test (/ ss p1 p2 lst)
  (and (setq ss (ssget "_:L" '((0 . "MULTILEADER,LINE,TEXT,MTEXT,LWPOLYLINE"))))
       (setq p1 (getpoint "\nSpecify base point: "))
       (if acet-ss-drag-move
         (setq p2 (acet-ss-drag-move ss p1 "\nSpecify second point: " T))
         (setq p2 (getpoint p1 "\nSpecify second point: "))
       )
       ((lambda (i)
          (while (setq e (ssname ss (setq i (1+ i))))
            (if (eq "MULTILEADER" (cdr (assoc 0 (entget e))))
              (setq lst ((lambda (lst n)
                           (mapcar
                             (function
                               (lambda (x)
                                 (setq n (1+ n))
                                 (if (and (eq (car x) 10)
                                          (eq (cdr (nth (1- n) lst)) "LEADER_LINE{")
                                     )
                                   x
                                 )
                               )
                             )
                             lst
                           )
                         )
                          (entget e)
                          -1
                        )
              )
            )
            (vla-move (vlax-ename->vla-object e)
                      (vlax-3d-point (trans p1 1 0))
                      (vlax-3d-point (trans p2 1 0))
            )
            (and lst
                 (entmod
                   (mapcar
                     (function
                       (lambda (a b)
                         (if a
                           a
                           b
                         )
                       )
                     )
                     lst
                     (entget e)
                   )
                 )
            )
          )
        )
         -1
       )
  )
  (princ)
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

butzers09silverado

  • Guest
Re: Multileader: Move but keep original placement of leader points
« Reply #1 on: May 06, 2010, 12:21:23 PM »
I'd like the mleader to treat text of different annotative scales differently so that 20 scale mtext isn't jammed up at 40scale... but no, you move around the 40 scale and fix it and then your 20 scale is also screwed up....

did you end up getting this to work in 09'.... interested.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Multileader: Move but keep original placement of leader points
« Reply #2 on: May 06, 2010, 01:00:22 PM »
I'd like the mleader to treat text of different annotative scales differently so that 20 scale mtext isn't jammed up at 40scale... but no, you move around the 40 scale and fix it and then your 20 scale is also screwed up....
Move the text by grip editing, not the MOVE command and it won't alter alternate scales.

did you end up getting this to work in 09'.... interested.
You ask this question less than 30 minutes after I post my data. :lmao: I'll continue to play with it some, but I'm not sure what else I can do. I'd love for someone else to test it in '09 or above.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Multileader: Move but keep original placement of leader points
« Reply #3 on: May 06, 2010, 01:12:13 PM »
Does it error in '09 or maybe an entupd might help?  :|

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Multileader: Move but keep original placement of leader points
« Reply #4 on: May 06, 2010, 01:14:56 PM »
Does it error in '09 or maybe an entupd might help?  :|
First thing I tried was entupd.  :| Excellent suggestion.
No error, just doesn't update.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Multileader: Move but keep original placement of leader points
« Reply #5 on: May 06, 2010, 01:16:13 PM »
Worked here in '09.  Single mleader entity with an mtext entity attached to it.  I selected both, and moved them, but the leader still pointed to the same spot.  Which is how I think you wanted it to work.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Multileader: Move but keep original placement of leader points
« Reply #6 on: May 06, 2010, 01:20:32 PM »
Worked here in '09.  Single mleader entity with an mtext entity attached to it.  I selected both, and moved them, but the leader still pointed to the same spot.  Which is how I think you wanted it to work.
Damnit! At least this tells me there's hope.
Thanks Tim.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Multileader: Move but keep original placement of leader points
« Reply #7 on: May 06, 2010, 01:23:49 PM »
You're welcome.  I don't use mleaders, so I'm not sure of the use of them, so if you want to post a drawing that doesn't work for you, I can test, and let you know what happens.  Maybe you set them up a different way, and it a setting that is messing with the code.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Multileader: Move but keep original placement of leader points
« Reply #8 on: May 06, 2010, 01:29:28 PM »
You're welcome.  I don't use mleaders, so I'm not sure of the use of them, so if you want to post a drawing that doesn't work for you, I can test, and let you know what happens.  Maybe you set them up a different way, and it a setting that is messing with the code.
Thank Tim. I just WBlocked out one object. I opened it to check and it still doesn't work.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Multileader: Move but keep original placement of leader points
« Reply #9 on: May 06, 2010, 01:37:33 PM »
I forgot to mention; I'm running Civil 3D 2009. I tested it on other workstations here and it still doesn't work. I rarely do this kind of work. I think I'll just stick with QLeaders for that next random occasion.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Multileader: Move but keep original placement of leader points
« Reply #10 on: May 06, 2010, 01:51:00 PM »
That one didn't work for me either.  I'm on '09 Electrical.  I'll see if I can spot a difference between the two when I get time.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Multileader: Move but keep original placement of leader points
« Reply #11 on: May 06, 2010, 01:52:19 PM »
That one didn't work for me either.  I'm on '09 Electrical.  I'll see if I can spot a difference between the two when I get time.
How odd. Also, if you get a chance, shoot me an example of one you got to work.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Multileader: Move but keep original placement of leader points
« Reply #12 on: May 06, 2010, 02:16:48 PM »
I wonder if it is because the one you have is annotative?  Just an idea, as it has a point of the leader line also.

The two white ones, are the ones I drew.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Multileader: Move but keep original placement of leader points
« Reply #13 on: May 06, 2010, 02:19:41 PM »
I wonder if it is because the one you have is annotative?  Just an idea, as it has a point of the leader line also.

The two white ones, are the ones I drew.
Ah hah! That's exactly what the problem is; won't work if Annotative. Of course, this only gives me a reason, not a solution. Oh well, good thing I'd probably never use it after today anyway. Thanks Tim. :) It was a useful exercise, none-the-less.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Multileader: Move but keep original placement of leader points
« Reply #14 on: May 06, 2010, 02:26:53 PM »
That is the solution.  I change the leader line point in the annotation part, then changed the point of the leader line in the mleader section, and the point undated.

You're welcome Alan.  It's nice to actually find an answer to a problem.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Multileader: Move but keep original placement of leader points
« Reply #15 on: May 06, 2010, 02:30:18 PM »
Sadly, I can't just make my text non-annotative.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Multileader: Move but keep original placement of leader points
« Reply #16 on: May 06, 2010, 02:33:29 PM »
I didn't make anything non-annotative, I just changed the point of the annotative section also.  I guess I could write a quick code to show you if you want?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Multileader: Move but keep original placement of leader points
« Reply #17 on: May 06, 2010, 02:46:35 PM »
I didn't make anything non-annotative, I just changed the point of the annotative section also.  I guess I could write a quick code to show you if you want?
Wait, so you got it to work on the Annotative MLeader?
If you don't mind showing a little code (when you get the chance), I'd really appreciate it. I guess I'm not fully understanding what you are saying. :ugly:
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Multileader: Move but keep original placement of leader points
« Reply #18 on: May 06, 2010, 02:50:40 PM »
Here you go.  It will change the pointing point to 0,0,0 for anno leaders, and non-anno leaders, at least it did in my test drawing that I posted.  Time for lunch, so I'll answer questions after, if you have any.

Code: [Select]
(defun c:Test (/ Sel MnData data)
   
    (setq Sel (entsel "\n Select mleader to change it's arrow point to 0,0: "))
    (setq MnData (entget (car Sel)))
    (if (setq data (member '(102 . "{ACAD_XDICTIONARY") MnData))
        (progn
            (print "dict")
            (setq data (entget (cdr (assoc 360 data))))
            (if (setq data (member '(3 . "AcDbContextDataManager") data))
                (progn
                    (print "man")
                    (setq data (entget (cdr (assoc 360 data))))
                    (if (setq data (member '(3 . "ACDB_ANNOTATIONSCALES") data))
                        (progn
                            (print "scales")
                            (foreach i (entget (cdr (assoc 350 data)))
                                (if (equal (car i) 350)
                                    (progn
                                        (setq data (entget (cdr i)))
                                        (entmod (subst '(10 0. 0. 0.) (assoc 10 (member '(304 . "LEADER_LINE{") data)) data))
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )
    (entmod (subst '(10 0. 0. 0.) (assoc 10 (member '(304 . "LEADER_LINE{") MnData)) MnData))
    (princ)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Multileader: Move but keep original placement of leader points
« Reply #19 on: May 06, 2010, 05:46:16 PM »
Did you get a chance to test it Alan?  Did it work for you if so?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Multileader: Move but keep original placement of leader points
« Reply #20 on: May 06, 2010, 06:21:07 PM »
Did you get a chance to test it Alan?  Did it work for you if so?
Sorry, forgot to respond.  :oops:

Yes, it worked perfectly. I couldn't work on the code any, but I'll be playing with it tonight. Yours will only reset the first leader, but it gives me the information I needed. Unless I can't get to it tonight, I'll post something later. Thanks so much for looking at this Tim. Your code was very educational. :)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Multileader: Move but keep original placement of leader points
« Reply #21 on: May 06, 2010, 06:27:37 PM »
Good to hear Alan.  I'm sure you will be able to get it to work.

You're welcome.  Glad I could help.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Multileader: Move but keep original placement of leader points
« Reply #22 on: May 06, 2010, 06:39:24 PM »
Thanks and thanks. :)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox