Jump to content

Recommended Posts

Posted

Hi, I've been looking for a way to process this task for weeks, since I found out it's going to be necessary, and am getting a bit stumped.

 

I thought It was a dynamic block, but @Lee Mac's lisp to find visibility of stamps didn't detect it. I thought I found an option to delete the stamp & replace with the visibitlity set, but haven't been able to find the post again.

 

it's a client's status stamp, in the lower-right of the titleblock, and I need to change visibility1 from "ISSUED TO CONSTRUCTION" to showing "AS CONSTRUCTED".

00-G-10-0003 - PTA A1 DRG SHT.dwg

Posted

Using Lee's 'set dynamic block property value', run this code in a script:

(defun c:foo (/ s)
  ;; Set Dynamic Block Property Value  -  Lee Mac
  ;; Modifies the value of a Dynamic Block property (if present)
  ;; blk - [vla] VLA Dynamic Block Reference object
  ;; prp - [str] Dynamic Block property name (case-insensitive)
  ;; val - [any] New value for property
  ;; Returns: [any] New value if successful, else nil
  (defun lm:setdynpropvalue (blk prp val)
    (setq prp (strcase prp))
    (vl-some
      '(lambda (x)
	 (if (= prp (strcase (vla-get-propertyname x)))
	   (progn (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))
		  (cond	(val)
			(t)
		  )
	   )
	 )
       )
      (vlax-invoke blk 'getdynamicblockproperties)
    )
  )
  (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "PTA_STAMP_DYNAMIC,`*U*"))))
    (foreach o (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex s)))
      (if (= "PTA_STAMP_DYNAMIC" (strcase (vla-get-effectivename o)))
	(lm:setdynpropvalue o "Visibility1" "AS CONSTRUCTED")
      )
    )
  )
  (princ)
)

 

  • Like 1
Posted
9 hours ago, ronjonp said:

Thanks. I actually tried the Lisp he created that lists the visibility states of dynamic blocks on the drawing, but this particular block wasn't listed, just the titleblock and another I didn't recognise.

 

Using Lee's 'set dynamic block property value', run this code in a script:

(defun c:foo (/ s)
  ;; Set Dynamic Block Property Value  -  Lee Mac
  ;; Modifies the value of a Dynamic Block property (if present)
  ;; blk - [vla] VLA Dynamic Block Reference object
  ;; prp - [str] Dynamic Block property name (case-insensitive)
  ;; val - [any] New value for property
  ;; Returns: [any] New value if successful, else nil
  (defun lm:setdynpropvalue (blk prp val)
    (setq prp (strcase prp))
    (vl-some
      '(lambda (x)
	 (if (= prp (strcase (vla-get-propertyname x)))
	   (progn (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))
		  (cond	(val)
			(t)
		  )
	   )
	 )
       )
      (vlax-invoke blk 'getdynamicblockproperties)
    )
  )
  (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "PTA_STAMP_DYNAMIC,`*U*"))))
    (foreach o (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex s)))
      (if (= "PTA_STAMP_DYNAMIC" (strcase (vla-get-effectivename o)))
	(lm:setdynpropvalue o "Visibility1" "AS CONSTRUCTED")
      )
    )
  )
  (princ)
)

 

 

Posted

A bit more if your using Accoreconsole it uses a script which can call a lisp, so after calling you could get it as part of the script to set the correct revision PRE-LIM, ISSUED, AS-BUILT etc.

 

I am sure Ronjonp can help you with a simple change to the FOO defun.

 

Accoreconsole can be batch driven to do a whole directory in one go. If you want more information just ask.

Posted

RonJonP works for me

 

For batch process, another of Lee Macs, scripteditor should do the batch processing OK.

 

BigAl - not sure about Accoreconsole - it sometimes fails with VLA- or VLAX- commands doesn't it? (I tend to use another routine rather than that even if core console is a lot quicker so not sure which it doesn't like)

  • Like 1
