TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: ArgV 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.
(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
-
but can't find anything on this subject directly.
That's because you needed to search on >BUBBLE Click Here< (http://www.theswamp.org/index.php?action=search2;params=YWR2YW5jZWR8J3wxfCJ8YnJkfCd8MiwxMXwifHNob3dfY29tcGxldGV8J3x8InxzdWJqZWN0X29ubHl8J3x8Inxzb3J0X2RpcnwnfGRlc2N8Inxzb3J0fCd8cmVsZXZhbmNlfCJ8c2VhcmNofCd8YnViYmxl)
PS Haven't seen it done with Mleaders yet. :)
-
shouldn't (vla-get-objectid leader) be the attribute tag name?
on the mac, can't test right now.
-
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+
-
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
-
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. :)
-
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:
-
but can't find anything on this subject directly.
That's because you needed to search on >BUBBLE Click Here< (http://www.theswamp.org/index.php?action=search2;params=YWR2YW5jZWR8J3wxfCJ8YnJkfCd8MiwxMXwifHNob3dfY29tcGxldGV8J3x8InxzdWJqZWN0X29ubHl8J3x8Inxzb3J0X2RpcnwnfGRlc2N8Inxzb3J0fCd8cmVsZXZhbmNlfCJ8c2VhcmNofCd8YnViYmxl)
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
-
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. :|
-
but can't find anything on this subject directly.
That's because you needed to search on >BUBBLE Click Here< (http://www.theswamp.org/index.php?action=search2;params=YWR2YW5jZWR8J3wxfCJ8YnJkfCd8MiwxMXwifHNob3dfY29tcGxldGV8J3x8InxzdWJqZWN0X29ubHl8J3x8Inxzb3J0X2RpcnwnfGRlc2N8Inxzb3J0fCd8cmVsZXZhbmNlfCJ8c2VhcmNofCd8YnViYmxl)
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)
(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
-
Hehe glad I could help in some way 8-)