francesc Posted February 9, 2016 Share Posted February 9, 2016 How to know if the polyline is a circle or other figure. I would like to detect polylines in a circle. Thank you. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 9, 2016 Share Posted February 9, 2016 (edited) Removed ... Edited February 9, 2016 by Tharwat Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 9, 2016 Share Posted February 9, 2016 Do you mean that you wish to detect whether a polyline has the visual appearance of a circle? Quote Link to comment Share on other sites More sharing options...
francesc Posted February 9, 2016 Author Share Posted February 9, 2016 yes Lee Thank you Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted February 9, 2016 Share Posted February 9, 2016 Not sure if you are looking for polylines with only the vertex on a circle, or polylines exactly like a circle (with bulges). For the last hypothesis: (defun is_circle (e / i o c1 c2 p1 p2) (setq i (vlax-curve-getendparam e) o T) (while (and (> i 0) o) (setq p1 (vlax-curve-getpointatparam e i) p2 (vlax-curve-getpointatparam e (setq i (1- i))) c1 (mapcar (if (minusp (vla-getbulge (vlax-ename->vla-object e) i)) '- '+) p2 (vlax-curve-getsecondderiv e i) ) ) (or (equal p1 p2 1e- (if (not c2) (setq c2 c1)) (setq o (equal c1 c2 1e-) ) ) o ) (defun c:test ( / e) (if (setq e (ssget ":E:S" '((0 . "LWPOLYLINE")))) (if (is_circle (ssname e 0)) (alert "Selected object lies on a CIRCLE") (alert "Not a circle") ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 9, 2016 Share Posted February 9, 2016 Very good Stefan Here is a crude & unimaginative method: (defun polycircle-p ( ent / _circle-p _vertexdata ) (defun _vertexdata ( enx ) (if (setq enx (member (assoc 10 enx) enx)) (cons (list (cdr (assoc 10 enx)) (cdr (assoc 42 enx)) ) (_vertexdata (cdr enx)) ) ) ) (defun _circle-p ( lst cn1 rd1 / ang cn2 rd2 ) (or (not (cdr lst)) (and (or (equal (caar lst) (caadr lst) 1e- (and (not (equal 0.0 (cadar lst) 1e-) (setq ang (* 2 (atan (cadar lst))) rd2 (/ (distance (caar lst) (caadr lst)) 2 (sin ang)) cn2 (polar (caar lst) (+ (- (/ pi 2) ang) (angle (caar lst) (caadr lst))) rd2) ) (or (null cn1) (and (equal cn1 cn2 1e- (equal rd1 rd2 1e-) ) (_circle-p (cdr lst) cn2 rd2) ) ) ) ) ) (and (setq enx (entget ent)) (= "LWPOLYLINE" (cdr (assoc 0 enx))) (= 1 (logand 1 (cdr (assoc 70 enx)))) (cdr (setq lst (_vertexdata enx))) (_circle-p (cons (last lst) lst) nil nil) ) ) Quote Link to comment Share on other sites More sharing options...
tombu Posted February 9, 2016 Share Posted February 9, 2016 http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/circle-to-polyline-circular-polyline-to-circle/m-p/5520233#M330236 CirclePolylineSwap.lsp [command names: C2P & P2C] by Kent Cooper, last edited 25 February 2015 Updated one is post #27 Guessing when you find them you may want to change them to circles. Quote Link to comment Share on other sites More sharing options...
francesc Posted February 10, 2016 Author Share Posted February 10, 2016 Thank you very much to all 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.