CAD Forums > Dynamic Blocks

Match State

(1/3) > >>

M-dub:
I'm wondering if there's some kind of function similar to MATCHPROP where it would allow you to match the state of dynamic blocks.  Select a source block and then, the destination blocks.  As long as the blocks are all the same name, it would... match the state.

Lee Mac:
Here is a quick hack, but should work as required:

--- Code: ---;; Match Dynamic Block Properties  -  Lee Mac
;; Matches all dynamic block properties from a selected source dynamic block
;; to all selected destination dynamic blocks of the same name.

(defun c:dynmatch ( / blk des inc obj prp src )
    (while
        (progn (setvar 'errno 0) (setq src (car (entsel "\nSelect Source Dynamic Block: ")))
            (cond
                (   (= 7 (getvar 'errno))
                    (princ "\nMissed, try again.")
                )
                (   (= 'ename (type src))
                    (cond
                        (   (/= "INSERT" (cdr (assoc 0 (entget src))))
                            (princ "\nObject is not a block.")
                        )
                        (   (= :vlax-false (vla-get-isdynamicblock (setq src (vlax-ename->vla-object src))))
                            (princ "\nBlock is not dynamic.")
                        )
                    )
                )
            )
        )
    )
    (if
        (and (= 'vla-object (type src))
            (setq des
                (LM:ssget "\nSelect Destination Dynamic Blocks: "
                    (list "_:L"
                        (list '(0 . "INSERT")
                            (cons 2
                                (strcat "`*U*,"
                                    (setq blk (strcase (vla-get-effectivename src)))
                                )
                            )
                        )
                    )
                )
            )
            (setq prp
                (mapcar 'vla-get-value
                    (vlax-invoke src 'getdynamicblockproperties)
                )
            )
        )
        (repeat (setq inc (sslength des))
            (setq obj (vlax-ename->vla-object (ssname des (setq inc (1- inc)))))
            (if (= (strcase (vla-get-effectivename obj)) blk)
                (mapcar
                    (function
                        (lambda ( a b )
                            (if (/= "ORIGIN" (strcase (vla-get-propertyname a)))
                                (vla-put-value a b)
                            )
                        )
                    )
                    (vlax-invoke obj 'getdynamicblockproperties)
                    prp
                )
            )
        )
    )
    (princ)
)

;; ssget  -  Lee Mac
;; A wrapper for the ssget function to permit the use of a custom selection prompt
;;
;; Arguments:
;; msg    - selection prompt
;; params - list of ssget arguments

(defun LM:ssget ( msg params / sel )
    (princ msg)
    (setvar 'nomutt 1)
    (setq sel (vl-catch-all-apply 'ssget params))
    (setvar 'nomutt 0)
    (if (not (vl-catch-all-error-p sel)) sel)
)

(vl-load-com) (princ)
--- End code ---

M-dub:
Nice-Lee Done! (yes, I said that...)  That's fantastic!  :)
I have some people who often forget to set certain properties and this makes it quick and easy to fix their work.

Thanks!

TimSpangler:
Select the block
<right click> / Select Similar
Properties
Change the state

?

M-dub:

--- Quote from: TimSpangler on April 19, 2013, 12:45:20 PM ---Select the block
<right click> / Select Similar
Properties
Change the state

?

--- End quote ---

Way to make me feel like an idiot, Tim. :P


Kidding!  Well, half kidding, anyway.


I should've thought to try that.  Duh...

Navigation

[0] Message Index

[#] Next page

Go to full version