Reinsert dynamic blocks and copy over attributes and parameter

Reinsert dynamic blocks and copy over attributes and parameter

Anonymous
Not applicable
384 Views
0 Replies
Message 1 of 1

Reinsert dynamic blocks and copy over attributes and parameter

Anonymous
Not applicable

Hello everyone! Smiley Happy

 

Found this code from the forums by Lee Mac that reinsert blocks. The routine works well and really close to what I intend to accomplish but I need the blocks reinserted as the original coordinates for each block and copy over all attributes and parameter settings including visibility. Please help....Thanks in advance!

 

(defun c:ReInsertAll (/ GetName Blocks ss Model Var Obj)
  (vl-load-com)

  (setq GetName (lambda (obj) (if (vlax-property-available-p obj 'EffectiveName)
                                (vla-get-EffectiveName obj)
                                (vla-get-Name obj))))

  (if (ssget "_X" '((0 . "INSERT") (410 . "Model")))
    (progn
      (vlax-for obj (setq ss (vla-get-ActiveSelectionSet
                               (setq doc (vla-get-ActiveDocument
                                           (vlax-get-acad-object)))))

        (setq Blocks
          (cons
            (list (GetName obj) obj
                  (if (eq :vlax-true (vla-get-HasAttributes obj))
                    (mapcar
                      (function
                        (lambda (attrib) (cons (vla-get-TagString attrib)
                                               (vla-get-TextString attrib))))
                      
                      (vlax-invoke obj 'GetAttributes))))

            Blocks)))
      
      (vla-delete ss)
      (setq Model (vla-get-ModelSpace doc) Var (vlax-3D-point '(0 0 0)))

      (foreach x Blocks
        (setq Obj (vla-InsertBlock Model Var (car x) 1. 1. 1. 0.))
        (vla-delete (cadr x))
        
        (if (and (caddr x)
                 (eq :vlax-true (vla-get-HasAttributes Obj)))
          
          (foreach att (vlax-invoke obj 'GetAttributes)
            (if (setq tag (assoc (vla-get-TagString att) (caddr x)))
              (vla-put-TextString att (cdr tag))))))))        
  
  (princ))

 

0 Likes
385 Views
0 Replies
Replies (0)