ollie Posted July 26, 2010 Share Posted July 26, 2010 Hi Folks I am trying to identify points on an arc where if a horizontal line was drawn from a test point across the arc the result would be a list of on or two points where the Y coordinate intersects_ Cheers. Quote Link to comment Share on other sites More sharing options...
alanjt Posted July 26, 2010 Share Posted July 26, 2010 Look into (vlax-invoke obj1 'IntersectWith obj2 acExtendNone) Quote Link to comment Share on other sites More sharing options...
ollie Posted July 26, 2010 Author Share Posted July 26, 2010 Thanks alanjt. Unfortunately I can't use the intersectsWith method as there is no actual line and the program which is ODBX based carries out the calculation this would be plugged into thousands of times per documnent. I've wrote a method to generate every detail imaginable about the arc (everyone I can imagine) and know the test coordinates. I need to achieve this solely using maths. Ironically I used briefly worked in manufacturing and design which if I'd stayed long enough I would have had to learn how to do this by now. Cheers, Ollie Quote Link to comment Share on other sites More sharing options...
alanjt Posted July 26, 2010 Share Posted July 26, 2010 I love love love it when people don't include all the information. Quote Link to comment Share on other sites More sharing options...
ollie Posted July 26, 2010 Author Share Posted July 26, 2010 I love love love it when people don't include all the information. hehe: I spend that much time writing math functions in various languages these days I assume everyone only thinks in calculus. Quote Link to comment Share on other sites More sharing options...
alanjt Posted July 26, 2010 Share Posted July 26, 2010 Not when there are built in functions for it. Quote Link to comment Share on other sites More sharing options...
ollie Posted July 26, 2010 Author Share Posted July 26, 2010 Built in functions are for the weak The above statement is probably the downfall of every project I embrace. Quote Link to comment Share on other sites More sharing options...
alanjt Posted July 26, 2010 Share Posted July 26, 2010 If the option is there, use it. Quote Link to comment Share on other sites More sharing options...
ollie Posted July 26, 2010 Author Share Posted July 26, 2010 Depending on the scale of the function (if it's reasonably small) I tend to work on the basis of - if there is a vl* method for it use if not write your own. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 26, 2010 Share Posted July 26, 2010 Built-in functions are for the weak (defun GetArcX ( e y / dxf asin l c r s f a g ) ;; © Lee Mac 2010 (defun dxf ( c l ) (cdr (assoc c l))) (defun asin ( x ) (if (< (abs x) 1.0) (if (equal (abs x) 1.0 1e- (* x (/ pi 2.)) (atan (/ x (sqrt (- 1.0 (* x x))))) ) ) ) (setq l (entget e)) (setq c (dxf 10 l) r (dxf 40 l) s (dxf 50 l) f (dxf 51 l)) (if (< f s) (setq s (- s (* 2 pi)))) (if (setq a (asin (/ (- y (cadr c)) r))) (mapcar (function (lambda ( n ) (if (<= s n f) (list (+ (* r (cos n)) (car c)) y) ) ) ) (list (- pi a) (rem (+ (* 2 pi) a) (* 2 pi))) ) ) ) (defun c:test ( / e pt x y ) (if (and (setq e (car (entsel "\nSelect Arc: "))) (setq p (getpoint "\nPick Y Elevation: ")) (setq x (GetArcX e (cadr (trans p 1 0))))) (foreach pt x (if pt (entmakex (list (cons 0 "POINT") (cons 10 pt))) ) ) ) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 27, 2010 Share Posted July 27, 2010 Check a land surveying handbook there is a mathmatical soloution without actually drawing anything. Otherwise maybe draw a line and arc then just erase them if not needed. Thanks to lee mac did something similar and just created temporary objects and let Autocad do its thing using "intersectwith" This is code for two lines hitting an arc cutting a bit out and redrawing (do arc rad 9 parallel lines say 2 apart must hit arc) (vl-load-com) (setq oldsnap (getvar "osmode")) (setvar "osmode" 0) (setq oldlayer (getvar "clayer")) ;pdmode point type use when checking points ; (setvar "pdmode" 34) (setvar "osmode" 512) ; nearest make sure on line (setq pickobj (entsel "\nPick arc :")) (setq obj1 (vlax-ename->vla-object (car pickobj))) (setq pt1 (cadr pickobj)) (setvar "clayer" (cdr (assoc 8 (entget (car pickobj))))) (setq pickobj1 (entsel "\nPick 1st line :")) (setq obj2 (vlax-ename->vla-object (car pickobj1))) (setq intpt1 (vlax-invoke obj2 'intersectWith obj1 acExtendThisEntity)) (setq L1 (cdr (assoc 10 (entget (car pickobj1))))) (setq L2 (cdr (assoc 11 (entget (car pickobj1))))) (setq ang (angle L1 L2)) (setq dist (distance L1 L2)) (setq pt2 (polar L1 ang (/ dist 2.0))) ;(setq pt2 (cadr pickobj1)) ;(command "point" intpt1) ;path intersect with arc ;path intersect with arc (setq pickobj2 (entsel "\nPick 2nd line :")) (setq obj3 (vlax-ename->vla-object (car pickobj2))) (setq pt3 (cadr pickobj2)) (setq intpt2 (vlax-invoke obj3 'intersectWith obj1 acExtendThisEntity)) ;(command "point" intpt2) ; left & right offset (setq L1 (cdr (assoc 10 (entget (car pickobj2))))) (setq L2 (cdr (assoc 11 (entget (car pickobj2))))) (setq ang (angle L1 L2)) (setq dist (distance L1 L2)) (setq pt3 (polar L1 ang (/ dist 2.0))) (setvar "osmode" 0) (setq ang (angle pt2 pt3)) (setq ang2 (+ ang 3.14159)) (setq pt4 (polar pt2 ang2 1.0)) (setq pt5 (polar pt3 ang 1.0)) ;path offset intersect with arc (command "offset" 0.6 pickobj2 pt5 "exit") (setq pickobj3 (entlast)) (setq obj4 (vlax-ename->vla-object pickobj3)) (setq intpt3 (vlax-invoke obj4 'intersectWith obj1 acExtendThisEntity)) ;(command "point" intpt3) ;path offset intersect with arc (command "offset" 0.6 pickobj1 pt4 "exit") (setq pickobj4 (entlast)) (setq obj5 (vlax-ename->vla-object pickobj4)) (setq intpt4 (vlax-invoke obj5 'intersectWith obj1 acExtendThisEntity)) ;(command "point" intpt4) : (command "offset" 0.3 pickobj pt4 "exit") (setq pickobj5 (entlast)) (command "extend" pickobj5 "" pickobj1 "") (command "extend" pickobj5 "" pickobj2 "") (setq L1 (cdr (assoc 10 (entget (car pickobj2))))) (setq L2 (cdr (assoc 11 (entget (car pickobj2))))) ; swap (setq d1 (distance intpt2 L1)) (setq d2 (distance intpt2 L2)) (if (> d1 d2) (progn (setq temp L1) (setq L1 L2) (setq L2 temp) ) ) (setq L3 (cdr (assoc 10 (entget (car pickobj1))))) (setq L4 (cdr (assoc 11 (entget (car pickobj1))))) ;swap (setq d1 (distance intpt1 L3)) (setq d2 (distance intpt1 L4)) (if (> d1 d2) (progn (setq temp L3) (setq L3 L4) (setq L4 temp) ) ) (command "erase" pickobj3 pickobj4 pickobj5 "") (command "break" pickobj "F" intpt3 intpt4) (command "line" intpt3 L1 L3 intpt4 "") (setvar "osmode" oldsnap) (princ) 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.