Jump to content

Leaders with autonumbering


Chilidawg

Recommended Posts

a have a project where I have to add a couple hundred sample locations using a leader from each point to consecutive 7 digit code/ serial numbers.

 

 

I'm looking for a lisp routine that will do this.

 

 

I have a routine that creates sequential numbers, and a separate one that creates a leader to existing text, but that is a two step process and has some other minor issues as well. (it allways left justifies the text, creating odd looking leaders for those that are off to the left. I often have to go back and readjust the position of the text, an extra step)

 

 

I'm looking for a single routine that will let me pick the arrowhead location, then the landing and automatically populate the text with the sequential number.

Link to comment
Share on other sites

no, it wont. bubble blocks don't work well with 7 digit numbers.

 

 

What I would like is something like his incremental numbering lisp, but that inserts a multi leader instead of an mtext object or a block.

 

 

Oh, well, I don't have time to learn to write one for myself.

Link to comment
Share on other sites

no, it wont. bubble blocks don't work well with 7 digit numbers.

 

Who said you had to use 'bubble blocks' with the program? The program will function with any MLeader with attributed block content.

Link to comment
Share on other sites

no, it wont. bubble blocks don't work well with 7 digit numbers.

 

 

What I would like is something like his incremental numbering lisp, but that inserts a multi leader instead of an mtext object or a block.

 

 

Oh, well, I don't have time to learn to write one for myself.

 

Lee-Mac just happened to use a Circle Block in his example. You can have a block with a "sausage" shape to contain your 7 digit number Attribute. The page explains how to configure the lisp to your liking.

Link to comment
Share on other sites

The problem with that routine is that it automatically renumbers all the blocks if you add or delete one.

Link to comment
Share on other sites

The problem with that routine is that it automatically renumbers all the blocks if you add or delete one.

 

Some people may view that as being a positive feature (i.e. - time saver).

Link to comment
Share on other sites

For me, it's not. these are specific sample numbers tied to specific locations. I tried it, and if you turn off the autolabel, you can delete or change a specific number without affecting the rest.

 

 

However, there is another problem that I cant seem to work around. In order to make that program work, you have to have a block, "MYBLOCK" that contains an attribute tag, "MYTAG" and set up your multileader style so that it uses that block for the content, instead of mtext. so far, so good.

 

 

the problem is the landing. because its a block and not mtext, the landing does not behave the way I want it to.

 

 

if you have to tweak the location of the landing/text, the landing flips justification and if you set the landing to zero, the leader line crosses over the text. . .

 

 

it's just not working the way I would like it to.

 

 

thanks all, but I will stick to my old, multi step method for now.

Link to comment
Share on other sites

Hi Chilidawg,

 

See if this is what you are after.

Click "off" the leader for input.

Must esc to exit.

 

Number variable set as global, so it will pick up where you left off.

 

;|SEQUENTIALLY NUMBER AN MLEADER
P. DuMONT 06/19/2017 |;



