Is there a command that allows you to swap block locations.
In an ideal world I would love to be able to enter this command, select block 'A' then select block 'B' and have them swap locations.
Solved! Go to Solution.
Solved by p_mcknight. Go to Solution.
Follow this link:
Edited by
Discussion_Admin
Another method without additional routine is this:
Use command BLOCKREPLACE in Express Tools to replace
1. Create a temporary Block C
2. Replace all Block A with Block C
3. Replace all Block B with Block A
4. Replace all Block C with Block B
5. Delete and purge Block C
A dirty workaround would be to draw a line between the insertion points of both blocks.
Then move both blocks at the same time to one end of the line. Then move the block which is left hanging to the other end of the line.
Or go into properties for each block one at a time, and note their x,y,z positions.
Then go into properties again and swap the x,y,z positon of the block you've chosen for the other block.
Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
@Patchy wrote:
Follow this link:
....
Here's a more sophisticated version than what I posted there. This one is tailored specifically to INSERT objects, has some selection controls, and uses a different method to move them, so there's no command echoing to deal with.
If you don't want it to accept other kinds of INSERT objects than Blocks [Xrefs, Minserts, Windows Metafiles, old-style Hatch patterns], additional controls could be added.
The below code makes a command 'swap' to swap two block locations. The blocks will inherit any mirroring, rotation, scaling, etc of the block they are being swapped with. You may select the two blocks before executing the command or after.
(defun c:swap ( / objs vlobj1 vlobj2 block1Name block2Name)
(setq objs (ssget))
(if (= 2 (sslength objs))
(progn
(setq vlobj1 (vlax-ename->vla-object (ssname objs 0)))
(setq vlobj2 (vlax-ename->vla-object (ssname objs 1)))
(if (and (= "AcDbBlockReference" (vla-get-ObjectName vlobj1)) (= "AcDbBlockReference" (vla-get-ObjectName vlobj2)))
(progn
(setq block1Name (vla-get-Name vlobj1))
(setq block2Name (vla-get-Name vlobj2))
(vla-put-name vlobj1 block2Name)
(vla-put-name vlobj2 block1Name)
)
(alert "One or more selected item is not a block. ")
)
)
(alert "More or less than two objects are selected. ")
)
(princ)
)