i was and still am Posted July 26, 2012 Posted July 26, 2012 i am trying to teach myself some lisp, after many years of being out of the industry. so I have a problem. I want to create a toolbar macro usiing a bit of macro language and a bit of lisp... I have a bit of work to do changing attributes. these are quite standard having just a single default, the block name is the same throughout. what i want to do, and have done is change the attribute default. this is relativly easy if the change is always the same. i would like to be able to change this to be variable.. so i have played around with simple lisp statements. what i have is : put a variable together using (setq a (getstring "what ?")).. then I try and pass this into the -attedit command at the appropriate 'change to what' prompt... BUT i cant get the command to take the variable. i have tried various ways ( 'used the lisp bit first and tried !variable at point of 'change to', 'tried putting the lisp in at the point of 'change to', tried putting the whole thing in lisp as in all 'command and prompts' in quotes) but am at a loss... any help would be appreciated.. To summerise: how can i pass a variable string to the attedit command at the 'change to' prompt.. Quote
BIGAL Posted July 27, 2012 Posted July 27, 2012 You would normally write a lisp to do the whole thing and rather than use -attedit you would do some form of entity update proceedure. Here is a update title block lisp as an example it a start of something bigger it asks questions and reads the layout name as part of the block updates. Thanks to Lee-mac for parsing code. ; change the 410 to layout name ;;-------------------=={ Parse Numbers }==--------------------;; ;; ;; ;; Parses a list of numerical values from a supplied string. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - [url="http://www.lee-mac.com"]www.lee-mac.com[/url] ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; s - String to process ;; ;;------------------------------------------------------------;; ;; Returns: List of numerical values found in string. ;; ;;------------------------------------------------------------;; (defun LM:ParseNumbers ( s ) ( (lambda ( l ) (read (strcat "(" (vl-list->string (mapcar (function (lambda ( a b c ) (if (or (< 47 b 58) (and (= 45 b) (< 47 c 58) (not (< 47 a 58))) (and (= 46 b) (< 47 a 58) (< 47 c 58)) ) b 32 ) ) ) (cons nil l) l (append (cdr l) (list nil)) ) ) ")" ) ) ) (vl-string->list s) ) ) ; update title block by BIGAL july 2012 ;(defun ah:sheetupdate1 (ss1 lay plotabs tabname dwgname) (defun ah:sheetupdate1 () (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for lay (vla-get-Layouts doc) (setq plotabs (cons (vla-get-name lay) plotabs)) ) (setq title "Please enter dwg number") (ah:getval title) (setq dwgname item) (setq newstr4 (getstring "\nPlease enter version for all sheets <Cr> no change ")) (princ "0") (setq len (length plotabs)) (setq x 0) (setq bname "DA1DRTXT") (repeat len (setq tabname (nth x plotabs)) (if (/= tabname "Model") (progn (setvar "ctab" tabname) (setq ss1 (ssget "x" (list (cons 0 "INSERT") (cons 2 bname)(cons 410 tabname)))) (setq dwgnum (Lm:parsenumbers tabname)) (setq sheetnum (car dwgnum)) (setq oldtag1 "SHT_NO") ;attribute tag name (setq newstr1 (rtos sheetnum 2 0)) (setq oldtag2 "DRG_NO") ;attribute tag name (setq oldtag3 "PROJ_NO") ;attribute tag name (setq newstr3 dwgname) (setq oldtag4 "REV_NO") ;attribute tag name ; if less than 10 (if (< (car dwgnum) 10.0) (setq newstr2 (strcat dwgname "-D0" (rtos sheetnum 2 0))) (setq newstr2 (strcat dwgname "-D" (rtos sheetnum 2 0))) ) (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 0 )) 'getattributes) (if (= oldtag1 (strcase (vla-get-tagstring att))) (vla-put-textstring att newstr1) ) ; end if (if (= oldtag2 (strcase (vla-get-tagstring att))) (vla-put-textstring att newstr2) ) ; end if (if (= oldtag3 (strcase (vla-get-tagstring att))) (vla-put-textstring att newstr3) ) ; end if (if (and (/= version nil) (= oldtag4 (strcase (vla-get-tagstring att))) ) (vla-put-textstring att newstr4) ) ; end if ) ; end foreach ) ; end progn ) ; end if (setq x (+ x 1)) ) ; end repeat (setq ss1 nil) ) ; end defun ah (ah:sheetupdate1) (princ) Quote
DesignMan Posted November 22, 2012 Posted November 22, 2012 Hi Is there any lisp routine which can update title block in many layout within a drawing file. Thanks DM Quote
BIGAL Posted November 23, 2012 Posted November 23, 2012 Thats what the code in the post above does! 2 methods go to each layout and do something or just do all contained in DWG as above. 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.