notview Posted February 23, 2013 Posted February 23, 2013 Anybody can make a lisp program: Move objects with a base point from Mid between two points, then move and paste to Mid between two points. Thanx! Quote
marko_ribar Posted February 23, 2013 Posted February 23, 2013 Just use "_m2p" OSNAP... Type command OSNAP and turn snaps to for ex. "_int", "_mid", "_end" and turn on check for activation - or press F3... Then when you want to move, type MOVE, select object(s), when asked for first point, ctrl+right mouse click, find "_m2p" OSNAP, pick first helper point, pick second helper point (remember that now these points are helpers and picking reactor reacts according to previously set OSNAP - so real picked point will be mid between these two helper picked points), and finally when asked for destination point, do the same as with first source point... Object(s) will be moved as your request... Quote
MSasu Posted February 23, 2013 Posted February 23, 2013 You may instead resort to M2P command modifier; it will allow you to get the middle point between two picked points. By the way, by posting the same thread twice you will just split the discussion; please ask a Moderator to join them. Thank you. Quote
notview Posted February 23, 2013 Author Posted February 23, 2013 Sometimes, that's the way I did, but if there is another way to do just in one command, in a lisp who can do for it, I really appreciate it. Quote
Lee Mac Posted February 23, 2013 Posted February 23, 2013 (defun c:mm2p ( / p1 p2 p3 p4 ss ) (if (and (setq ss (ssget "_:L")) (setq p1 (getpoint "\n1st Point of Mid for Basepoint: ")) (setq p2 (getpoint "\n2nd Point of Mid for Basepoint: ")) (setq p3 (getpoint "\n1st Point of Mid for Next point: ")) (setq p4 (getpoint "\n2nd Point of Mid for Next point: ")) ) (command "_.move" ss "" "_non" (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) p1 p2) "_non" (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) p3 p4) ) ) (princ) ) Quote
notview Posted February 23, 2013 Author Posted February 23, 2013 Thank you Lee!! This is what I really want. Simple routine but great!! Quote
Paraglide1 Posted March 14, 2013 Posted March 14, 2013 Lee, Your web postings have been and are a great help to me. There is a new snap, MTP, that snaps to the midpoint between any two points. Any type of point input is allowed (including other snaps, e.g. int,app,cen,etc.). It is in 2013 but I don't know in which version it was first introduced. Since it is not lisp based but an input option it can be used during the execution of any lisp routine. Quote
ReMark Posted March 14, 2013 Posted March 14, 2013 Re: MTP. It's a command modifier and can be invoked within a command by typing MTP or M2P. Works both ways. I think someone already mentioned this. Quote
Biscuits Posted March 14, 2013 Posted March 14, 2013 I modified my "F1" key in the CUI to iniate M2P and use it like an osnap. No need for special codes. I use it to center text in BOM cells, etc. Quote
Paraglide1 Posted March 14, 2013 Posted March 14, 2013 Just replying to Lee in case he had not heard of MTP ... but upon closer inspection his code is to use two midpoints to move something as the OP had asked for. I wondered why an expert like Lee would not have known about MTP (or M2P). My eyesight is going along with my memory (and a few other things). I saw Lee defun-ing c:m2p instead of c:mm2p. It was just me not paying close enough attention. My apologies Lee. Quote
ReMark Posted March 14, 2013 Posted March 14, 2013 Lee is more of a programmer than a day-to-day AutoCAD user. Most of us prefer it that way as his custom lisp routines have often saved us from ourselves and saved the day as well. 1 Quote
SLW210 Posted March 14, 2013 Posted March 14, 2013 Pretty awesome there Lee Mac, that's one I will use a lot. Quote
Lee Mac Posted March 14, 2013 Posted March 14, 2013 Lee,Your web postings have been and are a great help to me. There is a new snap, MTP, that snaps to the midpoint between any two points. Any type of point input is allowed (including other snaps, e.g. int,app,cen,etc.). It is in 2013 but I don't know in which version it was first introduced. Since it is not lisp based but an input option it can be used during the execution of any lisp routine. Just replying to Lee in case he had not heard of MTP ... but upon closer inspection his code is to use two midpoints to move something as the OP had asked for. I wondered why an expert like Lee would not have known about MTP (or M2P). My eyesight is going along with my memory (and a few other things). I saw Lee defun-ing c:m2p instead of c:mm2p. It was just me not paying close enough attention. My apologies Lee. No apologies necessary Henry, I can certainly see the source of the misunderstanding. To clarify, I am aware of the mtp / m2p function, however, I will almost always opt to perform my own geometrical calculations within my programs over reliance on command modifiers, the geomcal utility, or any Express Tools. Of course as you know, the program could equally be written: (defun c:mm2p ( / ss ) (if (setq ss (ssget "_:L")) (command "_.move" ss "" "m2p" "\\" "m2p" "\\") ) (princ) ) Finally, I'm delighted that my posts have been of benefit to you. Pretty awesome there Lee Mac, that's one I will use a lot. Cheers Steve, I guess sometimes the simple ones are the most useful. 1 Quote
masterfal Posted June 30, 2023 Posted June 30, 2023 Hi all, Just wondering, instead of the base point being selecting by the midpoint between 2 chosen points, could it be set up so the base point is the midpoint of a chosen closed polyline? Would be great to be able to simply click a polyline and move it by its midpoint instead of needing to choose 2 points to find the midpoint of to move from Quote
Steven P Posted June 30, 2023 Posted June 30, 2023 7 hours ago, masterfal said: Hi all, Just wondering, instead of the base point being selecting by the midpoint between 2 chosen points, could it be set up so the base point is the midpoint of a chosen closed polyline? Would be great to be able to simply click a polyline and move it by its midpoint instead of needing to choose 2 points to find the midpoint of to move from This should give you the mid point of a line or polyline, added a bit to do the move from Lee Macs example above -chose which one you like to use (defun c:Mid_Pt ( / Sel_Ent Sel_Obj Mid_Len Mid_Pt ) (setq Sel_Ent (car (entsel)) ) (setq Sel_Obj (vlax-Ename->Vla-Object Sel_Ent)) (setq Mid_Len (/ (vla-get-length Sel_Obj ) 2 )) (setq Mid_Pt (vlax-curve-getPointAtDist Sel_Obj Mid_Len)) ;; Mid_Pt ;;;;;;;;; ;;Do nmove as you want for example: (setq p3 (getpoint "\n1st Point of Mid for Next point: ")) (setq p4 (getpoint "\n2nd Point of Mid for Next point: ")) (command "_.move" Sel_Ent "" "_non" Mid_Pt "_non" (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) p3 p4) ) ;;;;;;;;; ) which you could use to move a polyline Quote
Lee Mac Posted June 30, 2023 Posted June 30, 2023 @Steven P Since not all curve objects have an ActiveX length property (namely, arcs, circles, etc.); it may be better to obtain the midpoint using a function such as the following, which will work with any curve object of finite length: (defun curvemidpoint ( ent ) (vlax-curve-getpointatdist ent (/ (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) 2.0) ) ) 1 Quote
Steven P Posted June 30, 2023 Posted June 30, 2023 7 minutes ago, Lee Mac said: @Steven P Since not all curve objects have an ActiveX length property (namely, arcs, circles, etc.); it may be better to obtain the midpoint using a function such as the following, which will work with any curve object of finite length: (defun curvemidpoint ( ent ) (vlax-curve-getpointatdist ent (/ (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) 2.0) ) ) Thanks Lee, that is better Quote
BIGAL Posted July 1, 2023 Posted July 1, 2023 Is it mid point of length or a GCEN ie centre of closed pline. 1 Quote
masterfal Posted July 3, 2023 Posted July 3, 2023 On 7/1/2023 at 11:06 AM, BIGAL said: Is it mid point of length or a GCEN ie centre of closed pline. yeh i was referring to the centre of a closed polyline. ie moving centre of one rectangle onto the centre of a different rectangle. apologies if i didn't explain clearly.. Quote
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.