circle mleaders rebuild

circle mleaders rebuild

Anonymous
Not applicable
1,220 Views
12 Replies
Message 1 of 13

circle mleaders rebuild

Anonymous
Not applicable

I am trying to rebuild some exploded mleaders and I have it mostly done but I would like to be able to pick the text from the broken circle mleader and use it for the text for the new mleader without having the edit attribute window come up.  Also sometime the new leader doesn't get placed in the right place.  Can someone help me out with this.

thanx

 

(defun c:c22 (/ lead)

(princ "Select exploded circle multileader peices to delete.")

(setvar 'osmode 247)
(setq lead (ssget))

(setq pt1 (getpoint "\nSpecify leader arrowhead location: "))
(setq pt2 (getpoint "\nSpecify center of bubble location: "))

(command "_.erase" lead "")

(setvar 'osmode 0)
(command "_.mleader" pt1 pt2 "")
(setvar 'osmode 247)
  (princ)
)

 

0 Likes
Accepted solutions (1)
1,221 Views
12 Replies
Replies (12)
Message 2 of 13

ВeekeeCZ
Consultant
Consultant

Try this mod:

(defun c:c22 (/ ss pt1 pt2 txt i def)
  
  (princ "Select exploded circle multileader peices to delete.")
  (if (setq ss (ssget "_:L"))
    (progn
    (repeat (setq i (sslength ss))
      (setq def (entget (ssname ss (setq i (1- i)))))
      (cond ((= "LINE" (cdr (assoc 0 def)))
	     (setq pt1 (cdr (assoc 10 def))))
	    ((= "CIRCLE" (cdr (assoc 0 def)))
	     (setq pt2 (cdr (assoc 10 def))))
	    ((= "TEXT" (cdr (assoc 0 def)))
	     (setq txt (cdr (assoc 1 def))))))
    (if (and pt1 pt2 txt) (command "_.mleader" "_non" pt1 "_non" pt2 txt ""))
    (command "_.ERASE" ss "")))
  (princ)
  )
Message 3 of 13

Anonymous
Not applicable

Hi , thanks for the help but that doesn't seem to work.  It doesn't ask me anymore where I want the new mleader to be and it still opens the edit attribute box.  If possible I would like to pick the text that I want in the new circle mleader from the old exploded one then pick what I want to delete (the old exploded mleader components) then pick where the new mleader will go then it will automatically insert the text that I picked from the old exploded cirlce mleader and use it for the new circle mleader without opening the edit attribute box.  is this possible?

 

thanks again

0 Likes
Message 4 of 13

ВeekeeCZ
Consultant
Consultant

You have to have the ATTDIA and ATTREQ sysvars set correctly.

Or set it in code, if you want. 

0 Likes
Message 5 of 13

dlanorh
Advisor
Advisor

Try this

 

(defun c:c22 (/ osm rubbish pt1 pt2 txt)

  (cond ( (/= (getvar 'osmode) 5) (setq osm (getvar 'osmode)) (setvar 'osmode 5)));;Why 247?

  (setq txt (vlax-get-property (vlax-ename->vla-object (car (entsel "\nSelect Old Text : "))) 'textstring))

  (prompt "Select exploded circle multileader pieces to delete.")
  (setq rubbish (ssget))

  (setq pt1 (getpoint "\nSpecify leader arrowhead location: ")
        pt2 (getpoint "\nSpecify center of bubble location: ")
  );end_setq
  
  (command "_.erase" rubbish "")
  (setvar 'osmode 0)
  (command "_.mleader" pt1 pt2 "" txt);;stick the text on the end of the mleader command to bypass the edit window
  (if osm (setvar 'osmode osm))
  (princ)
)

I am not one of the robots you're looking for

0 Likes
Message 6 of 13

ВeekeeCZ
Consultant
Consultant

@dlanorh wrote:

Try this

 

...
  (setq rubbish (ssget))

...


 

I see your different approach. What I consider as valuable selection set to be recycled, you have as 'rubbish'. Such a waste! 

Message 7 of 13

Luís Augusto
Advocate
Advocate

Perfect.
I would never have thought of that.
For correct operation we have to change the system variable ATTREQ = 1 and ATTDIA = 0.

Thank you for sharing your knowledge with us.

0 Likes
Message 8 of 13

dlanorh
Advisor
Advisor

Recycled items need to be sorted and put into seperate bins. Robot tongue I just wanted to finish before the windows update "nag" pop-up appeared again.Robot Mad

I am not one of the robots you're looking for

0 Likes
Message 9 of 13

Anonymous
Not applicable

 I see what you mean and totally agree about the wasted geometry.  but sometime I might want to change the positon of the mleader.  that being said I think I will stay with your recommendation.  So I have set the ATTDIA and ATTREQ to 0 and the attribute remains empty at the end.  could I be doing something wrong?

 

thanx

0 Likes
Message 10 of 13

ВeekeeCZ
Consultant
Consultant
Accepted solution

Yes, that's exactly why I didn't tell you the appropriate values for those sysvars. You should hop on HELP to read and think about it. Now you have it wrong.

 

Anyway. Here is the code with an example how to change sysvar and get them back even in case of error. The second code is for manual redraw, you can select text to get the content from, but don't have to and type that manually.

 

(defun c:c22 (/ *error* atq atd ss pt1 pt2 txt i def)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if atq (setvar 'ATTREQ atq))
    (if atd (setvar 'ATTDIA atd))
    (princ))
  
  ; ----------------------------------------------------------------------------------------------
  
  (princ "Select exploded circle multileader pieces to be redrawed")
  (if (setq ss (ssget "_:L"))
    (progn
      (setq atq (getvar 'ATTREQ)
            atd (getvar 'ATTDIA))
      (setvar 'ATTREQ 1)
      (setvar 'ATTDIA 0)
      
      (repeat (setq i (sslength ss))
        (setq def (entget (ssname ss (setq i (1- i)))))
        (cond ((= "LINE" (cdr (assoc 0 def)))
               (setq pt1 (cdr (assoc 10 def))))
              ((= "CIRCLE" (cdr (assoc 0 def)))
               (setq pt2 (cdr (assoc 10 def))))
              ((= "TEXT" (cdr (assoc 0 def)))
               (setq txt (cdr (assoc 1 def))))))
      (if (and pt1 pt2 txt) (command "_.mleader" "_non" pt1 "_non" pt2 txt ""))
      (command "_.ERASE" ss "")))
  (*error* "end")
  )





(defun c:c22m (/ ss pt1 pt2 txt i def)
  
  (princ "Select exploded circle multileader pieces to delete.")
  (if (setq ss (ssget "_:L"))
    (progn
      (setq st (ssget "_P" '((0 . "TEXT"))))
      (command "_.MLEADER" pause pause)
      (if st
        (command (cdr (assoc 1 (entget (ssname st 0)))) "")
        (command pause))
      (command "_.ERASE" ss "")))
  (princ)
  )
0 Likes
Message 11 of 13

Anonymous
Not applicable

ok...I get it now.  I have set ATTDIA to 0 and ATTREQ to 1 and it is working.  Is there any reason I cant add this  (setvar "attdia" 0) & (setvar "attreq" 1) then undo upon existing.  

 

Thanks for your time and patient

0 Likes
Message 12 of 13

Anonymous
Not applicable

thanks to everybody for all the help especially

0 Likes
Message 13 of 13

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

ok...I get it now.  I have set ATTDIA to 0 and ATTREQ to 1 and it is working.  Is there any reason I cant add this  (setvar "attdia" 0) & (setvar "attreq" 1) then undo upon existing.  

 

Thanks for your time and patient


 

Something like this? Sure you can... but run the routine, and then hit ECS because you realized that you actually wanted a different command. Then check the variables if they are back.

 

(defun c:c22-test (/ atq atd ss pt1 pt2 txt i def)
  
  (setq atq (getvar 'ATTREQ)
        atd (getvar 'ATTDIA))
  (setvar 'ATTREQ 1)
  (setvar 'ATTDIA 0)
  
  (princ "Select exploded circle multileader pieces to be redrawed")
  (if (setq ss (ssget "_:L"))
    (progn
      (repeat (setq i (sslength ss))
        (setq def (entget (ssname ss (setq i (1- i)))))
        (cond ((= "LINE" (cdr (assoc 0 def)))
               (setq pt1 (cdr (assoc 10 def))))
              ((= "CIRCLE" (cdr (assoc 0 def)))
               (setq pt2 (cdr (assoc 10 def))))
              ((= "TEXT" (cdr (assoc 0 def)))
               (setq txt (cdr (assoc 1 def))))))
      (if (and pt1 pt2 txt) (command "_.mleader" "_non" pt1 "_non" pt2 txt ""))
      (command "_.ERASE" ss "")))
  
  (setvar 'ATTREQ atq)
  (setvar 'ATTDIA atd)
  (princ)
  )

So you still need the *error* function to get them back in case of any error happens. So you can either have the back-setting placed at both places - at the end of routine AND at the error function - or you can simply call the *error* function even if no error occured. Yes, someone can say it's misusing of *error*, the other just way that works reliably.

 

 

 

 

0 Likes