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

blcoks not selected if modified by dynamic parameter

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
robert06
436 Views, 6 Replies

blcoks not selected if modified by dynamic parameter

I have a simple script to select blocks by name and move them to a layer. What should be added to include in selection set also blocks that have been modified by a dynamic parameter (blocks that have been scaled, rotated etc from dynamic parameter grips).

 


(defun c:xx2yy ()
        (prompt "\move blocks xx to layer "yy")(terpri)
    (setq Blks (ssget "_x" '((0 . "insert")(2 . "xx"))))
    (command "chprop" "p" "" "la" "yy" "")
    (princ)
)

thanks!

6 REPLIES 6
Message 2 of 7
hmsilva
in reply to: robert06

Robert

 

try

(defun c:xx2yy ( / BLKN BLKS HND I XXBLKS)
  (prompt "\nmove blocks xx to layer yy")
  (if (setq blks (ssget "_x" (list '(0 . "insert") (cons 2 "xx,`*U*"))))
    (progn
      (setq i	   0
	    xxblks (ssadd)
      );; setq
      (while (setq hnd (ssname blks i))
	(setq blkn (vla-get-effectivename (vlax-ename->vla-object hnd)))
	(if (wcmatch blkn "xx")
	  (ssadd hnd xxblks)
	);; if
	(setq i (1+ i))
      );; while
      (if xxblks
	(command "chprop" xxblks "" "la" "yy" "")
      );; if
    );; progn
  );; if
  (princ)
);; xx2yy

 

HTH

Henrique

EESignature

Message 3 of 7
robert06
in reply to: hmsilva

Many thanks!

Message 4 of 7
Lee_Mac
in reply to: robert06

In addition to Henrique's excellent suggestion, the following code will be compatible with earlier versions of AutoCAD (in which there is no ActiveX effectivename property) and will also process blocks which reside in all layouts (not just the current space):

 

(defun c:xx2yy ( / e i s x )
    (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "`*U*,xx"))))
        (repeat (setq i (sslength s))
            (setq e (ssname s (setq i (1- i)))
                  x (entget e)
            )
            (if (= "xx" (LM:blockname (vlax-ename->vla-object e)))
                (entmod (subst '(8 . "yy") (assoc 8 x) x))
            )
        )
    )
    (princ)
)

;; Block Name  -  Lee Mac
;; Returns the true (effective) name of a supplied block reference
                        
(defun LM:blockname ( obj )
    (if (vlax-property-available-p obj 'effectivename)
        (defun LM:blockname ( obj ) (vla-get-effectivename obj))
        (defun LM:blockname ( obj ) (vla-get-name obj))
    )
    (LM:blockname obj)
)
(vl-load-com) (princ)
Message 5 of 7
hmsilva
in reply to: Lee_Mac


@Smiley HappyLee_Mac wrote:

...

the following code will be compatible with earlier versions of AutoCAD (in which there is no ActiveX effectivename property)

...


Nice thinking, Lee Smiley Happy

 

@ robert06

 

You're welcome, Robert
Glad i could help

 

Henrique

 

EESignature

Message 6 of 7
Lee_Mac
in reply to: hmsilva


@hmsilva wrote:

@Smiley HappyLee_Mac wrote:

...

the following code will be compatible with earlier versions of AutoCAD (in which there is no ActiveX effectivename property)

...


Nice thinking, Lee Smiley Happy


Thank you Henrique - enjoy your weekend! Smiley Happy

Message 7 of 7
hmsilva
in reply to: Lee_Mac


@Lee_Mac wrote:
...
enjoy your weekend! Smiley Happy

Thank you Lee Smiley Happy


But this weekend will be work, work and work...
I have a deadline to meet Monday, therefore no weekend...

 

Cheers
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