Remove the line from the multileader

Remove the line from the multileader

angelinabrown0123
Advocate Advocate
1,224 Views
7 Replies
Message 1 of 8

Remove the line from the multileader

angelinabrown0123
Advocate
Advocate

I am looking for Lisp to remove the line from the Multileader, I tried to do a lot of searching on Google but I have not found any Lisp.
I have two types of mleaders, so I need two types of Lisp or you can add two types of options to Lisp.
First of all, I have to remove the first and the third line from the mleader.
And in the second mleader I have to delete all the lines except the first line.
If you help me to give lisp, i will be grateful to you

0 Likes
Accepted solutions (2)
1,225 Views
7 Replies
Replies (7)
Message 2 of 8

hosneyalaa
Advisor
Advisor

try

;; hosneyalaa 03 / 04 / 2021 
(defun c:tstLTILEADER (/ cnt sset1 obj)
  (vl-load-com)
    (if (setq sset1 (ssget '((0 . "MULTILEADER"))) )  ;(0 . "MULTILEADER")   
    (progn

      
      (initget 0 "type1 type2")
 (setq chosen (cond ((getkword "\nSpecify demo number [type1/type2] <type1>: "))
               ("type1")
         )
 )

         (setq cnt -1)
    
      (while (< (setq cnt (1+ cnt)) (sslength sset1))
        (setq obj     (vlax-ename->vla-object (ssname sset1 cnt))
              ObjText (vlax-get obj 'textstring)
              )
               
              (if (= chosen "type1")
                (vlax-put obj
		  'textstring
		  (car (str2list ObjText  "\\P"))
	)
              (vlax-put obj
		  'textstring
		  (cadr (str2list ObjText  "\\P"))
	)
                )
               
         
      )   ; end while

      (command "regen")

    )     ; end progn
  )       ; end if

  (princ)
)


(defun Str2List	(str pat / i j n lst)
  (cond
    ((/= (type str) (type pat) 'STR))
    ((= str pat) '(""))
    (T
     (setq i 0
	   n (strlen pat)
     )
     (while (setq j (vl-string-search pat str i))
       (setq lst (cons (substr str (1+ i) (- j i)) lst)
	     i	 (+ j n)
       )
     )
     (reverse (cons (substr str (1+ i)) lst))
    )
  )
)

 

111111.gif

0 Likes
Message 3 of 8

angelinabrown0123
Advocate
Advocate

Thanks for the code, I tried testing your code on another drawing but it is not working on some mleader.

Please see the attached drawing.

0 Likes
Message 4 of 8

hosneyalaa
Advisor
Advisor
Accepted solution
;; hosneyalaa 03 / 04 / 2021 
(defun c:tstLTILEADER01 (/ cnt sset1 obj)
  (vl-load-com)
    (if (setq sset1 (ssget '((0 . "MULTILEADER"))) )  ;(0 . "MULTILEADER")   
    (progn

      
      (initget 0 "type1 type2")
 (setq chosen (cond ((getkword "\nSpecify demo number [type1/type2] <type1>: "))
               ("type1")
         )
 )

         (setq cnt -1)
    
      (while (< (setq cnt (1+ cnt)) (sslength sset1))
        (setq obj     (vlax-ename->vla-object (ssname sset1 cnt))
              ObjText (vlax-get obj 'textstring)
              )
               
              (if (= chosen "type1")
                (vlax-put obj
		  'textstring
		  (car (str2list ObjText  "\n"))
	)
              (vlax-put obj
		  'textstring
		  (cadr (str2list ObjText  "\n"))
	)
                )
               
         
      )   ; end while

      (command "regen")

    )     ; end progn
  )       ; end if

  (princ)
)

;;;(setq str ObjText  pat "\n")
(defun Str2List	(str pat / i j n lst)
  (cond
    ((/= (type str) (type pat) 'STR))
    ((= str pat) '(""))
    (T
     (setq i 0
	   n (strlen pat)
     )
     (while (setq j (vl-string-search pat str i))
       (setq lst (cons (substr str (1+ i) (- j i)) lst)
	     i	 (+ j n)
       )
     )
     (reverse (cons (substr str (1+ i)) lst))
    )
  )
)
Message 5 of 8

angelinabrown0123
Advocate
Advocate

Now it is working properly, however I have to use both lisp because the new code is not removing the old mleader.

Still work, thank you very much 😀

 

Message 6 of 8

hosneyalaa
Advisor
Advisor

Yeah

I have an idea to try

Just ready

Attach it to you

0 Likes
Message 7 of 8

hosneyalaa
Advisor
Advisor
Accepted solution

TRY THIS IS 

 

;;                            ;;
;; HOSNEYALAA 04 - 04 - 2021 
;;                             ;;
;; Roy_043
(defun KGA_Sys_Entlast ( / enm tmp)
 (if (setq enm (entlast))
   (while (setq tmp (entnext enm))
     (setq enm tmp)
   )
 )
 enm
)
(defun AeccDbPointInsPointGet (enm / enmLast obj ptLst tmp)
 (setq enmLast (KGA_Sys_Entlast))
 (setvar 'cmdecho 0)
 (command "_.explode" enm)
 (while (setq tmp (entnext enmLast))
   (if (= "AcDbText" (vla-get-objectname (setq obj (vlax-ename->vla-object tmp))))
     (setq ptLst (vl-list* (vlax-get obj 'textstring) ptLst))
   )
   (setq enmLast tmp)
 )
  
 (command "_.u")
 (setvar 'cmdecho 1)
 (if (< 1 (length ptLst)) (reverse ptLst))
)


(defun c:tstLMLEADER (/ cnt sset1 obj)
  (vl-load-com)
    (if (setq sset1 (ssget '((0 . "MULTILEADER"))) )  ;(0 . "MULTILEADER")   
    (progn

      
      (initget 0 "type1 type2")
 (setq chosen (cond ((getkword "\nSpecify demo number [type1/type2] <type1>: "))
               ("type1")
         )
 )

         (setq cnt -1)
    
      (while (< (setq cnt (1+ cnt)) (sslength sset1))
        (setq obj     (vlax-ename->vla-object  (SETQ ENTMT (ssname sset1 cnt)))
              ObjText (vlax-get obj 'textstring)
              )
        
        (setq entMTXT (entmakex (list '(0 . "MTEXT")
                            '(100 . "AcDbEntity")
                            '(8 . "Text List")
                            (cons 10 (CDR(ASSOC 10(ENTGET ENTMT))))
                            '(100 . "AcDbMText")
                             '(40 . 0.1)
                              (cons 1 ObjText)
                            '(41 . 0)
                            '(210 0. 0. 1.)
                            ) ;_ end of list
                      ) ;_ end of entmakex
        
        )
        
               
              (if (= chosen "type1")
                (vlax-put obj
		  'textstring
		  (car (AeccDbPointInsPointGet entMTXT))
	)
              (vlax-put obj
		  'textstring
		  (cadr (AeccDbPointInsPointGet entMTXT))
	)
                )
               
         (entdel (vlax-vla-object->ename (vlax-ename->vla-object entMTXT)))
      )   ; end while

      (command "regen")

    )     ; end progn
  )       ; end if

  (princ)
)

 

 

222.gif

Message 8 of 8

angelinabrown0123
Advocate
Advocate

At this time it is working on all types of mleaders, thanks for giving your valuable time, I will always be grateful to you. 😊