Based on this:
@cherrygate wrote:
Yes, the objects being moved will ALWAYS be the same circle block I attached in the DWG and they will move away from the pline/line work
Here's my take. You can update the "getAwayDist" variable to any number you'd like.
(defun c:GETAWAY ( / ssBlocks ssLwork getAwayDist cnt lwList blk eg pBase pTemp pClose minDist tmpDist)
(vl-load-com)
(if (and (setq ssBlocks (ssget '((0 . "INSERT") (2 . "Import"))))
(setq ssLwork (ssget '((0 . "LWPOLYLINE,LINE,ARC"))))
);and
(progn
(setq getAwayDist 25)
;; Get linework entity names for later
(repeat (setq cnt (sslength ssLwork))
(setq lwList (cons (ssname ssLwork (setq cnt (1- cnt))) lwList))
);repeat
;; For each blk, determine closest line, then move to 'getAwayDist'
(repeat (setq cnt (sslength ssBlocks))
(setq blk (ssname ssBlocks (setq cnt (1- cnt))))
(setq eg (entget blk))
(setq pBase (cdr (assoc 10 eg)))
(setq minDist nil)
;; Determine closest line point
(foreach lw lwList
(setq pTemp (vlax-curve-getclosestpointto lw pBase))
(setq tmpDist (distance pBase pTemp))
(if (or (not minDist)
(< tmpDist minDist)
);or
(setq minDist tmpDist pClose pTemp)
);if
);foreach
;; Move to 'getAwayDist'
(vla-move
(vlax-ename->vla-object blk)
(apply 'vlax-3d-point pBase)
(apply 'vlax-3d-point (polar pClose (angle pClose pBase) getAwayDist))
);vla-move
);repeat
(prompt "\nGETAWAY Complete.")
);progn
;else
(prompt "\nOne or Both selection sets were bad.")
);if
(princ)
);defun
-- EDIT --
Some Notes:
- This will always move the block to the "getAwayDist".. so even blocks further away will be moved closer.
- This does not account for other intersecting/near linework (as discussed by others previously).
Best,
~DD