itacad Posted April 10, 2021 Share Posted April 10, 2021 Hi, I think I found the lisp that I am attaching on this forum. It is a very useful lisp, it allows you to move two blocks between them, swapping their positions, using the insertion point of both. Unfortunately it has the limitation that it only works with blocks. Could it be correct to swap the position of all objects that have an insertion point? thank you very much SWAP.LSP 1 Quote Link to comment Share on other sites More sharing options...
rlx Posted April 10, 2021 Share Posted April 10, 2021 UU (utterly untested) (defun c:swap ( / ss l) (vl-load-com) (princ "\nSelect 2 objects with insertionpoint : ") (cond ((not (setq ss (ssget "_:L")))(alert "Selection cancelled")) ((not (= 2 (sslength ss))) (alert (strcat "You selected " (sslength ss) " objects"))) ((not (vl-every 'vl-consp (setq l (mapcar '(lambda (i)(getip (vlax-ename->vla-object (ssname ss i)))) '(0 1))))) (alert "Insertionpoint error")) (t (putip (cadar l) (caadr l)) (putip (cadadr l) (caar l))))(princ)) (defun getip (o) (cond ((vlax-property-available-p o 'TextAlignmentPoint) (if (= (vla-get-alignment o) 0)(list (vla-get-InsertionPoint o) o)(list (vla-get-TextAlignmentPoint o) o))) ((vlax-property-available-p o 'InsertionPoint)(list (vla-get-InsertionPoint o) o)))) (defun putip (o p) (if (and (vlax-property-available-p o 'TextAlignmentPoint)(/= (vla-get-alignment o) 0)) (progn (vla-put-insertionpoint o p)(vla-put-TextAlignmentpoint o p))(vla-put-insertionpoint o p))) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 10, 2021 Share Posted April 10, 2021 (edited) Not sure how many objects have a Insertion point may be better as a series of defuns could swap a line and a block. Just thinking Block Insertion point *Text has as suggested alignment point Arc & Circle centre point Line start pt, mid , end Pline 1st vertice or (GC) hatch has a pt Need Itacad to narrow down what is to be swapped and the rules. Edited April 10, 2021 by BIGAL Quote Link to comment Share on other sites More sharing options...
rlx Posted April 11, 2021 Share Posted April 11, 2021 (edited) inspoint prop accoording to active-x reference Edited April 11, 2021 by rlx Quote Link to comment Share on other sites More sharing options...
itacad Posted April 11, 2021 Author Share Posted April 11, 2021 Hello and thanks in the meantime. By insertion point I meant what is considered such by the object snap. For example, texts have an insertion point...for other types of objects (lines, polygons, etc.) I don't need them. Greetings Quote Link to comment Share on other sites More sharing options...
devitg Posted April 13, 2021 Share Posted April 13, 2021 (edited) @itacad, maybe some like it (setq ss (ssget "_:L" '((0 . "INSERT,metxt,text")))) Maybe you will need to check if selection hold same entities kind , Edited April 13, 2021 by devitg Quote Link to comment Share on other sites More sharing options...
rlx Posted April 13, 2021 Share Posted April 13, 2021 i realy like the ,metxt, part 1 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 13, 2021 Share Posted April 13, 2021 *TEXT Quote Link to comment Share on other sites More sharing options...
devitg Posted April 14, 2021 Share Posted April 14, 2021 My typo fault , ..... Quote Link to comment Share on other sites More sharing options...
itacad Posted April 15, 2021 Author Share Posted April 15, 2021 ...Srry but I did not understand the suggestion of devitg... ...I tried to replace the line of code but it doesn't work ... regards Quote Link to comment Share on other sites More sharing options...
devitg Posted April 15, 2021 Share Posted April 15, 2021 This line , if it is typed correctly, allow to select BLOCKREFERENCE [INSERT], MTEXT,TEXT (setq ss (ssget "_:L" '((0 . "INSERT,MTEXT,TEXT")))) Quote Link to comment Share on other sites More sharing options...
itacad Posted April 17, 2021 Author Share Posted April 17, 2021 Great! it works just how I need it! Thanks so much! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.