now i can run the program
but.. that not working to change variable for all layout
could help me ?
thanks
;;; revision 2022-jan-18-b
;;; THEY ARE MULTIPLE POSSIBILITY OF REVISION IN A DRAWING OR PROJECT
;;; DRAWING MAY CONTAIN MULTIPLE INFINITE TABS(LAYOUT)
;;; BLOCK SSREVISION ARE REQUIRED AND COULD BE ON ANY LAYOUT
;;; THIS PROGRAM ATOMATICALY MAKE REVISION (ADD A LINE) IN THE BLOCK IF REVISION ARE MADE IN SHREV_# TAG
;;; THIS PROGRAM IS NOT COMPLETE AND HAVE BUG BUT ITS A IDEA TO DOING THE FUNCTION
(vl-load-com)
(defun :GetRevList (blkname / :BuildName :Layorder lays lst)
(defun :BuildName (att)
(setq att (strcase att))
(if (zerop (atoi att))
(strcat "" att)
(strcat "REV"
(substr att 1 (vl-string-search "_" att))
(cond ((wcmatch att "*NO*"
) "NO")
((wcmatch att "*DATE*") "DATE")
((wcmatch att "*MIS*") "EMIS")
((wcmatch att "*PAR*") "PAR")
(T "X")))))
; pbejse https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/layout-order/td-p/3749964
(defun :Layorder (/ order)
(vlax-for lay (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq order (cons (list (vla-get-name lay) (vla-get-taborder lay)) order)))
(mapcar 'car (cdr (vl-sort order '(lambda (j k) (< (cadr j) (cadr k)))))))
; ---------------------------------------------------------------------------------------------------
; main func
(foreach lay (setq lays (:Layorder))
(if (setq sel (ssget "_X" (list '(0 . "INSERT") (cons 2 blkname) (cons 410 lay))))
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname sel 0)) 'GetAttributes)
(setq lst (cons (cons (strcat (:BuildName (vla-get-TagString att)) (itoa (1+ (vl-position lay lays))))
(vla-get-TextString att))
lst)))))
(setq lst (reverse lst)))
;; Set Attribute Value - Lee Mac
;; Sets the value of the first attribute with the given tag found within the block, if present.
;; blk - [vla] VLA Block Reference Object
;; tag - [str] Attribute TagString
;; val - [str] Attribute Value
;; Returns: [str] Attribute value if successful, else nil.
(defun LM:vl-setattributevalue ( blk tag val )
(setq tag (strcase tag))
(vl-some
'(lambda ( att )
(if (= tag (strcase (vla-get-tagstring att)))
(progn (vla-put-textstring att val) val)
)
)
(vlax-invoke blk 'getattributes)
)
)
;;;; SETATTRIB
(defun setAttrib ( blkname att val / ss vla-obj)
(setq sheetlayname (setvar 'ctab (nth sheetlay (layoutlist))))
(if (setq ss (ssget "X" (list (cons 2 blkname)(cons 0 "INSERT")(cons 410 sheetlayname))))
(progn
(setq vla-obj (vlax-ename->vla-object (ssname ss 0)))
(if (not (LM:vl-setattributevalue vla-obj att val))
(prompt "\nAttribute not present")
)
)
(prompt "\nBlock not found")
)
(princ)
)
;;;testing variables....
(defun c:ReadExamples ( / lst)
(setq lst (:GetRevList "SSREVISION"))
(foreach e lst
(princ "\n") (princ e)) ; list all values (associated list)
;;;
;;; (princ "\n")
;;; (princ (cdr (assoc "REV3DATE1" lst))) ; princ value from associted list
;;; below - IMHO this is ridiculuos, associated list should serve the puPARose.
(foreach e lst
(set (read (car e)) (cdr e))) ;; set all variables from associated list
;;; (princ "\n")
;;; (princ (eval (read "REV3DATE1"))) ;; princ a value from variable
;;;
(princ)
)
(defun c:REC_REVUP ()
(c:ReadExamples)
;layout 1
(if
(/= SS_NO1 "%%")
(and
(setq sheetlay 1)
(setAttrib "SSREVISION" "SS_BAKNO" SS_NO1)
(setq SNO1 "oui")
);end and
);end if
(if
(= SS_NO1 "%%")
(setq SNO1 "non")
);end if
(if
(and
(/= SS_NO1 "%%")
(/= SS_BAKNO1 "%%")
(= REV1NO1 "%%")
);end and
(and
(setq sheetlay 1)
(setAttrib "SSREVISION" "1_NO" SS_NO1)
(setq R1NO1 "oui")
);end and
);end if
(if
(and
(= SS_NO1 "%%")
(= SS_BAKNO1 "%%")
(/= REV1NO1 "%%")
);end and
(setq R1NO1 "non")
);end if
;layout 2
(if
(/= SS_NO2 "%%")
(and
(setq sheetlay 2)
(setAttrib "SSREVISION" "SS_BAKNO" SS_NO2)
(setq SNO2 "oui")
);end and
);end if
(if
(= SS_NO2 "%%")
(setq SNO2 "non")
);end if
(if
(and
(/= SS_NO2 "%%")
(/= SS_BAKNO2 "%%")
(= REV1NO2 "%%")
);end and
(and
(setq sheetlay 2)
(setAttrib "SSREVISION" "1_NO" SS_NO2)
(setq R1NO2 "oui")
);end and
);end if
(if
(and
(= SS_NO2 "%%")
(= SS_BAKNO2 "%%")
(/= REV1NO2 "%%")
);end and
(setq R1NO2 "non")
);end if
(princ)
)