Jump to content

Recommended Posts

Posted

Hello, I use a very powerful lisp that I attach and that allows the exchange of position (swap) between two objects.

I recommend it because it speeds up one of the repetitive operations typical of Autocad.

I ask you if it can be changed from:
- Swap object 1 with object 2
to
- Replace object 2 by deleting it, with a copy of object 1 (i.e. I would like to click on object 1 first, then on object 2)

 

I already use lisps that do this function just as conveniently but work exclusively with blocks (e.g. ReplaceBlock that I attach), I would like to have one that does this function with almost all objects like Swap.lsp

 

Thanks in advance

 

swap.lspReplaceBlock.lsp

Posted

You want it to work for other types of objects, other than blocks.

 

The issue is: not all types of objects heve the properties you need.

Text objects don't have a scale, they have a text height.

Lines don't have a position, they have 2 insertpoints.

...

 

-----------

Anyway, I think this does the most generic version of copying an object

and pasting it to the position of selected destination objects.

 

(defun c:BRE2 ( / src src_ dest ss i temp)
	(princ "\nSelect source object: ")
	(setq src_ (vlax-ename->vla-object (setq src (car (entsel)))))

	
	(princ "\nSelect objects to be repalced: ")
    (setq ss (ssget "_:L" '((0 . "*"))))
	(setq i 0)
	(repeat (sslength ss)
		(setq dest (ssname ss i))
		(setq temp (vla-copy src_))		;; copy source
		(vla-move temp 			;; move the copy to the destination
			 (vlax-3d-point (cdr (assoc 10 (entget src))))
			 (vlax-3d-point (cdr (assoc 10 (entget dest))))
		)
		(entdel dest)
		(setq i (+ i 1))
	)
	
)

 

Do you need this to do more?

 

 

  • Like 1
Posted

I think I understand what you mean, but I think it's not a problem, because in my imagination I thought of using this command to replace object type with the same object type, even if I just tried it and I see that it works with different objects, moreover it also has the possibility to replace a series of objects after selecting the one to use as "master".

At first glance it seems exactly what I needed and I think I will definitely add it to my favorite lisps!
Thank you!

  • Like 1

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