- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am attempting to auto update a user defined parameter named "PN" that is accessible within the block reference (quick properties) after each of the available dynamic block parameters changes . Whether it is a grip stretch or selection from a dropdown populated by the block table. I have what I believe is a completed Visual LISP script but I cannot seem to get it to run. first issue is when I use the APPLOAD command and load the LISP file and add it to the Startup Suite, and restart AutoCAD, when I check the Loaded Applications the LISP file is greyed out. I have placed the file in the default location "C:\Program Files\Autodesk\AutoCAD 2024\Support\en-us" as it is already a trusted file location and support file search path. This tells me that either this action is not possible thru this type of LISP function or I improperly setup the script or are missing critical components. Below is the script. I have also attached a DWG file with the block included to help understand the purpose of this script. Thank you to all in advanced who are able to shed some light on this. fyi, ChatGPT helped me put this together so I am sure there is lots to refine. I am a novice at LISP file creation.
(defun c:ShowBlockDims ( / ent obj dynprops leg1 leg2 thick getprop msg)
(vl-load-com)
;; Ask user to select a block reference
(if (setq ent (car (entsel "\nSelect a dynamic block: ")))
(progn
(setq obj (vlax-ename->vla-object ent))
(if (and (= (vla-get-objectname obj) "AcDbBlockReference")
(vlax-property-available-p obj 'EffectiveName)
(wcmatch (strcase (vla-get-EffectiveName obj)) "CA"))
(progn
(setq dynprops (vlax-invoke obj 'GetDynamicBlockProperties))
;; Helper to get dynamic prop by name
(defun getprop (name)
(vl-some
(function (lambda (p)
(if (eq (strcase (vla-get-PropertyName p)) (strcase name))
p)))
dynprops))
;; Get values
(setq leg1 (vla-get-value (getprop "LEG 1")))
(setq leg2 (vla-get-value (getprop "LEG 2")))
(setq thick (vla-get-value (getprop "THICKNESS")))
;; Show popup
(setq msg (strcat
"LEG 1: " (rtos leg1 2 4) "\\n"
"LEG 2: " (rtos leg2 2 4) "\\n"
"THICKNESS: " (rtos thick 2 4)))
(alert msg)
)
(prompt "\n[!] Not a valid 'CA' dynamic block.")
)
)
(prompt "\n[!] No block selected.")
)
(princ)
)
Solved! Go to Solution.