Extracting from Block Table (for multiple blocks)

Extracting from Block Table (for multiple blocks)

3arizona
Advocate Advocate
960 Views
4 Replies
Message 1 of 5

Extracting from Block Table (for multiple blocks)

3arizona
Advocate
Advocate

I found this lisp a while back and can't find the original thread.  Dynamic Block has an attribute TAG called NOTE01 and block Table Table information.  Lisp works fine, it reads NOTE01 attribute and Table Text. Command places block information on a leader.

 

I want to add another block with a different attribute TAG (NOTE02) but when i add the attribute to the lisp nothing works.. I don't want to create different lisps/command for the same category of blocks.  

 

See lisp. object in red is the new attribute TAG and that's when nothing work. 

(defun c:Note ( / obj ent items counter blkname attname attdxf)
  (setq ent (SSget))
  (setq p1 (getpoint "\nSpecify arrowhead location: "))
  (setq p2 (getpoint p1 "\nSpecify leader landing location: "))	
    (if ent
      (progn
        (setq Items (sslength Ent ) )
        (setq Counter -1 )
        (repeat Items
          (setq Counter (1+ Counter ) )
          (setq BlkName (ssname Ent Counter ) )
          (setq AttName (entnext BlkName ) ) 
          (eq "AcDbAttribute" (setq obj (vlax-ename->vla-object attname)))
	  (while AttName
            (setq AttDxf (entget AttName ) )
            (if (= (cdr (assoc 2 AttDxf )) "NOTE01, NOTE02")  
		(command "mleader" P1 p2 
      (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-objectid obj)) ">%).TextString>%") ) )
            (if (= (cdr (assoc 0 (entget AttName ))) "SEQEND" )
		(setq AttName nil )
		(setq AttName (entnext AttName )) )
          )
          (setq AttName BlkName )
        ) 
      )
    )
  (princ)
)

 

0 Likes
Accepted solutions (1)
961 Views
4 Replies
Replies (4)
Message 2 of 5

jtoverka
Advocate
Advocate
Accepted solution

I am operating on the assumption that you have a separate block with the NOTE02 attribute and you want the program to find that and perform an operation. Therefore:

 

Change

(if (= (cdr (assoc 2 AttDxf )) "NOTE01, NOTE02")  

 to

(if (or
(= (cdr (assoc 2 AttDxf )) "NOTE01")
(= (cdr (assoc 2 AttDxf)) "NOTE02")
)

 

0 Likes
Message 3 of 5

Moshe-A
Mentor
Mentor

@3arizona hi,

 

or better change it to this:

(wcmatch (strcase (cdr (assoc 2 AttDxf ))) "NOTE0[12]")  

 

this means the last char could be 1 or 2

 

and if you want to it to cover future tags, you can do that:

(wcmatch (strcase (cdr (assoc 2 AttDxf ))) "NOTE0[0-9]")
  

and this means the last char can be from 0 to 9 (it a range)

you also could do the same to the '0' before the last.

 

moshe

0 Likes
Message 4 of 5

3arizona
Advocate
Advocate

Works Perfect! Thank you, for your time.

 

 

0 Likes
Message 5 of 5

3arizona
Advocate
Advocate

Moshe-A, you options inserted 60-70 Mleaders.  thank you also for your time

0 Likes