TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: ELOQUINTET on March 07, 2008, 11:19:27 AM

Title: Preset attribute values routine
Post by: ELOQUINTET on March 07, 2008, 11:19:27 AM
I started a new job recently and have been doing minor revisions and most of them require me to fill in the same thing in the revision description(s). What I'm wondering is has anybody made a routine that will allow me to add common info to so I don't have to type these same things in over and over?
Title: Re: Preset attribute values routine
Post by: deegeecees on March 07, 2008, 11:25:46 AM
Is the attribute and block the same name in each drawing?
Title: Re: Preset attribute values routine
Post by: ronjonp on March 07, 2008, 11:27:59 AM
Dan,

There are tons of attribute routines here :wink:
Search Results (http://www.theswamp.org/index.php?action=search2;params=YWR2YW5jZWR8J3wwfCJ8YnJkfCd8MjIsNDAsMiwzOCw2Myw2NCwxNCwyNywzNSwyMCwxMSw1LDksMjEsMzYsNDYsNTYsNjIsNjYsMzQsNyw4LDEwLDU0LDEsNiwxNSw0LDE5LDMxLDI0LDMyLDMwLDU4LDQ3LDE2LDU5LDYwLDYxLDIzLDMsNDgsNDksNTAsNTEsNTIsNTMsNTUsNTd8InxzaG93X2NvbXBsZXRlfCd8fCJ8c3ViamVjdF9vbmx5fCd8fCJ8c29ydHwnfHJlbGV2YW5jZXwifHNvcnRfZGlyfCd8ZGVzY3wifHNlYXJjaHwnfGF0dHJpYnV0ZXM=;start=20)
Title: Re: Preset attribute values routine
Post by: ELOQUINTET on March 07, 2008, 12:03:07 PM
Deeg i'm not really sure of that yet as i am revising old and new titleblocks. I would have to work with them more before I can say. Ron I did a search before I posted this hoping to someone would pull a rabbit out of a hat rather than having to search through 36 pages. I'll look through these over the weekend unless someone performs magic...
Title: Re: Preset attribute values routine
Post by: deegeecees on March 07, 2008, 12:08:13 PM
Here's some magic that you could tinker with. As always my standard disclaimer applies: "It ain't pretty, but it works". Let me know if you need a nudge.
Title: Re: Preset attribute values routine
Post by: ELOQUINTET on March 07, 2008, 12:59:58 PM
will do man thanks
Title: Re: Preset attribute values routine
Post by: deegeecees on March 07, 2008, 01:16:41 PM
No problem Dan. It's a batch proceesor for multiple drawings. You'll need to tweak a few lines for your situation (i.e. directory, block/attribute name), and it will leave a couple text files on your C: drive. There are probably better ways to achieve what this does, but I thought it may be a good starting point for you.
Title: Re: Preset attribute values routine
Post by: ASMI on March 08, 2008, 03:39:18 PM
Copy all attrributes from blok to block aslo between different drawings. CATT- copy, PATT- paste.


Code: [Select]
;**** Copy attributes values ****

(defun c:catt(/ sSet)

;;; written by ASMI (Alexander Smirnov) 3rd Sep 2007
;;; absolutely free to use and modify

  (vl-load-com)
  (princ "\n<<< Select block to copy attributes >>>")
  (if
    (setq sSet(ssget "_:S" '((0 . "INSERT")(66 . 1))))
    (progn
      (setq cBl(vlax-ename->vla-object(ssname sSet 0)))
      (vl-bb-set 'atLst(cons
(vla-get-Name cBl)
   (mapcar '(lambda(x)
    (vla-get-TextString x))
       (vlax-safearray->list
                 (vlax-variant-value
   (vla-GetAttributes
     cBl))))))
      (princ "\n<<< Attribute value(s) were copied >>>")
      ); end progn
    (princ "\n>>> This isn't block with attribute(s)! <<< ")
    ); end if
  (princ)
  ); end of c:catt



;**** Paste attributes values to multiple blocks ****

(defun c:patt(/ sDat dLst fLst blSet)
  (vl-load-com)
  (if
    (setq sDat(vl-bb-ref 'atLst))
    (progn
      (setq fLst(list '(0 . "INSERT")(cons 2(car sDat)) '(66 . 1))
    dLst(cdr sDat)
    ); end setq
      (princ(strcat "\n<<< Current block to paste is '" (car sDat) "' >>> "))
       (if
(setq blSet(ssget fLst))
  (foreach bl (mapcar 'vlax-ename->vla-object
                       (vl-remove-if 'listp
                         (mapcar 'cadr(ssnamex blSet))))
    (mapcar 'vla-put-TextString
    (vlax-safearray->list
     (vlax-variant-value
       (vla-GetAttributes bl)))dLst)
    ); end foreach
(princ "\n>>> Nothing selected! <<< ")
); end if
      ); end progn
    (princ "\n >>> There isn't attributes datas to paste! <<< ")
    ); end if
  (princ)
  ); end of c:patt
Title: Re: Preset attribute values routine
Post by: CAB on March 09, 2008, 10:01:29 AM
Dan,
There is plenty of code on attributes to put this together.
Do you know the tag name & is it the same every time?
Is the block unique to the space you are in, i.e. only one occurrence?


Here is the pseudo code 1, tag name constant

Here is the pseudo code 2, block unique, but tag name varies

Here is the pseudo code 3, block unique & tag name constant
Title: Re: Preset attribute values routine
Post by: deegeecees on March 11, 2008, 03:12:44 PM
>nudge< Anything pan out for you Dan?