Doctor Nocturnal Posted September 16, 2019 Posted September 16, 2019 (edited) It's been a while since I've been on cad, I got really excited when I saw the OSnap, to snap to the center of a square, but that's not really what it is. It has to be a closed object. I was wondering if there have been any improvements or a lisp that someone has came up with. Maybe it would first have to create a boundary? I just do a lot of work placing things right in the center or 2' x 2' act ceiling tiles. It wouldn't be a super time saver, because there is always snap midway between two points, and also, I can copy from the point of a corner, but..it would be pretty cool. Edited September 16, 2019 by Doctor Nocturnal typo Quote
Cad64 Posted September 16, 2019 Posted September 16, 2019 You could use the M2P command modifier. For example, if you need to place a block at the midpoint between two lines, Start the Move command, select the block, choose a base point on the block, then type M2P. Now click on the endpoint of one line and the endpoint of the other line and the block will be placed at the midpoint between the two endpoints you selected. Edit: I just re-read your post and it sounds like maybe you already know about M2P? Quote
lrm Posted September 17, 2019 Posted September 17, 2019 Let's say you want to snap to the center of several rectangles (closed or open or part of a grid) such as the following: You could create a single polyline (red) from corner to opposite corner using osnap end and intersection and then use osnap midpoint to snap the block to the centers. The single polyline is then easily deleted. Quote
BIGAL Posted September 17, 2019 Posted September 17, 2019 Like Lrm just pick inside each shape use bpoly and a quick and dirty is that 4 points of the pline created the mid of pt1 + pt3 is the answer. (defun c:test ( / co-ord pt1 pt2 dist ang ) (while (setq pt (getpoint "Pick a point inside")) (command "bpoly" pt "") (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast))))) (setq pt1 (nth 0 co-ord)) (setq pt2 (nth 2 co-ord)) (setq ang (angle pt1 pt2)) (setq dist (/ (distance pt1 pt2) 2.0)) (setq pt1 (polar pt1 ang dist)) (command "erase" (entlast) "") (command "line" pt2 pt1 "") ) ) (c:test) Quote
tombu Posted September 17, 2019 Posted September 17, 2019 ; Middle Object Osnap ; Macro: ^P(or midobj (load "midobj.lsp")(princ))(midobj) (defun midobj (/ ll ur selection pntlist pnts adoc) (setq selection (car (entsel)) adoc (vla-get-activedocument (vlax-get-acad-object)) ) (vla-getboundingbox (vlax-ename->vla-object selection) 'll 'ur) (setq pntlist (mapcar 'vlax-safearray->list (list ll ur))) (list(/(+(caar pntlist)(caadr pntlist))2.0)(/(+(cadar pntlist)(cadadr pntlist))2.0)) ) or ;Center of closed polygon ;^P(or C:pc1 (load "pc1.lsp"))(pc1) ; (load "pc1.lsp")(pc1) (defun pc1 ( / acdoc acspc acsel reg pt) (vl-load-com) ;; © Lee Mac 2011 (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)) acspc (vlax-get-property acdoc (if (= 1 (getvar 'CVPORT)) 'Paperspace 'Modelspace)) ) ; (if (ssget "+.:E:S") (if (ssget "+.:E:S" '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1))) (progn (vlax-for obj (setq acsel (vla-get-ActiveSelectionSet acdoc)) (setq pt(trans (vlax-get (setq reg (car (vlax-invoke acspc 'addregion (list obj)))) 'Centroid) 1 0)) (vla-delete reg) ) (vla-delete acsel) ) ) pt ) or something in this thread: https://www.cadtutor.net/forum/topic/43811-display-hatch-area-as-a-label/?tab=comments#comment-358082 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.