Hudson Posted August 6, 2009 Share Posted August 6, 2009 I know when I access the arc information via entget the endpoint isn't even the list of information. Through a more advance method, is there a way to swap the start and end points.. or does autocad have to draw an arc in say counterclockwise? Thanks for your time! Andrew Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 6, 2009 Share Posted August 6, 2009 Hmm.. good question. Start/End Points are RO, and so cannot be altered directly, but this is the best I could get to: (defun swparc (Obj / lst) (setq lst (mapcar (function (lambda (x) (vlax-get-property Obj x))) '(StartAngle EndAngle))) (mapcar (function (lambda (x y) (vlax-put-property Obj x y))) '(EndAngle StartAngle) lst)) (defun c:test () (swparc (vlax-ename->vla-object (car (entsel))))) Quote Link to comment Share on other sites More sharing options...
Hudson Posted August 6, 2009 Author Share Posted August 6, 2009 great! I'm learning a lot today Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 6, 2009 Share Posted August 6, 2009 Well, its not exactly what you wanted - the arc is still anticlockwise... but just reversed... Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted August 6, 2009 Share Posted August 6, 2009 Im not sure if this is the case, and carnt check while @ work but In polylines you can controll the direction with - i think Im not sure what the 0.4142356 is refering to in the entity Its not radius nor radians. clockwise (cons 42 0.41421356) Anticlockwise (cons 42 -0.41421356) Food for thought purhaps Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 7, 2009 Share Posted August 7, 2009 This is not really any help but I spent ages trying to figure out arcs they are basicly stored as a centre point, two angles and a radius (lee mac above ), trying to write some code to do arc stuff I never really solved the problem. I played with quadrants and all sorts of things. Autodesk sometimes hide things and you only occasionaly find out. I have looked at the dxf output of an arc and still no wiser. I think the bulge factor creeps in somewhere. + vs - If you reverse the start and end you would get say a 1/4 versus a 3/4 arc. Its the same with arcs and line types you can not reverse an arc you can only reverse the linetype (ie two linetypes) If its just knowing the points of the ends then thats just cen pt angle rad. Quote Link to comment Share on other sites More sharing options...
Hudson Posted August 7, 2009 Author Share Posted August 7, 2009 Well, it's not the end of the world that I can't reverse them. It would have made more logical sense for the task I'm working on if the start point could be either end in the actual drawing. But if that's just not possible, then that's ok. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 7, 2009 Share Posted August 7, 2009 Im not sure if this is the case, and carnt check while @ work but In polylines you can controll the direction with - i think Im not sure what the 0.4142356 is refering to in the entity Its not radius nor radians. clockwise (cons 42 0.41421356) Anticlockwise (cons 42 -0.41421356) Food for thought purhaps The 42 is the Bulge in the polyline - its equal to the tangent of a quarter of the angle subtended by the arc. Have a look at vla-getbulge for more on this. However, I don't think pure arc entities have this attribute. Lee Quote Link to comment Share on other sites More sharing options...
David Bethel Posted August 7, 2009 Share Posted August 7, 2009 Autocad ARCs are always counterclockwise. Here's is bit of info on arc data. (defun RtoA (r) (/ (* r 180.0) pi)) ;Radian To Angle (defun r_just (s p) (princ "\n") (repeat (- p (strlen s)) (princ " ")) (princ s)) (defun arcdata (en / ed ce ra sa ea ia p1 p2 mp cd ch cl al al et la ha ac ls lt tk uc) (and (= (type en) 'ENAME) (setq ed (entget en)) (= (cdr (assoc 0 ed)) "ARC") (setq ce (cdr (assoc 10 ed)) ra (cdr (assoc 40 ed)) sa (cdr (assoc 50 ed)) ea (cdr (assoc 51 ed)) ia (if (> sa ea) (+ (- (* 2 pi) sa) ea) (- ea sa)) p1 (polar ce sa ra) p2 (polar ce ea ra) mp (polar ce (+ sa (* 0.5 ia)) ra) cd (distance p1 p2) cl (angle p1 p2) ch (distance (inters p1 p2 mp ce nil) mp) al (* ia ra) ha (assoc 5 ed) ac (assoc 62 ed) tk (assoc 39 ed) ls (assoc 48 ed) lt (assoc 6 ed) et (cdr (assoc 0 ed)) la (cdr (assoc 8 ed)) uc (cdr (assoc 210 ed))) (progn (textpage) (r_just "Entity Name <-1>: " 30) (prin1 en) (r_just "Entity Type <0>: " 30) (princ et) (r_just "Handle <5>: " 30) (cond ((not ha) (princ "HANDLES Disabled")) (T (princ (cdr ha)))) (r_just "LineType <6>: " 30) (cond ((not lt) (princ "BYLAYER")) (T (princ (cdr lt)))) (r_just "Layer <8>: " 30) (princ la) (r_just "Center <10>: " 30) (prin1 ce) (r_just "Entity Color <62>: " 30) (cond ((not ac) (princ "BYLAYER")) ((zerop (cdr ac)) (princ "BYCOLOR")) (T (prin1 (cdr ac)))) (r_just "Thickness <39>: " 30) (cond ((not tk) (princ "0")) (T (prin1 (cdr tk)))) (r_just "LineType Scale <48>: " 30) (cond ((not ls) (princ "1")) (T (prin1 (cdr ls)))) (r_just "Start Point: " 30) (prin1 p1) (r_just "Mid Point: " 30) (prin1 mp) (r_just "End Point: " 30) (prin1 p2) (r_just "ARC Length: " 30) (prin1 al) (r_just "Radius <40>: " 30) (prin1 ra) (r_just "Start Angle In Degrees <50>: " 30) (prin1 (rtoa sa)) (r_just "End Angle In Degrees <51>: " 30) (prin1 (rtoa ea)) (r_just "Included Angle In Degrees: " 30) (prin1 (rtoa ia)) (r_just "Chord Length: " 30) (prin1 cd) (r_just "Chord Height: " 30) (prin1 ch) (r_just "Chord Angle Decimal: " 30) (prin1 (rtoa cl)) (r_just "Chord Angle Surveyors: " 30) (princ (angtos cl 4 4)) (r_just "UCS <210>: " 30) (if (equal uc '(0 0 1) 1e-14) (princ "WORLD") (prin1 uc)))) (prin1)) -David Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 11, 2009 Share Posted August 11, 2009 If you just need to be able to the pick the end you want to be the start point then there is a way around it and its very simple. You pick the arc near the end you want as the start point get the two end points and then just compare the distance from your pick point to the end points then make the shorter distance the start point etc. ;this is code for a line just need to change pt1 and pt2 for an arc (setq tp1 (entsel "\nSelect arc near start : ")) (setq tpp1 (entget (car tp1))) (setq pt1 (cdr (assoc 10 tpp1))) (setq pt2 (cdr (assoc 11 tpp1))) (setq pt3 (cadr tp1)) (setq d1 (distance pt1 pt3)) (setq d2 (distance pt2 pt3)) (if (> d1 d2) (progn (setq temp pt1) (setq pt1 pt2) (setq pt2 temp) ) ) Quote Link to comment Share on other sites More sharing options...
Hudson Posted August 12, 2009 Author Share Posted August 12, 2009 BigAl, Thanks, I can now draw my chords along the arc starting from either end.. Everyone here has been most helpful! Regards, Andrew Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 12, 2009 Share Posted August 12, 2009 Glad we could be of some assistance 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.