Jump to content

Recommended Posts

Posted

Hello,

 

Looking for some code that can help extract both attribute information and multiple lines of text out of one block so i can insert it into another. i have been able to do one or the other but not both in one block at the same time.

 

 

Thanks,

Jess

Posted

sample [retirieve text strings]

(defun c:sample  (/ a e txtlst atbtlst)
     (if (setq txtlst nil
               a      (ssget "_:S:E" '((0 . "INSERT"))))
           (progn
                 (setq e (vlax-ename->vla-object (ssname a 0)))
                 (vlax-for
                        itm
                        (vla-item
                              (vla-get-blocks
                                    (vla-get-ActiveDocument
                                          (vlax-get-acad-object)))
                              (vla-get-effectivename e))
                       (if (wcmatch
                                 (vla-get-ObjectName itm)
                                 "AcDb*Text")
                             (setq txtlst
                                        (cons (vla-get-TextString
                                                    itm)
                                              txtlst))))
                 (setq atbtlst
                            (mapcar
                                  (function
                                        (lambda (j)
                                              (vla-get-textstring
                                                    j)))
                                  (vlax-invoke
                                        e
                                        'GetAttributes)))
                 )
           )
     (foreach
            itm  (list '("TEXT" txtlst) '("ATTRIB" atbtlst))
           (if (eval (cadr itm))
                 (progn (print (car itm))
                        (foreach
                               str  (eval (cadr itm))
                              (princ (strcat "\n\t\t" str)))
                        )
                 )
           )
     (princ)
     )

Posted

I guess i am. somehow on vlide, when i click format selection it does that. before the indention is not that wide. tried revert to default but still no joy. :?

Posted
That worked great, thanks a lot.

 

Jess

 

You are welcome Jess

Glad i could help

 

Cheers

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...