Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Insert, rotate, and manipulate stretch action between two points

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
RockyBrown4134
888 Views, 5 Replies

Insert, rotate, and manipulate stretch action between two points

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.

 

 

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
5 REPLIES 5
Message 2 of 6
hmsilva
in reply to: RockyBrown4134

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

 

EESignature

Message 3 of 6
RockyBrown4134
in reply to: hmsilva

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.

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
Message 4 of 6
hmsilva
in reply to: RockyBrown4134


@RockyBrown4134 wrote:

I had to change the endpoint variable in two places.

 ...


Sorry about the variable "endpt", I'm getting too old... Smiley Happy

 

You're welcome, RockyBrown
Glad I could help

 

Henrique

EESignature

Message 5 of 6
Anonymous
in reply to: hmsilva

Oh but you are growing so wise in your old age henrique 🙂

Message 6 of 6
hmsilva
in reply to: Anonymous


@Anonymous wrote:

Oh but you are growing so wise in your old age henrique 🙂


Happy New Year, Brandon!  Smiley Happy

 

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost