Jump to content

Recommended Posts

Posted

I have this lisp that I modified from on that LeeMac wrote for me to update the text on dimensions. I was looking to make it work for leaders but I haven't got it working.

 

Can an option be added to set the width of the multiline text for the leader as well?

 

leader_update : dialog { key = "dctitle";
 spacer;  
 : list_box { label = "Notes:"; key = "lst";
              alignment = centered; fixed_height = true;
              fixed_width = true; width = 50; height = 20; }
 spacer;
 ok_cancel;
}

 

 

 

(defun c:leader_update ( / *error* _read )
 ;; © Lee Mac 2010
 

 (setq dcfilename  "leader_update.dcl"   ;; DCL Filename

       Strfilename "CCC_NNRDO_leader_update.txt"   ;; Data Filename
  )


 (defun *error* ( msg )
   (and dcTag (unload_dialog dcTag))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))


 (defun _read ( file / ofile lst nl )

   (cond (  (setq ofile (open file "r"))
        
            (while (setq nl (read-line ofile))
              (setq lst (cons nl lst)))

            (close ofile)))
 
   (reverse lst)
 )


 (cond (  (not (setq Strfilename (findfile Strfilename)))

          (princ "\n** Data File not Found **"))

       (  (not (setq StrLst (_read Strfilename)))

          (princ "\n** Data File Empty **"))

       (  (not (setq ss (ssget "_:L" '((0 . "*LEADER"))))))

       (  (<= (setq dcTag (load_dialog dcfilename)) 0)

          (princ "\n** Dialog Definition Not Found **"))

       (  (not (new_dialog "leader_update" dcTag))

          (princ "\n** Dialog Could not be Loaded **"))

       (t
          (start_list "lst")
          (mapcar (function add_list) StrLst)
          (end_list)

          (set_tile "dcltitle" "Dimension Notes")

          (setq ptr (set_tile "lst" "0"))
        
          (action_tile  "lst" "(setq ptr $value)")

          (setq dcFlag (start_dialog) dcTag (unload_dialog dcTag) Str (nth (atoi ptr) StrLst))

          (if (= 1 dcFlag)
            (
              (lambda ( i )
                (while (setq ent (ssname ss (setq i (1+ i))))
                  (entupd                     
                    (cdr
                      (assoc -1
                        (entmod
                          (subst (cons 1 (strcat str)) (assoc 1 (entget ent)) (entget ent))
                        )
                      )
                    )
                  )
                )
              )
              -1
            )

            (princ "\n*Cancel*")
          )
        )
 )
 
 (princ)
)

 

Thanks.

CCC_NNRDO_Leader_update.txt

leader_update.dcl

Posted

I found this lisp below at the following location:

http://lispcad.com/2012/03/add-leader-to-text-%E2%80%93-make-multileader/

 

Can this be modified to create an mleader based on a style when a text string is selected from the dcl window?

 

(defun c:mt2ml ( / oobj nobj nstrg)
 (vl-load-com)
 (setq oobj (vlax-ename->vla-object (car (nentsel "nSelect source text: "))))
 (if (= (vlax-get-property oobj 'ObjectName) "AcDbMText")
   (setq nstrg (vlax-get-property oobj 'TextString))
   (exit)
   )
 (command "_MLEADER")
 (while (= 1 (logand (getvar "CMDACTIVE") 1)) (command PAUSE))
 (setq nobj (vlax-ename->vla-object (entlast)))
 (if (= (vlax-get-property nobj 'ObjectName) "AcDbMLeader")
   (vlax-put-property nobj 'TextString nstrg)
   (exit)
   )
 (entdel (vlax-vla-object->ename oobj))
 (princ)
)

Posted

I have taken a different approach to this now. I have created blocks with leaders and the specific text I want but how do I get this lisp that LeeMac helped me with to explode the blocks on input? I have researched that I need to put star before the name but how do I do this when I can select multiple blocks?

 

insert_lining_leaders : dialog {                                   //*dialog name
        label = "Lining Leaders";           //*give it a label
: row {                                    //*define row
             : paragraph {                          //*define paragraph
            }                                      //*end paragraph
        }                                          //*end row
        : row {                                    //*define row
          : boxed_column {                         //*define boxex_column
            label = "Choose a Note:";               //*give it a label 
            : list_box {                         //*define popup_list
              key = "S1";                          //*give it a name
              width=100;                        //*edit_width
              fixed_width=true;               //*fixed width
 height=20;		//*Height
 fixed_height=true;		//*fixed height
              alignment = right;                   //*alignment
 multiple_select=true;
            }                                      //*end popup_list
            : spacer {                             //*define spacer
              height = 0;                          //*height
            }                                      //*end spacer
          }                                        //*end boxed_column
        }                                          //*end row
        : row {                                    //*define row
          : column {                               //*define column
            ok_cancel ;                            //*predifined OK/Cancel
            : paragraph {                          //*define paragraph
               : text_part {                        //*define more text
                label = "CCC NNRDO     v1.0.24.07.2009";           //*some more text
              }                                    //*end text
            }                                      //*end paragraph
          }                                        //*end column
        }                                          //*end row
      }                                            //*end dialog

 

 

 

 

(defun c:insert_lining_leaders (/ *error* DCHANDLE INPT OV PT RTN S1_LIST VL SUSM)

 (setq SUSM (getvar "osmode"))

 (defun *error* (msg)
   (and dcHandle (unload_dialog dcHandle))
   (and ov (mapcar 'setvar vl ov))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))

 (setq S1_list
  '("*** Smybols ***" 											;0
    "M115 Yield Triangle" 											;1

   )
 )

 (setq vl '("CMDECHO" "CLAYER" "OSMODE") ov (mapcar 'getvar vl))
 (setvar "attdia" 1)
 (cond (  (<= (setq dcHandle (load_dialog "insert_lining_leaders.dcl")) 0)

          (princ "\n** Dialog file not Found **"))

       (  (not (new_dialog "insert_lining_leaders" dcHandle))

          (princ "\n** Dialog Definition Not Found **"))

       (t

          (start_list "S1")
          (mapcar (function add_list) S1_list)
          (end_list)

          (set_tile "S1" (setq *def* (cond (*def*) ("1"))))

          (action_tile "S1"     "(setq *def* $value)")
        
          (action_tile "accept" "(cond ((member (atoi *def*) '(0)) (alert \"Invalid Note\"))
                                       ((done_dialog 1)))")
        
          (action_tile "cancel" "(done_dialog 0)")

          (setq rtn (start_dialog))

          (setq dcHandle (unload_dialog dcHandle))

          (if (= 1 rtn)
            (progn

              (or (tblsearch "LAYER" "CCC_SHEET_LAYOUT_Notes")
                  (entmake (list (cons 0 "LAYER")
                                 (cons 100 "AcDbSymbolTableRecord")
                                 (cons 100 "AcDbLayerTableRecord")
                                 (cons 2 "CCC_SHEET_LAYOUT_Notes")
                                 (cons 70 0)
                                 (cons 62 7)
                                 (cons 370 30))))

              (mapcar 'setvar vl '(0 "CCC_SHEET_LAYOUT_Notes" 0))

              (foreach block (mapcar
                               (function
                                 (lambda (x) (nth x S1_list)))

                               (read (strcat "(" *def* ")")))
                (setvar "osmode" 1)
                (if (setq pt (setq INPT (getpoint "\nPick Insertion Point: ")))

                  (command "_.-insert" block INPT "1" "1" "0"))))
	 	


            (princ "\n*Cancel*"))))
(setvar "osmode" SUSM)
(setvar "attdia" 0)
 (mapcar 'setvar vl ov)

(princ))

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...