Jump to content

NESTED BLOCK COPY


jim78b

Recommended Posts

i have to modify this lisp because not work 100% please.

It must work with all type of blocks even non uniform scaled. i try it but not work with non uniform scaled block.

I want even that i do a multiple selection

#NESTED BLOCKS COPY WITHOUT OPEN IT
(defun c:cx (/ *error* space ss nent br copy)
  (vl-load-com)
  (or *acad* (setq *acad* (vlax-get-acad-object)))
  (or *acdoc* (setq *acdoc* (vla-get-ActiveDocument *acad*)))

  (defun *error* (msg)
    (and msg
         (/=(strcase msg) "FUNCTION CANCELLED")
         (princ (strcat "\nError: " msg))
    )
    (vla-EndUndoMark *acdoc*)
    (princ)
  )

  (vla-StartUndoMark *acdoc*)
  (setq space (if (= 1 (getvar 'cvport))
                (vla-get-PaperSpace *acdoc*)
                (vla-get-ModelSpace *acdoc*)
              )
  )
  (setq ss (ssadd))
  (while (and (setq nent (nentselp "\nSelect a nested block: "))
              (= 4 (length nent))
              (= "AcDbBlockReference" (vla-get-ObjectName (setq br (vlax-ename->vla-object (car (last nent))))))
              (apply '= (mapcar 'abs (list (vla-get-XScaleFactor br) (vla-get-YScaleFactor br) (vla-get-ZScaleFactor br))))
         )
    (setq copy (vla-insertblock space (vlax-3d-point '(0 0 0)) (vla-get-Name br) 1.0 1.0 1.0 0.0))
    (vla-TransformBy copy (vlax-tmatrix (caddr nent)))
    (vla-Highlight copy :vlax-true)
    (ssadd (vlax-vla-object->ename copy) ss)
  )
  (command "_.move" ss "")
  (*error* nil)
)

 

Link to comment
Share on other sites

9 hours ago, Tharwat said:

Comment or delete this line.


(apply '= (mapcar 'abs (list (vla-get-XScaleFactor br) (vla-get-YScaleFactor br) (vla-get-ZScaleFactor br))))

 

 

I was about to say what Lee said... he beat me to it...

 

But it's an interesting challenge, I'll think about it.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...