Hi
I have a simple dynamic block for a break line with one dynamic parameter called "length". I want to use this inside a lisp routine which allows me to do the following
While I am able to create a lisp routine to draw break line by manually asking for size of break, I would like to do it in a way that I can visually size the break point by using the dynamic block. I have also included that lisp routine along with the block for the dynamic break point.
I can insert the dynamic block using the parameters from 5 to 7 but dont know how to modify the lenght parameter from within a lisp routine.
Please help
Thanks
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
Try the following code akshay:
(defun c:brkline ( / *error* blk bln dwg obj pt1 pt2 val var ) (defun *error* ( msg ) (mapcar 'setvar var val) (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))) (princ (strcat "\nError: " msg)) ) (princ) ) (setq bln "BRKLINE" var '(cmdecho attreq) val (mapcar 'getvar var) ) (mapcar 'setvar var '(0 0)) (cond ( (not (or (tblsearch "block" (setq blk bln)) (and (setq dwg (findfile (strcat bln ".dwg"))) (progn (command "_.-insert" dwg nil) (tblsearch "block" (setq blk bln)) ) ) ) ) (princ (strcat "\nBlock \"" bln "\" not found.")) ) ( (and (setq pt1 (getpoint "\nSpecify 1st point: ")) (setq pt2 (getpoint "\nSpecify 2nd point: " pt1)) ) (prompt "\nSpecify scale factor: ") (initcommandversion) (if (and (vl-cmdf "_.-insert" blk "_r" (* 180.0 (/ (angle pt1 pt2) pi)) "_non" (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) pt1 pt2) "\\" ) (setq obj (entlast)) (setq obj (vlax-ename->vla-object obj)) (= "AcDbBlockReference" (vla-get-objectname obj)) (= :vlax-true (vla-get-isdynamicblock obj)) ) (LM:setdynpropvalue obj "length" (distance pt1 pt2)) ) ) ) (*error* nil) (princ) ) ;; 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) ) ) (vl-load-com) (princ)
The Set Dynamic Block Property Value function is part of my set of Dynamic Block Functions.
Lee
Hi Lee_Mac:
Thank you so much for taking the time to prepare this routine for me. I am highly obliged.
I was initially getting an error because i had saved the dynamic block inside another drawing but sorted it out once I saved the block definition as a drawing file.
For others wanting to use this routine, I have attached the dynamic block reference brkline.dwg that they can make part of their library with this message. You may have to rename brkline to another name if you have express tools installed as the tools also contain a dwg named brkline which can cause some errors.
Thank you so much for taking the time to prepare this routine for me. I am highly obliged.
You're most welcome akshay, I'm pleased that the program is working well for you & I appreciate your gratitude.
Lee
As always Lee Mac's routines are awesome! Sorry for some grammar error because I do not speak English, I use the google translator.