CADkitt Posted May 14, 2010 Posted May 14, 2010 So I have to do a lot of boring work like updating old templates with new ones. And I was asked to copy past all that attribute text to the new template. And hell no I'm not planning to do that manual. So I started searching the forum for autolisp I could use. And so far I almost got it except one little link that I am missing. The problem the new template doesn't have the same tags as the new one, and it even has 1 subject line less. So I have to merge an attribute (att1+ att2)= att3 Would be enough. Edit found a rename tag lisp file after searching for battman lisp edit2: I got it all working now only need to merge 2 Attribute values. EDIT3 the code pasting only works if the block has the same name tried deleting the check but failed. Some one any idea how to kick out the name check? check new posts Quote
CADkitt Posted May 17, 2010 Author Posted May 17, 2010 lol I did a lot of nonsens here (at least I learned a lot of it ). The code that worked for me now renames old tags with the new ones then replaces the template with a new one and updates it with attsync. It also adjusts the scale of the new template. (defun changeTags (/ BLK DOC I TAGLST SS) (vl-load-com) (setq blk "A10" tagLst '( ;"Old Tag" "New Tag" ("REG1" "PROJECTTITLE2") ("REG2" "TITLE1") ("REG3" "TITLE2") ("CLIENT" "CLIENT1") ("PROJECT" "PROJECTTITLE1") ("REG1" "PROJECTTITLE2") ) i -1 doc (vla-get-activedocument (vlax-get-acad-object)) ) (if (ssget "_X" (list (cons 0 "INSERT")(cons 2 blk))) (vlax-for bl (setq ss (vla-get-activeselectionset doc)) (foreach att (vlax-invoke bl 'getAttributes) (If (assoc (vla-get-tagstring att) tagLst) (vla-put-tagstring att (cadr (assoc (vla-get-tagstring att) tagLst))) ))) (princ "\nNo Selection Set Found.")) (princ) (progn (command "-rename" "b" "A10" "new block NEW LOGO") (command "_.-insert" "new block NEW LOGO=Template_New_2010" "y" nil);replaced convert template to new template. (command "_.attsync" "n" "new block NEW LOGO") (scl);; scales all templates )(princ)(princ "succes!")(princ) ) ;; Run program manually with this: (defun c:ChTag () (changeTags)) ;; Uncomment this to run when lisp loaded ;(changeTags) ;; Scale the old template to new one (defun scl (/ ss) (vl-load-com) (if (setq SS (ssget "_X" (list '(0 . "INSERT") (cons 2 "new block NEW LOGO")))) ;(if (setq ss (ssget '((0 . "CIRCLE,ARC,ELLIPSE")))) (mapcar (function (lambda (Obj) (vla-ScaleEntity Obj (vla-get-insertionpoint Obj)9.673518))) (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))) (princ)) And it all works in batch, so I am gonna take the rest of the day off Quote
Recommended Posts
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.