lamensterms Posted March 12, 2019 Posted March 12, 2019 (edited) Hey guys, Sorry for the vague title, didn't really know how best to name this thread... or describe my question, for that matter. I have a couple of elements (3DSOLID and ARC/CIRCLE - within block) that I would like to move onto a line, at the tangent of the ARC/CIRCLE. I only wish to move them horizontally, in the X axis. Please see screen shot below and CAD file attached. I have been drawing a line from centre of ARC/CIRCLE, perpendicular to the line, then drawing a horizontal line at the inter or the 1st line and the ARC... this method does give me the desired result, but is a bit time consuming. I will need to perform this task approximately 1200 times. I am wondering if anyone knows of the routine or command that will allow me to pick the ARC and objects and then move them (in current view X only) onto the tangent line? I have done a bit of digging in Google, and there are a few peeps asking a similar question, but I haven't found an 'automated' method just yet. Thanks a lot for any help guys. MOVE X at TAN.dwg Edited March 12, 2019 by lamensterms 1 Quote
Emmanuel Delay Posted March 12, 2019 Posted March 12, 2019 (to me) It's a bit of problem that the entities are not drawn in WCS. I can do it for my dwg, maybe somebody can adapt it to work for yours Command MAT (for Move Arc Tangent) select the arc select the block again anywhere (this is another ToDo: extract the parent...) select the line ;; https://www.cadtutor.net/forum/topic/18257-entmake-functions/ (defun Line (p1 p2) (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2))) ) (defun xLine (pt vec) (entmakex (list (cons 0 "XLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbXline") (cons 10 pt) (cons 11 vec))) ) (defun dArc (cen rad sAng eAng) (entmakex (list (cons 0 "ARC") (cons 10 cen) (cons 40 rad) (cons 50 sAng) (cons 51 eAng)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Intersections - Lee Mac ;; Returns a list of all points of intersection between two objects ;; for the given intersection mode. ;; ob1,ob2 - [vla] VLA-Objects ;; mod - [int] acextendoption enum of intersectwith method (defun LM:intersections ( ob1 ob2 mod / lst rtn ) (if (and (vlax-method-applicable-p ob1 'intersectwith) (vlax-method-applicable-p ob2 'intersectwith) (setq lst (vlax-invoke ob1 'intersectwith ob2 mod)) ) (repeat (/ (length lst) 3) (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn) lst (cdddr lst) ) ) ) (reverse rtn) ) (vl-load-com) (defun c:mat ( / arc arc2 parent l1 c1 s e r bi p1 sloped hor lst p2 p3) (setq arc (nentsel "\nSelect Arc")) ;;(setq parent (cdr (assoc 330 (entget (car arc))))) (setq parent (entsel "\nSelect Block")) (setq l1 (entsel "\nSelect Line")) ;; center/start/end/radius of the Arc inside block (edit) ;; we will copy/paste the arc outside of the block (setq c1 (cdr (assoc 10 (entget (car arc))))) (setq s (cdr (assoc 50 (entget (car arc))))) (setq e (cdr (assoc 51 (entget (car arc))))) (setq r (cdr (assoc 40 (entget (car arc))))) ;; insert point of the block (setq bi (cdr (assoc 10 (entget (car parent))))) ;; sum of both gives you the center outside the block (setq c1 (list (+ (nth 0 c1) (nth 0 bi)) (+ (nth 1 c1) (nth 1 bi)) )) ;; copy the arc (setq arc2 (dArc c1 r s e)) ;; p1: closest point on the line to the center of the arc (perpendicular) (setq p1 (vlax-curve-getClosestPointTo (car l1) c1)) ;; draw a sloped line (setq sloped (Line c1 p1)) ;; find the intersection of the arc / sloped line (setq lst (LM:intersections (vlax-ename->vla-object sloped) (vlax-ename->vla-object arc2) acextendnone)) (setq p2 (nth 0 lst)) ;; draw a horizontal XLine (setq hor (xLine p2 (list 1.0 0.0) )) ;; find the intersection of the horizontal xLine / l1 (setq lst (LM:intersections (vlax-ename->vla-object hor) (vlax-ename->vla-object (car l1)) acextendnone)) (setq p3 (nth 0 lst)) ;; move arc to p3 (vla-move (vlax-ename->vla-object (car parent)) (vlax-3d-point p2)(vlax-3d-point p3)) ;; delete temporary items Line, xLine, Arc (entdel sloped) (entdel hor) (entdel arc2) ) MAT.dwg 1 Quote
marko_ribar Posted March 12, 2019 Posted March 12, 2019 If I may just give a notification : When you move block along X axis, arc won't be touching desired line as tangent, so you might have 2 intersection points (arc X line) - according to your picture, very close points, but different... To make it touch 1 point, you have to move block/arc on perpendicular point, so everything was shown correctly except 3rd step (you should move block in perpendicular direction instead horizontally)... But as you asked for - as in posted code by Emmanuel you can do whatever you want, but I won't dare to say that that intervention gives tangent arc-line situation... So your only horizontal way of doing this is to make sure your pink (magenta) line is vertical, but I guess you don't have this situation... Quote
lamensterms Posted March 12, 2019 Author Posted March 12, 2019 Hi Emmanuel, thank you very much for providing this routine, it works exactly as I had hoped... but as you say - will not work outside of WCS. I also have the issue that the destination line will not always be in the same Z elevation as the ARC & block. The workflow is spot on though, thank you for sharing. Hi Marko, thanks for the reply. I am not sure I understand what you mean. I am quite sure that the 3 steps shown in the original post will result in the ARC aligning with the LINE at the tangent point (please ignore current UCS Z elevation value for this exercise). Could you please elaborate what you mean? I should also add that the angle of the destination line varies in each situation, and is rarely 'vertical' in current UCS. Quote
marko_ribar Posted March 13, 2019 Posted March 13, 2019 Sorry, my mistake... I looked at picture again and I see that I was wrong... Discard my posted observation... 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.