Leader that displays attribute

Leader that displays attribute

rbh1
Enthusiast Enthusiast
1,219 Views
10 Replies
Message 1 of 11

Leader that displays attribute

rbh1
Enthusiast
Enthusiast

Is anyone aware of how to make a leader that will read attributes from a block?  I would like to create a leader that will read the attributes from a block and place them in a bubble (circle) leader.

 

 

Thank you for ay assistance you may be able to provide.

0 Likes
1,220 Views
10 Replies
Replies (10)
Message 2 of 11

devitg
Advisor
Advisor

@rbh1 For better understanding, and maybe get further help, please upload such sample.dwg

0 Likes
Message 3 of 11

pbejse
Mentor
Mentor

@rbh1 wrote:

Is anyone aware of how to make a leader that will read attributes from a block?  I would like to create a leader that will read the attributes from a block and place them in a bubble (circle) leader.


 

That means more than one attribute in a block? and concatenate them in one attribue in the leader?  perhaps use Multileader instead, one that use "_TagCircle" attribute block. Do you need it as Field value ?

 

 

 

0 Likes
Message 4 of 11

rbh1
Enthusiast
Enthusiast

Here is an example of what I would like to do.

 

I would like for the leader to prompt for the block and fill in the attributes.

 

I have created my blocks with the same attribute names to keep it simple and standard.

 

There two different examples.  the F/N 06 is what I am trying to accomplish.  the other one is another leader I would like to do once I learn how to do accomplish the first one.

 

Thank you all for any help you can give.

 

Sincerly

0 Likes
Message 5 of 11

pbejse
Mentor
Mentor

@rbh1 wrote:

There two different examples.  the F/N 06 is what I am trying to accomplish.  the other one is another leader I would like to do once I learn how to do accomplish the first one.

 


You realize the Multileaders have two different ContentType.

Here's one for the "MText/Contents"

 

(defun c:demo (/ ss source sourceID)
  (if (and
	(princ "\nSelect Callout")
	(setq ss (ssget "_+.:S:E:L" '((0 . "MULTILEADER"))))
	(princ "\nSelect Source")
	(setq source (ssget "_+.:S:E" '((0 . "INSERT") (66 . 1))))
      ) ;_ end of and
    (progn
      (if
	(vl-some '(lambda (at)
		    (if	(eq (vla-get-tagstring at) "FINDNUMBER")
		      (setq sourceID (itoa (vla-get-objectid at)))
		    ) ;_ end of if
		  ) ;_ end of lambda
		 (vlax-invoke
		   (vlax-ename->vla-object (ssname source 0))
		   'GetAttributes
		 ) ;_ end of vlax-invoke
	) ;_ end of vl-some
	   (setpropertyvalue
	     (ssname ss 0)
	     "MText/Contents"
	     (strcat "F/N "
		     "%<\\AcObjProp Object(%<\\_ObjId "
		     sourceID
		     ">%).TextString>%"
	     ) ;_ end of strcat
	   ) ;_ end of setpropertyvalue
      ) ;_ end of if
    ) ;_ end of progn
  ) ;_ end of if
  (princ)
) ;_ end of defun

 

 

Let see how you fair with the other type

** Requries a regen **

 

 

0 Likes
Message 6 of 11

rbh1
Enthusiast
Enthusiast

Thank you very much.  I will try this out.

0 Likes
Message 7 of 11

Sea-Haven
Mentor
Mentor

Hi PBE maybe a suggestion rather than hard coding the tag name as you can not see a attribute use the attribute order to get tag name, so dbl click block and look the "FINDNUMBER" would be attribute 2 remember that. So when running would enter tag order 2, this way becomes a bit more global working for any block. Typing a number is a bit quicker than a tagname.

 

Perhaps a Enter tagname or order.

0 Likes
Message 8 of 11

pbejse
Mentor
Mentor

@Sea-Haven wrote:

... this way becomes a bit more global working for any block. Typing a number is a bit quicker than a tagname.


 

I like the idea of making the code more generic  👍 We might as well do that with this one..

 

(defun c:demo (/ _init ss source sourceID) 
(defun _init (l)
  ( (lambda (init choice)
      (foreach str l
        (setq init (Strcat init (car str) " ")
              choice  (Strcat  choice (car str) " " (Cadr str) "/")))
      		(list init choice 2)
      	) ""  "")
  )  
  (if (and
	(princ "\nSelect Callout")
	(setq ss (ssget "_+.:S:E:L" '((0 . "MULTILEADER"))))
	(princ "\nSelect Source")
	(setq source (ssget "_+.:S:E" '((0 . "INSERT") (66 . 1))))
      )
    (progn
      ( (lambda (i)
      (setq attVal (mapcar '(lambda	(att)
			  (list	(itoa (setq i (1+ i)))
				(strcat (vla-get-tagstring att))
				(itoa (vla-get-objectid att))
			  )
			)
		       (vlax-invoke
			 (vlax-ename->vla-object (ssname source 0))
			 'GetAttributes
		       )
	       )
      		))
	  0)
      	(setq choices (_INIT  attVal))
	(initget 1 (Car choices))
	(setq option (getkword (strcat "\nChoose option [" (Cadr choices) "]: ")))
        (setq sourceID (caddr (nth (1- (atoi option)) attVal)))
	   (setpropertyvalue
	     (ssname ss 0)
	     "MText/Contents"
	     (strcat "F/N "
		     "%<\\AcObjProp Object(%<\\_ObjId "
		     sourceID
		     ">%).TextString>%"
	     ) 
	   ) 
      )
    ) 

  (princ)
)

Either you click on the choice of type in a number

It this particular demo code

Command: DEMO
Select Callout
Select objects:

Choose option [1 PARTNUMBER/2 FINDNUMBER/3 DESCRIPTION/]: 

 

HTH

0 Likes
Message 9 of 11

Sea-Haven
Mentor
Mentor

Nice solution

0 Likes
Message 10 of 11

pbejse
Mentor
Mentor

@Sea-Haven wrote:

Nice solution


Glad you like  👍 it, I was hoping the OP would get back to us with what the info for the other Mleader type. It would've been fun to code.

 

 

 

0 Likes
Message 11 of 11

rbh1
Enthusiast
Enthusiast

I apologize I have been working on another project but back on it now.  I will let you know about the other leader and try out your solution.  Thank you very much for taking out the time to provide the code for me to try.

0 Likes