All;
I need some help please. Here is what I want to do. I need a simple lisp routine to Insert a Dynamick block between two points and change the stretch action parameter to br the total distance between two points. I am trying to update and older lisp program that was written in LISP, not VLISP.
Here is the code I have been using to insert a standard block between two points, after I have selected the basepoint (basept) and end point (endpt):
(command "-insert" "5x18b" basept "" "" endpt)
The block has a strectch parameter with a minimum distance of 31" and a maximum distance of 49". The property name for the linear parameter will be OVL.
I think what I want to do is get the last enity, and change the value of the stretch parameter. I know I must be looking over something simple.
Is there an easy way to do this?
Thanks for your help in advance.
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Untested...
Perhaps something like this.
(defun c:test ( / BASEPT BLK DIST ENDPT) ;; by Allen Johnson ??? (defun chgdynprop (e propname newval / obj sal prp) (setq obj (if (= (type e) 'vla-object) e (vlax-ename->vla-object e))) (if (= (vlax-get-property obj 'isdynamicblock) :vlax-true) (progn (setq sal (vlax-safearray->list(vlax-variant-value (vla-getdynamicblockproperties obj)))) (setq prp (vl-remove-if-not (function (lambda(x)(= (vlax-get-property x 'PropertyName) propname))) sal)) (mapcar (function (lambda(v) (if (vlax-property-available-p v 'Value) (progn (vlax-put-property v 'Value newval)(vla-update obj)) ))) prp) ) ) );; chgdynprop (if (and (setq basept (getpoint "\nPick Base Point: ")) (setq endpt (getpoint "\nPick End Point: ")) );; and (progn (setq dist (distance basept basept)) (cond ((< dist 31) (setq dist 31)) ((> dist 49) (setq dist 49)) );; cond (command "-insert" "5x18b" basept "" "" basept) (setq blk (entlast)) (chgdynprop (vlax-ename->vla-object blk) "OVL" dist) );; progn );; if );; test
HTH
Henrique
I had to change the endpoint variable in two places. Works like I expected.
(if (and (setq basept (getpoint "\nPick Base Point: "))
(setq endpt (getpoint "\nPick End Point: "))
);; and
(progn
(setq dist (distance basept endpt))
(cond ((< dist 31) (setq dist 31))
((> dist 49) (setq dist 49))
);; cond
(command "-insert" "5x18b" basept "" "" endpt)
(setq blk (entlast))
(chgdynprop (vlax-ename->vla-object blk) "OVL" dist)
);; progn
);; if
Thanks for the help and education.
@RockyBrown4134 wrote:
I had to change the endpoint variable in two places.
...
Sorry about the variable "endpt", I'm getting too old...
You're welcome, RockyBrown
Glad I could help
Henrique