Change dynamic block grip using coordinates

Change dynamic block grip using coordinates

Amriya_Exe
Advocate Advocate
625 Views
8 Replies
Message 1 of 9

Change dynamic block grip using coordinates

Amriya_Exe
Advocate
Advocate

I Have dynamic Block with 9 Grips of Stretch and Move parameters. other side I have 9 coordinates on alignment I have to adjust 9 Grips on this coordinates. its possible to complete this job using any script or Lips?

0 Likes
626 Views
8 Replies
Replies (8)
Message 2 of 9

hak_vz
Advisor
Advisor

Maybe with .net, but not with lisp as far as I know!

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 9

Sea-Haven
Mentor
Mentor

Depending on the block if we look at say "Distance1 which might have a grip at 1 end so changing a length, then yes can set "Distance1" via lisp. 

 

1st step is download Lee-mac Dynamic Block lisps.

 

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

(setq blk (vlax-ename->vla-object (entlast)))
(LM:setdynpropvalue blk "Width" wid)
(LM:setdynpropvalue blk "Height" ht )

 

 

0 Likes
Message 4 of 9

Amriya_Exe
Advocate
Advocate
This is LISP or Script?
how to use this?
On
Lee-mac Dynamic Block site I found this

;; Set Dynamic Block Properties - Lee Mac
;; Modifies values of Dynamic Block properties using a supplied association list.
;; blk - [vla] VLA Dynamic Block Reference object
;; lst - [lst] Association list of ((<Property> . <Value>) ... )
;; Returns: nil

(defun LM:setdynprops ( blk lst / itm )
(setq lst (mapcar '(lambda ( x ) (cons (strcase (car x)) (cdr x))) lst))
(foreach x (vlax-invoke blk 'getdynamicblockproperties)
(if (setq itm (assoc (strcase (vla-get-propertyname x)) lst))
(vla-put-value x (vlax-make-variant (cdr itm) (vlax-variant-type (vla-get-value x))))
)
)
)

But dont know how to use
0 Likes
Message 5 of 9

komondormrex
Mentor
Mentor

a sample of before and after could be useful to apprehend whether lisp can be of help

0 Likes
Message 6 of 9

Amriya_Exe
Advocate
Advocate

@komondormrex  Please check attached file for detailed information.

I want to move all Five Grips on this coordinates automatic

16.6132,136.0869
13.7663,145.7196
10.9492,155.2514
8.1632,164.6781
19.3787,126.73

0 Likes
Message 7 of 9

ВeekeeCZ
Consultant
Consultant

You can use this simple lisp.

 

BUT you need to redefine your block so it's not such a mess. See the drawing, there are labeled dimensions, that way you need to redefine your block. The routine does not set coordinates but distances between points.

 

(vl-load-com)

(defun c:Trailins ( / p e s l) (princ "\nSelect points, ") (if (and (setq s (ssget '((0 . "POINT")))) (not (command "_.-insert" "trail" "_s" 1 pause pause)) (setq p (getvar 'lastpoint)) (setq e (entlast)) (setq l (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))) (setq l (mapcar '(lambda (x) (cdr (assoc 10 (entget x)))) l)) (setq l (vl-sort l '(lambda (x1 x2) (< (distance p x1) (distance p x2))))) (setq l (mapcar '(lambda (x1 x2) (distance x1 x2)) (cons p l) l)) ;(princ l) ) (mapcar '(lambda (p x) (vl-catch-all-apply 'setpropertyvalue (list e (strcat "AcDbDynBlockPropertyDistance" p) x))) '("1" "2" "3" "4" "5") l)) (princ) )

 

0 Likes
Message 8 of 9

Amriya_Exe
Advocate
Advocate

I tried above lisp and result is as below

Its not falling on the points I selecting.

Amriya_Exe_0-1709572448508.png

 

0 Likes
Message 9 of 9

Amriya_Exe
Advocate
Advocate

Solution Please

0 Likes