Ok, i have it working in this current form:
(defun c:Note ( / obj ent items counter blkname attname attdxf p1 p2 a b c inspnt itm)
(setq p1 '(0,0,0))
(setvar "clayer" "A-Anno-Note")
(command "cannoscale" "1/4\" = 1'-0\"")
;(setq leaderstyle (getvar "mleaderstyle"))
;(command _.mleaderstyle "Block (Straight Leader)" "")
(setq ent (SSget))
(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)))
;(setq p1 (getpoint "\nSpecify arrowhead location: "))
(if (setq inspnt
(ssget "_+.:S:E"
'((0 . "INSERT")
(66 . 1))))
(progn
(foreach
itm
(vlax-invoke
(vlax-ename->vla-object
(ssname inspnt 0))
'GetAttributes)
;(if (minusp (vlax-get itm 'Invisible))
(progn
(setq p1 (Vlax-get
itm
'InsertionPoint))))))
;)
;(princ p1)
(setq a (+ (car p1) 12))
(setq b (+ (cadr p1) 12))
(setq c (caddr p1))
(setq p2 (list a b c))
(princ p1)
(princ p2)
(princ a)
(princ b)
(princ c)
;(setq p2 (getpoint "\nSpecify leader landing location: "))
(while attname
(setq attdxf (entget attname ) )
(if
(= (cdr (assoc 2 attdxf )) "ACCESS")
(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 )
)
)
)
(setvar "clayer" "0")
;(command _.mleaderstyle leaderstyle)
(princ)
)
I still have a few more things to figure out to make the routine more robust:
- I have some blocks with more than one hidden attribute and can add those here:
(while attname
(setq attdxf (entget attname ) )
(if
(= (cdr (assoc 2 attdxf )) "ACCESS")
What I would like to do is make this cycle through each one individually probably with a either a foreach or a while. Also guessing I would need to move this part above the part where I pull the points so it can find the insertion point of each one.
2. I would like to not have to not have to select each block a second time to have the points get calculated when this:
(if (setq inspnt
(ssget "_+.:S:E"
'((0 . "INSERT")
(66 . 1))))
Is ran so it automatically will cycle through the selection that happens during this:
(setq ent (SSget))
(if ent
(progn
(setq items (sslength ent ) )
To make sure that the right leader is associated with the correct block.
I have included a .dwg with my test blocks for reference.
I am still reading and learning about how to assemble code in LISP to behave how I want it to behave so if I can get some direction or places to look would be greatly appreciated. I am digging through Lee Mac's site and Afralisp to see what I can find along with the forums both autodesk and cadTutor.
My last step will be to go back through to add in error handling.