(defun c:MLI ( / *error* cmde ldr doc ent ent_obj new_num )
 (defun *error* (msg)
   (if	(and msg
     (not (wcmatch (strcase msg t) "*break*,*cancel*,*exit*"))
) ;_ end of and
     (princ (strcat "\nError: " msg))
   )
   (if	cmde
     (setvar 'cmdecho cmde)
   )
   (if	ldr
     (setvar 'cmleaderstyle ldr)
   )
   (if	doc
     (vla-endundomark doc)
   )
   (princ)
 ) ;_ end of defun

 (setvar 'cmdecho 0)
 (setq ldr (getvar 'cmleaderstyle))
 (if
   (and (setq dic (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE"))
 (setq dat (dictsearch (setq dic (cdr (assoc -1 dic))) "NOTES")) ;check your Leader style here
   ) ;_ end of and
       (setvar 'cmleaderstyle "NOTES") ;set your Leader style here
 ) ;_ end of if
 (setq doc (vla-get-activedocument (vlax-get-acad-object)))
 (vla-startundomark doc)
 (inputnum)
 (while
   (initcommandversion)
    (command "MLEADER")
    (while (= 1 (logand 1 (getvar 'cmdactive)))
      (command pause)
    ) ;_ end of while
    (setq ent (entlast)
   ent_obj  (vlax-ename->vla-object ent)
   new_num  (itoa *!num!*)
   *!num!*  (1+ *!num!*))
    (vla-put-TextString ent_obj new_num)
    
 ) ;_ end of while
 (vla-endundomark doc)
 (setvar 'cmleaderstyle ldr)
 (setvar 'cmdecho cmde)
) ;_ end of defun


(defun inputnum	()
 (setq	*!num!*
 (cond
   ((getint
      (strcat "\nStarting number? <"
	      (itoa (setq *!num!* (cond	(*!num!*)
					(1)
				  ) ;_ end of cond
		    ) ;_ end of setq
	      ) ;_ end of itoa
	      ">: "
      ) ;_ end of strcat
    ) ;_ end of getint
   )
   (*!num!*)
 ) ;_ end of cond
 ) ; setq
) ;_ end of defun

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Thanks. that works with just one problem.

 

 

My sample serial numbers are all seven digit numbers. your code will only allow me to enter 16 bit integers from +32767 to -32678.

Link to comment
Share on other sites

Change the 'inputnum' function to:

(defun inputnum    ()
 (setq    *!num!*
    (fix
        (cond
          ((getreal
             (strcat "\nStarting number? <"
                 (itoa (setq *!num!* (cond    (*!num!*)
                           (1)
                         ) ;_ end of cond
                   ) ;_ end of setq
                 ) ;_ end of itoa
                 ">: "
             ) ;_ end of strcat
           ) ;_ end of getint
          )
          (*!num!*)
        ) ;_ end of cond
    )
 ) ; setq
) ;_ end of defun

Link to comment
Share on other sites

I use this when entering my datapoints. Maybe it could lead you in the right direction.

 

(DEFUN C:CADDER()
(defun *error* (msg)
   (if oldlayr (setvar "clayer" oldlayr))
   (if oldos (setvar "osmode" oldos))
   (if oldortho (setvar "orthomode" oldortho))
   (if msg (prompt msg))
   (princ)
   )
  (if (null(tblsearch "LAYER" "LOCAL-DATA"))
     (command "._-layer" "N" "LOCAL-DATA" "C" "142" "LOCAL-DATA" "")
  )
 (setq oldortho (getvar "orthomode")) 
 (setq oldos (getvar "osmode"))
 (setq oldlayr (getvar "clayer")) 
 (command "._-layer" "s" "LOCAL-DATA" "")
 (setvar "osmode" 16383)
;(WHILE
 (initget 1)  (setq p1a (getpoint "\nSelect datapoint location on pipe: "))
 (setvar "osmode" 0)
 (setvar "orthomode" 0)
 (initget 33) (setq p2a (getpoint p1a "\nSelect datapoint label location: "))
 (setq DATA (getreal "\nEnter STARTING datapoint number (1.00-999.99): "))
 (if (not (equal p1a p2a))
 (progn
  (if (< (car p1a) (car p2a))
   (progn (setq side1 "ML") (setq dir1 0.0))
   (progn (setq side1 "MR") (setq dir1 180.0))
  )
  (setq p3a (polar p2a (dtr dir1) (getvar "userr1")))
  (setq p4a (polar p3a (dtr dir1) (getvar "userr1")))
 )
 (progn (setq p4a p2a) (setq side1 "ML")
 )
)
  (command "._line" p1a p2a p3a "")
  (setq a1 (angle p2a p1a))
  (command "._solid" p1a (polar p1a (- a1 85) (getvar "userr1"))
                        (polar p1a (+ a1 85) (getvar "userr1")) "" "")
 (command "._text" side1 p4a (getvar "userr1") 0 (strcat "#" (trim (rtos DATA 2 0)) "-PIPE"))
 (setq DATA (+ DATA 1))
 (command "._-layer" "s" oldlayr "")
 (setvar "OSMODE" OLDOS)
 (setvar "ORTHOMODE" OLDORTHO)

(*ERROR* nil)
(PRINC))

Link to comment
Share on other sites

Here is the same routine but with while looping so once you enter your first number it allows you to continue selecting datapoints whilst adding 1 to the previous entry.

 

(DEFUN C:CADDER3( / *ERROR* oldlayr oldos oldortho P1A P2A DATA side1 dir1 P3A P4A A1)
(defun *error* (msg)
   (if oldlayr (setvar "clayer" oldlayr))
   (if oldos (setvar "osmode" oldos))
   (if oldortho (setvar "orthomode" oldortho))
   (if msg (prompt msg))
   (princ)
   )
  (if (null(tblsearch "LAYER" "LOCAL-DATA"))
     (command "._-layer" "N" "LOCAL-DATA" "C" "142" "LOCAL-DATA" "")
  )
(setvar "osmode" 16383)
(WHILE
 (setq oldortho (getvar "orthomode")) 
 (setq oldos (getvar "osmode"))
 (setq oldlayr (getvar "clayer")) 
 (command "._-layer" "s" "LOCAL-DATA" "")
 (initget 1)  (setq p1a (getpoint "\nSelect datapoint location on pipe: "))
 (setvar "osmode" 0)
 (setvar "orthomode" 0)
 (initget 33) (setq p2a (getpoint p1a "\nSelect datapoint label location: "))
 (if (= DATA nil)
  (setq DATA (getreal "\nEnter STARTING datapoint number (1.00-999.99): "))
 )
(if (not (equal p1a p2a))
 (progn
  (if (< (car p1a) (car p2a))
   (progn (setq side1 "ML") (setq dir1 0.0))
   (progn (setq side1 "MR") (setq dir1 180.0))
  )
  (setq p3a (polar p2a (dtr dir1) (getvar "userr1")))
  (setq p4a (polar p3a (dtr dir1) (getvar "userr1")))
 )
 (progn (setq p4a p2a) (setq side1 "ML")
 )
)
  (command "._line" p1a p2a p3a "")
  (setq a1 (angle p2a p1a))
  (command "._solid" p1a (polar p1a (- a1 85) (getvar "userr1"))
                        (polar p1a (+ a1 85) (getvar "userr1")) "" "")
 (command "._text" side1 p4a (getvar "userr1") 0 (rtos DATA 2 0))
 (setq DATA (+ DATA 1))
 (command "._-layer" "s" oldlayr "")
 (setvar "OSMODE" OLDOS)
 (setvar "ORTHOMODE" OLDORTHO)
)
(*ERROR* nil)
(PRINC))

Link to comment
Share on other sites

  • 3 years later...
On 11/26/2020 at 12:38 PM, markun said:

I still have problem if I change mleader type from mtext to block autonumbering not work. Please help?

 

 

I posted an incremental mleader one several years ago. It's up to you to create the mleader style.

 

Link to comment
Share on other sites

  • 1 year later...
On 07/06/2017 at 20:39, guitarguy1685 said:

http://www.lee-mac.com/autolabelattributes.html

 

I think this is what you're looking for.

I can't apply this program i create a block  named "my block" and make auto label on  then i create multi leader from annotate panel but it doesn't auto numbering always asking me to enter the number and am trying to copy it but it doesn't work  

Link to comment
Share on other sites

On 10/4/2022 at 5:30 AM, Ayman Edris said:

I can't apply this program i create a block  named "my block" and make auto label on  then i create multi leader from annotate panel but it doesn't auto numbering always asking me to enter the number and am trying to copy it but it doesn't work  

Set the system variables ATTREQ to 1 and ATTDIA to 0.  Let me know if that fixes it.  

Link to comment
Share on other sites

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...