Posted
4 hours ago, Steven P said:

BigAl - not sure about Accoreconsole - it sometimes fails with VLA- or VLAX- commands doesn't it? (I tend to use another routine rather than that even if core console is a lot quicker so not sure which it doesn't like)

 

You are right, this is hardly possible unless you load with (arxload) certain ARX libraries, but you have to know which ones, which is not at all obvious.

  • Like 1
Posted

There is this one which is cut down from the one I made up. Mine has a load of links to other smaller LISPs and is pain to copy all the parts into here, so you get the short version. LM: Refers to Lee Macs LISPs

 

Command BasicBatchLisp

 

Commands List Notes:
- write commands as if you were writing them in a LISP excluding start and end bracket ( ) for example to draw a line (example usng an AutoCAD command example) command "line" "0,0" "10,10" ""  (no brackets)

 

Or for a LISP example c:za remembering for LISPs to include the 'c:'
Note that in this the LISP routines have to be in the start-up menu or loaded before they are run
 

Quite a basic interface, not many checks but should also work. Slower than core console - this opens, works on and saves each file in turn but should also leave behind the bak file in case you want to go back a step

 

 

 

(defun c:za() (command "zoom" "a" "zoom" ".95x")(princ));;Zoom all, then zooms out 0.95x
(vl-load-com)
;;------------------------=={ Get Files Dialog }==----------------------;;
;;                                                                      ;;
;;  An analog of the 'getfiled' function for multiple file selection.   ;;
;;----------------------------------------------------------------------;;
;;  Author:  Lee Mac, Copyright © 2012  -  www.lee-mac.com              ;;
;;----------------------------------------------------------------------;;
;;  Arguments:                                                          ;;
;;  msg - [str/nil] Dialog box label; 'Select Files' if nil or "".      ;;
;;  def - [str/nil] Default directory; dwgprefix if nil or "".          ;;
;;  ext - [str/nil] File extension filter (e.g. "dwg;lsp"); "*" if nil  ;;
;;----------------------------------------------------------------------;;
;;  Returns:  List of selected files, else nil                          ;;
;;----------------------------------------------------------------------;;
;;  Version 1.6    -    2016-03-21                                      ;;
;;----------------------------------------------------------------------;;
(defun LM:getfiles ( msg def ext / *error* dch dcl des dir dirdata lst rtn )

    (defun *error* ( msg )
        (if (= 'file (type des))
            (close des)
        )
        (if (and (= 'int (type dch)) (< 0 dch))
            (unload_dialog dch)
        )
        (if (and (= 'str (type dcl)) (findfile dcl))
            (vl-file-delete dcl)
        )
        (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")))
            (princ (strcat "\nError: " msg))
        )
        (princ)
    )    
    
    (if
        (and
            (setq dcl (vl-filename-mktemp nil nil ".dcl"))
            (setq des (open dcl "w"))
            (progn
                (foreach x
                   '(
                        "lst : list_box"
                        "{"
                        "    width = 40.0;"
                        "    height = 20.0;"
                        "    fixed_width = true;"
                        "    fixed_height = true;"
                        "    alignment = centered;"
                        "    multiple_select = true;"
                        "}"
                        "but : button"
                        "{"
                        "    width = 20.0;"
                        "    height = 1.8;"
                        "    fixed_width = true;"
                        "    fixed_height = true;"
                        "    alignment = centered;"
                        "}"
                        "getfiles : dialog"
                        "{"
                        "    key = \"title\"; spacer;"
                        "    : row"
                        "    {"
                        "        alignment = centered;"
                        "        : edit_box { key = \"dir\"; label = \"Folder:\"; }"
                        "        : button"
                        "        {"
                        "            key = \"brw\";"
                        "            label = \"Browse\";"
                        "            fixed_width = true;"
                        "        }"
                        "    }"
                        "    spacer;"
                        "    : row"
                        "    {"
                        "        : column"
                        "        {"
                        "            : lst { key = \"box1\"; }"
                        "            : but { key = \"add\" ; label = \"Add Files\"; }"
                        "        }"
                        "        : column {"
                        "            : lst { key = \"box2\"; }"
                        "            : but { key = \"del\" ; label = \"Remove Files\"; }"
                        "        }"
                        "    }"
                        "    spacer; ok_cancel;"
                        "}"
                    )
                    (write-line x des)
                )
                (setq des (close des))
                (< 0 (setq dch (load_dialog dcl)))
            )
            (new_dialog "getfiles" dch)
        )
        (progn
            (setq ext (if (= 'str (type ext)) (LM:getfiles:str->lst (strcase ext) ";") '("*")))
            (set_tile "title" (if (member msg '(nil "")) "Select Files" msg))
            (set_tile "dir"
                (setq dir
                    (LM:getfiles:fixdir
                        (if (or (member def '(nil "")) (not (vl-file-directory-p (LM:getfiles:fixdir def))))
                            (getvar 'dwgprefix)
                            def
                        )
                    )
                )
            )
            (setq lst (LM:getfiles:updatefilelist dir ext nil))
            (mode_tile "add" 1)
            (mode_tile "del" 1)

            (action_tile "brw"
                (vl-prin1-to-string
                   '(if (setq tmp (LM:getfiles:browseforfolder "" nil 512))
                        (setq lst (LM:getfiles:updatefilelist (set_tile "dir" (setq dir tmp)) ext rtn)
                              rtn (LM:getfiles:updateselected dir rtn)
                        )                              
                    )
                )
            )

            (action_tile "dir"
                (vl-prin1-to-string
                   '(if (= 1 $reason)
                        (setq lst (LM:getfiles:updatefilelist (set_tile "dir" (setq dir (LM:getfiles:fixdir $value))) ext rtn)
                              rtn (LM:getfiles:updateselected dir rtn)
                        )
                    )
                )
            )

            (action_tile "box1"
                (vl-prin1-to-string
                   '(
                        (lambda ( / itm tmp )
                            (if (setq itm (mapcar '(lambda ( n ) (nth n lst)) (read (strcat "(" $value ")"))))
                                (if (= 4 $reason)
                                    (cond
                                        (   (equal '("..") itm)
                                            (setq lst (LM:getfiles:updatefilelist (set_tile "dir" (setq dir (LM:getfiles:updir dir))) ext rtn)
                                                  rtn (LM:getfiles:updateselected dir rtn)
                                            )
                                        )
                                        (   (vl-file-directory-p (setq tmp (LM:getfiles:checkredirect (strcat dir "\\" (car itm)))))
                                            (setq lst (LM:getfiles:updatefilelist (set_tile "dir" (setq dir tmp)) ext rtn)
                                                  rtn (LM:getfiles:updateselected dir rtn)
                                            )
                                        )
                                        (   (setq rtn (LM:getfiles:sort (append rtn (mapcar '(lambda ( x ) (strcat dir "\\" x)) itm)))
                                                  rtn (LM:getfiles:updateselected dir rtn)
                                                  lst (LM:getfiles:updatefilelist dir ext rtn)
                                            )
                                        )
                                    )
                                    (if (vl-every '(lambda ( x ) (vl-file-directory-p (strcat dir "\\" x))) itm)
                                        (mode_tile "add" 1)
                                        (mode_tile "add" 0)
                                    )
                                )
                            )
                        )
                    )
                )
            )

            (action_tile "box2"
                (vl-prin1-to-string
                   '(
                        (lambda ( / itm )
                            (if (setq itm (mapcar '(lambda ( n ) (nth n rtn)) (read (strcat "(" $value ")"))))
                                (if (= 4 $reason)
                                    (setq rtn (LM:getfiles:updateselected dir (vl-remove (car itm) rtn))
                                          lst (LM:getfiles:updatefilelist dir ext rtn)
                                    )
                                    (mode_tile "del" 0)
                                )
                            )
                        )
                    )
                )
            )

            (action_tile "add"
                (vl-prin1-to-string
                   '(
                        (lambda ( / itm )
                            (if
                                (setq itm
                                    (vl-remove-if 'vl-file-directory-p
                                        (mapcar '(lambda ( n ) (nth n lst)) (read (strcat "(" (get_tile "box1") ")")))
                                    )
                                )
                                (setq rtn (LM:getfiles:sort (append rtn (mapcar '(lambda ( x ) (strcat dir "\\" x)) itm)))
                                      rtn (LM:getfiles:updateselected dir rtn)
                                      lst (LM:getfiles:updatefilelist dir ext rtn)
                                )
                            )
                            (mode_tile "add" 1)
                            (mode_tile "del" 1)
                        )
                    )
                )
            )

            (action_tile "del"
                (vl-prin1-to-string
                   '(
                        (lambda ( / itm )
                            (if (setq itm (read (strcat "(" (get_tile "box2") ")")))
                                (setq rtn (LM:getfiles:updateselected dir (LM:getfiles:removeitems itm rtn))
                                      lst (LM:getfiles:updatefilelist dir ext rtn)
                                )
                            )
                            (mode_tile "add" 1)
                            (mode_tile "del" 1)
                        )
                    )
                )
            )
         
            (if (zerop (start_dialog))
                (setq rtn nil)
            )
        )
    )
    (*error* nil)
    rtn
)
(defun LM:getfiles:listbox ( key lst )
    (start_list key)
    (foreach x lst (add_list x))
    (end_list)
    lst
)
(defun LM:getfiles:listfiles ( dir ext lst )
    (vl-remove-if '(lambda ( x ) (member (strcat dir "\\" x) lst))
        (cond
            (   (cdr (assoc dir dirdata)))
            (   (cdar
                    (setq dirdata
                        (cons
                            (cons dir
                                (append
                                    (LM:getfiles:sortlist (vl-remove "." (vl-directory-files dir nil -1)))
                                    (LM:getfiles:sort
                                        (if (member ext '(("") ("*")))
                                            (vl-directory-files dir nil 1)
                                            (vl-remove-if-not
                                                (function
                                                    (lambda ( x / e )
                                                        (and
                                                            (setq e (vl-filename-extension x))
                                                            (setq e (strcase (substr e 2)))
                                                            (vl-some '(lambda ( w ) (wcmatch e w)) ext)
                                                        )
                                                    )
                                                )
                                                (vl-directory-files dir nil 1)
                                            )
                                        )
                                    )
                                )
                            )
                            dirdata
                        )
                    )
                )
            )
        )
    )
)
(defun LM:getfiles:checkredirect ( dir / itm pos )
    (cond
        (   (vl-directory-files dir) dir)
        (   (and
                (=  (strcase (getenv "UserProfile"))
                    (strcase (substr dir 1 (setq pos (vl-string-position 92 dir nil t))))
                )
                (setq itm
                    (cdr
                        (assoc (substr (strcase dir t) (+ pos 2))
                           '(
                                ("my documents" . "Documents")
                                ("my pictures"  . "Pictures")
                                ("my videos"    . "Videos")
                                ("my music"     . "Music")
                            )
                        )
                    )
                )
                (vl-file-directory-p (setq itm (strcat (substr dir 1 pos) "\\" itm)))
            )
            itm
        )
        (   dir   )
    )
)
(defun LM:getfiles:sort ( lst )
    (apply 'append
        (mapcar 'LM:getfiles:sortlist
            (vl-sort
                (LM:getfiles:groupbyfunction lst
                    (lambda ( a b / x y )
                        (and
                            (setq x (vl-filename-extension a))
                            (setq y (vl-filename-extension b))
                            (= (strcase x) (strcase y))
                        )
                    )
                )
                (function
                    (lambda ( a b / x y )
                        (and
                            (setq x (vl-filename-extension (car a)))
                            (setq y (vl-filename-extension (car b)))
                            (< (strcase x) (strcase y))
                        )
                    )
                )
            )
        )
    )
)
(defun LM:getfiles:sortlist ( lst )
    (mapcar (function (lambda ( n ) (nth n lst)))
        (vl-sort-i (mapcar 'LM:getfiles:splitstring lst)
            (function
                (lambda ( a b / x y )
                    (while
                        (and
                            (setq x (car a))
                            (setq y (car b))
                            (= x y)
                        )
                        (setq a (cdr a)
                              b (cdr b)
                        )
                    )
                    (cond
                        (   (null x) b)
                        (   (null y) nil)
                        (   (and (numberp x) (numberp y)) (< x y))
                        (   (numberp x))
                        (   (numberp y) nil)
                        (   (< x y))
                    )
                )
            )
        )
    )
)
(defun LM:getfiles:groupbyfunction ( lst fun / tmp1 tmp2 x1 )
    (if (setq x1 (car lst))
        (progn
            (foreach x2 (cdr lst)
                (if (fun x1 x2)
                    (setq tmp1 (cons x2 tmp1))
                    (setq tmp2 (cons x2 tmp2))
                )
            )
            (cons (cons x1 (reverse tmp1)) (LM:getfiles:groupbyfunction (reverse tmp2) fun))
        )
    )
)
(defun LM:getfiles:splitstring ( str )
    (
        (lambda ( l )
            (read
                (strcat "("
                    (vl-list->string
                        (apply 'append
                            (mapcar
                                (function
                                    (lambda ( a b c )
                                        (cond
                                            (   (member b '(45 46 92))
                                                (list 32)
                                            )
                                            (   (< 47 b 58)
                                                (list b)
                                            )
                                            (   (list 32 34 b 34 32))
                                        )
                                    )
                                )
                                (cons nil l) l (append (cdr l) '(( )))
                            )
                        )
                    )
                    ")"
                )
            )
        )
        (vl-string->list (strcase str))
    )
)
(defun LM:getfiles:browseforfolder ( msg dir flg / err fld pth shl slf )
    (setq err
        (vl-catch-all-apply
            (function
                (lambda ( / app hwd )
                    (if (setq app (vlax-get-acad-object)
                              shl (vla-getinterfaceobject app "shell.application")
                              hwd (vl-catch-all-apply 'vla-get-hwnd (list app))
                              fld (vlax-invoke-method shl 'browseforfolder (if (vl-catch-all-error-p hwd) 0 hwd) msg flg dir)
                        )
                        (setq slf (vlax-get-property fld 'self)
                              pth (LM:getfiles:fixdir (vlax-get-property slf 'path))
                        )
                    )
                )
            )
        )
    )
    (if slf (vlax-release-object slf))
    (if fld (vlax-release-object fld))
    (if shl (vlax-release-object shl))
    (if (vl-catch-all-error-p err)
        (prompt (vl-catch-all-error-message err))
        pth
    )
)
(defun LM:getfiles:full->relative ( dir path / p q )
    (setq dir (vl-string-right-trim "\\" dir))
    (cond
        (   (and
                (setq p (vl-string-position 58  dir))
                (setq q (vl-string-position 58 path))
                (/= (strcase (substr dir 1 p)) (strcase (substr path 1 q)))
            )
            path
        )
        (   (and
                (setq p (vl-string-position 92  dir))
                (setq q (vl-string-position 92 path))
                (= (strcase (substr dir 1 p)) (strcase (substr path 1 q)))
            )
            (LM:getfiles:full->relative (substr dir (+ 2 p)) (substr path (+ 2 q)))
        )
        (   (and
                (setq q (vl-string-position 92 path))
                (= (strcase dir) (strcase (substr path 1 q)))
            )
            (strcat ".\\" (substr path (+ 2 q)))
        )
        (   (= "" dir)
            path
        )
        (   (setq p (vl-string-position 92 dir))
            (LM:getfiles:full->relative (substr dir (+ 2 p)) (strcat "..\\" path))
        )
        (   (LM:getfiles:full->relative "" (strcat "..\\" path)))
    )
)
(defun LM:getfiles:str->lst ( str del / pos )
    (if (setq pos (vl-string-search del str))
        (cons (substr str 1 pos) (LM:getfiles:str->lst (substr str (+ pos 1 (strlen del))) del))
        (list str)
    )
)
(defun LM:getfiles:updatefilelist ( dir ext lst )
    (LM:getfiles:listbox "box1" (LM:getfiles:listfiles dir ext lst))
)
(defun LM:getfiles:updateselected ( dir lst )
    (LM:getfiles:listbox "box2" (mapcar '(lambda ( x ) (LM:getfiles:full->relative dir x)) lst))
    lst
)
(defun LM:getfiles:updir ( dir )
    (substr dir 1 (vl-string-position 92 dir nil t))
)
(defun LM:getfiles:fixdir ( dir )
    (vl-string-right-trim "\\" (vl-string-translate "/" "\\" dir))
)
(defun LM:getfiles:removeitems ( itm lst / idx )
    (setq idx -1)
    (vl-remove-if '(lambda ( x ) (member (setq idx (1+ idx)) itm)) lst)
)





(defun c:BasicBatchLisp ( / currentdrawing ThisDrawing batchdirectory batchfileslist l CommandsList
                            NextCommand acount acounter tempscript f)

;; Get Current Drawing
  (setq currentdrawing (strcat (getvar "dwgprefix")(getvar "dwgname"))) ;; get this drawing filepath abd name

;; Make Commands List
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Commands List Notes:
;;- write commands as if you were writing them in a LISP excluding start and end bracket ( )
;;  for example to draw a line (example usng an AutoCAD command example) 
;;  command "line" "0,0" "10,10" ""
;;  (no brackets)
;;  or for a LISP
;;  c:za
;;  remembering for LISPs to include the 'c:'
;;
;;- Note that in this the LISP routines have to be preloaded as the drawing opens, 
;;  I haven't added function to serch out and load LISPs on demand.
;;  There is no functionality in this to determine if commands are LISP, basic CAD
;;  commands or others
;;
;;- Commands can also be LISP commands and can even make up a LISP 'on thr fly' in each
;;c drawing if required which takes some thinking about
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (setq CommandsList (list) )                                           ;; a blank list
  (while (/= (setq NextCommand (getstring "Enter Next Command or ENTER to exit" T)) "")
    (setq CommandsList (append CommandsList (list NextCommand)))        ;; complete list with entered commands
  )

;; Run on this drawing
  (princ "\n")
  (initget "Y N YES NO Exit")                                           ;; limit options to yes / no / y / n
  (setq ThisDrawing (substr (strcase (getkword "Run on this drawing? [ Y N ]")) 1 1 )) ;; to get just Y or N

;;get files list from folder
  (setq batchfileslist (LM:getfiles "Choose Files" "" "dwg"))           ;; Fun LM:getfiles LISP

;;Create and open script file
  (setq acount 0) ;; a counter                                          ;; set a counter to 0 (in case used elsewhere)
  (setq tempscript (strcat (getvar "TEMPPREFIX") "tempbatchscrpt.scr")) ;; make temp script file (a text file)
  (setq f (open tempscript "w")) ;;open file                            ;; open script file to edit / write to

  (if (= ThisDrawing "Y")                                               ;; if modifying current drawing
    (progn                                                              ;; write these parts to script file
      (setq acounter 0)
      (while (< acounter (length CommandsList))
        (progn
          (write-line (strcat "(" (nth acounter CommandsList) ")" ) f)
          (setq acounter (+ acounter 1))
        ) ;;end progn
      ) ;;end for each x
    )
  )

 (foreach n batchfileslist                                              ;; loop through files list from above
   (progn
     (if (= (nth acount batchfileslist) currentdrawing)                 ;; exclude current drawing if it is in files list
       ()
       (progn                                                                 ;; script:
         (write-line (strcat "_.OPEN \"" (nth acount batchfileslist) "\"") f) ;; script to open the drawing
         (setq acounter 0)
         (while (< acounter (length CommandsList))                            ;; loop through commands list
          (progn
             (write-line (strcat "(" (nth acounter CommandsList) ")" ) f)     ;; write command to script file
             (setq acounter (+ acounter 1))
           ) ;;end progn
         ) ;;end for each x

        (write-line "(vla-save (vla-get-ActiveDocument (vlax-get-Acad-Object)))" f)  ;;script save command
        (write-line "(if (= dbmod 0)(command \".close\"))" f) ;;close the drawing    ;;script close drawing if no mods
        (write-line "(if (/= dbmod 0)(command \".close\" \"y\"))" f) ;;close the drawing  ;; or close drawing if mods
      ) ;;end progn
    ) ;;end if
   ) ;;end progn
   (setq acount (+ 1 acount))
 )  ;;end for each n
  (close f)

  (command "_.SCRIPT" tempscript) ;;run script
)

 

 

Posted

I'm new to lisp, haven't done programming since highschool 20 something years ago. Is there an online course I can do to improve in using lisp please?

 

I see the lisp, but have no idea of what I need to modify to get it to work the way I need to, and it's sending me a bit crosseyed.

Posted
12 hours ago, Wanda said:

I'm new to lisp, haven't done programming since highschool 20 something years ago. Is there an online course I can do to improve in using lisp please?

 

I see the lisp, but have no idea of what I need to modify to get it to work the way I need to, and it's sending me a bit crosseyed.

@Wanda

The solution I posted HERE works from my testing. All you need to do is make sure the lisp gets loaded at startup, then create a script calling (c:foo) using Lee's script writer and then run it.

  • 1 month later...
Posted
On 6/4/2024 at 10:57 PM, ronjonp said:

Using Lee's 'set dynamic block property value', run this code in a script:

(defun c:foo (/ s)
  ;; Set Dynamic Block Property Value  -  Lee Mac
  ;; Modifies the value of a Dynamic Block property (if present)
  ;; blk - [vla] VLA Dynamic Block Reference object
  ;; prp - [str] Dynamic Block property name (case-insensitive)
  ;; val - [any] New value for property
  ;; Returns: [any] New value if successful, else nil
  (defun lm:setdynpropvalue (blk prp val)
    (setq prp (strcase prp))
    (vl-some
      '(lambda (x)
	 (if (= prp (strcase (vla-get-propertyname x)))
	   (progn (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))
		  (cond	(val)
			(t)
		  )
	   )
	 )
       )
      (vlax-invoke blk 'getdynamicblockproperties)
    )
  )
  (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "PTA_STAMP_DYNAMIC,`*U*"))))
    (foreach o (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex s)))
      (if (= "PTA_STAMP_DYNAMIC" (strcase (vla-get-effectivename o)))
	(lm:setdynpropvalue o "Visibility1" "AS CONSTRUCTED")
      )
    )
  )
  (princ)
)

 

Hi, thanks for that. I've tried running it on a bunch of drawings, using Autoscript to trigger the lisp, but it's not working for me, the dynamic block remains as "detailed design".
I was just wondering if you would mind having a look and maybe giving me a step-by-step instruction please? Mum always said I was a bit "special" *facepalm"

Is it the load command? I do sometimes have trouble determining what the command should be to run a lisp.

I feel like I'm so close to getting this to work. Thanks!

Set Dynamic Block Property Value.LSP 00-G-10-0003 - PTA A1 DRG SHT.dwg ChangeStatusStamp.scr

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...