Author Topic: Add mleader w/ tag counter  (Read 4256 times)

0 Members and 1 Guest are viewing this topic.

ArgV

  • Guest
Add mleader w/ tag counter
« on: September 06, 2009, 06:05:18 PM »
Hello.

I'm trying to make something that will just allow you to keep adding mleaders (the kind with the circle and attribute).

Basically I just want it to start at number 1 and keep going until the user stops or whatever, I wrote this little bit (doesn't work) for an example. Not sure if I'm even doing this right, but can't find anything on this subject directly.

Code: [Select]
(defun addCircleLeader (/ layout point1 point2 points cntr array leader)

  (setq layout (vla-get-paperspace (vla-get-activedocument (vlax-get-acad-object))))


(repeat (getint "\nNumber of times to repeat:")
 
  (setq
point1 (getpoint "\nSelect arrow point")
point2 (getpoint "\nSelect landing point")
points (list (car point1)(cadr point1)(caddr point1)(car point2)(cadr point2)(caddr point2))
cntr 1)

(setq array (vlax-make-variant
      (vlax-safearray-fill
(vlax-make-safearray vlax-vbdouble
  (cons 0 (1- (length points)))) points)))

(setq leader (vla-addmleader layout array cntr))
(vla-put-contentblockname leader "_TagCircle - Imperial")
(vla-setblockattributevalue leader (vla-get-objectid leader) (rtos cntr)) ;<-- doesn't like this..
  (setq cntr (1+ cntr))
  )
)


thanks in advance.

-ArgV

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Add mleader w/ tag counter
« Reply #1 on: September 06, 2009, 07:36:55 PM »
but can't find anything on this subject directly.

That's because you needed to search on  >BUBBLE Click Here<


PS Haven't seen it done with Mleaders yet. :)
« Last Edit: September 06, 2009, 07:42:21 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Add mleader w/ tag counter
« Reply #2 on: September 06, 2009, 09:18:04 PM »
shouldn't (vla-get-objectid leader) be the attribute tag name?
on the mac, can't test right now.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Add mleader w/ tag counter
« Reply #3 on: September 06, 2009, 09:19:12 PM »
also, why not use 'while' instead of 'repeat' then you can just pick until to don't want to, and it will continue to create mleaders with the attribute continuing to increase 1+
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ArgV

  • Guest
Re: Add mleader w/ tag counter
« Reply #4 on: September 06, 2009, 09:37:52 PM »
also, why not use 'while' instead of 'repeat' then you can just pick until to don't want to, and it will continue to create mleaders with the attribute continuing to increase 1+

Like I say, I just threw this together to get the point across. I will be using a while statement, or some other mechanism.  :-D


alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Add mleader w/ tag counter
« Reply #5 on: September 06, 2009, 09:48:52 PM »
also, why not use 'while' instead of 'repeat' then you can just pick until to don't want to, and it will continue to create mleaders with the attribute continuing to increase 1+

Like I say, I just threw this together to get the point across. I will be using a while statement, or some other mechanism.  :-D


oh ok, never hurts to ask. :)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ArgV

  • Guest
Re: Add mleader w/ tag counter
« Reply #6 on: September 06, 2009, 10:07:46 PM »
also, why not use 'while' instead of 'repeat' then you can just pick until to don't want to, and it will continue to create mleaders with the attribute continuing to increase 1+

Like I say, I just threw this together to get the point across. I will be using a while statement, or some other mechanism.  :-D


oh ok, never hurts to ask. :)

 I hope not. If it did, I'd be a hurtin person! :angel:

ArgV

  • Guest
Re: Add mleader w/ tag counter
« Reply #7 on: September 06, 2009, 10:10:48 PM »
but can't find anything on this subject directly.

That's because you needed to search on  >BUBBLE Click Here<


PS Haven't seen it done with Mleaders yet. :)

Well CRAP!  :x Thats it. I guess I found the extent of LISP's usefulness. Just when I thought everything could be done, !BAM! I find the *ONE* thing that can't!

Just kidding. Ok, well, at least I learned some things while searching around for bubbles. :) thanks.

-ArgV

ArgV

  • Guest
Re: Add mleader w/ tag counter
« Reply #8 on: September 06, 2009, 10:13:23 PM »
shouldn't (vla-get-objectid leader) be the attribute tag name?
on the mac, can't test right now.

I don't know. I was just trying to do what the (not real helpful) help file on qleaders said to do, or my interpretation of it.  :|

ArgV

  • Guest
Put something together
« Reply #9 on: September 07, 2009, 12:53:06 AM »
but can't find anything on this subject directly.

That's because you needed to search on  >BUBBLE Click Here<


PS Haven't seen it done with Mleaders yet. :)

Well, I put this together from a few different sources. There isn't alot of documentation on multi-leaders apparently. Kinda scary!

(thanks to Lee Mac for his contribution)

Code: [Select]
(defun c:aacl (/ layout point1 point2 points cntr array leader)

(setq layout (vla-get-paperspace (vla-get-activedocument (vlax-get-acad-object)))
      cntr 1)
 
(while
  (setq
point1 (getpoint "\nSelect arrow point")
point2 (getpoint "\nSelect landing point" point1)
points (append point1 point2))

(setq array (vlax-make-variant
      (vlax-safearray-fill
(vlax-make-safearray vlax-vbdouble
  (cons 0 (1- (length points)))) points)))

(setq leader (vla-addmleader layout array 0))

;This portion borrowed from code from Lee Mac..               
;http://www.theswamp.org/index.php?topic=29271.0             
  (vla-SetDogLegDirection leader 0
      (vlax-3D-point
        (list
          (if (<= (car point1) (car point2)) 1 -1) 0 0)))
;*************************************************************
(vla-put-dogleglength leader 0.1)
(vla-put-landinggap leader 0.1)
(vla-put-contentblockname leader "_TagCircle - Imperial")
(addStuff)

(setq cntr (1+ cntr))
(princ)
)
)


(defun addStuff (/ ent entList attributeNames)
 
(setq ent (entlast))
(setq entList (entget ent))
  (foreach item entList
    (if (= (car item) 330)
      (setq attributeNames (cons (vlax-ename->vla-object (cdr item))
attributeNames))
      )
)
 
(vla-get-tagstring (nth 0 attributeNames))
(vla-SetBlockAttributeValue
  (vlax-ename->vla-object ent)
  (vla-get-objectid (nth 0 attributeNames))
  (itoa cntr)
  )
)

Thanks,

-ArgV

Lee Mac

  • Seagull
  • Posts: 12919
  • London, England
Re: Add mleader w/ tag counter
« Reply #10 on: September 07, 2009, 07:23:42 AM »
Hehe glad I could help in some way  8-)