Johntosh Posted November 14, 2008 Posted November 14, 2008 I'm familiar with vlax get start and get end point but what about the midpoint? Quote
Lee Mac Posted November 14, 2008 Posted November 14, 2008 This will retrieve the midpt: (defun c:mpt (/ l1 stpt enpt midpt) (setq l1 (car (entsel "\nSelect Line: "))) (setq stpt (cdr (assoc 10 (entget l1)))) (setq enpt (cdr (assoc 11 (entget l1)))) (setq midpt (polar stpt (angle stpt enpt) (/ (distance stpt enpt) 2) ) ; end polar ) ; end setq (princ) ) ; end mpt But doesn't use Active X methods, (I'm not too familiar with them) Quote
Johntosh Posted November 14, 2008 Author Posted November 14, 2008 Thanks Lee Am I right in thinking this is only for a line and not a polyline? Quote
Lee Mac Posted November 14, 2008 Posted November 14, 2008 Sorry John, Slight error in my first code - corrected But yes, sorry, it is for lines only. Quote
Johntosh Posted November 14, 2008 Author Posted November 14, 2008 Thanks all the same I'd like to use polar and angle as I learn more...and know I know how. Quote
lpseifert Posted November 14, 2008 Posted November 14, 2008 try this (defun c:test (/ oldosnap crv crv-obj endpt totlen middist midpt) (vl-load-com) (setq oldosnap (getvar "osmode")) (setvar "osmode" 0) (command "ucs" "w") (if (/= (getvar "pdmode") 3)(setvar "pdmode" 3)) (setq crv (entsel "Select curve: ") crv-obj (vlax-ename->vla-object (car crv)) endpt (vlax-curve-getEndPoint crv-obj) totlen (vlax-curve-getDistAtPoint crv-obj endpt) middist (/ totlen 2.0) midpt (vlax-curve-getPointAtDist crv-obj middist) ) (command "Point" midpt) (command "ucs" "p") (setvar "osmode" oldosnap) (princ (strcat "\nA point was placed at the midpoint of the curve at " (rtos (car midpt) 2 2)"," (rtos (cadr midpt) 2 2))) (princ) ) Quote
Johntosh Posted November 21, 2008 Author Posted November 21, 2008 Thanks Ipseifert. I'm not sure but is this for a polyline with just two points? I think I can work out how to get to the 2 inner-most points however and work from there. Quote
devitg Posted November 21, 2008 Posted November 21, 2008 Thanks Ipseifert. I'm not sure but is this for a polyline with just two points? I think I can work out how to get to the 2 inner-most points however and work from there. As I make a test , it work for any 2d enty , and even to a 3d poly . LINE ARC CIRCLE OPEN POLY CLOSED POLY SPLINE 3DPOLY all enty mid point.dwg Quote
lpseifert Posted November 21, 2008 Posted November 21, 2008 Thanks Ipseifert. I'm not sure but is this for a polyline with just two points? I think I can work out how to get to the 2 inner-most points however and work from there. It finds the length of the curve (vlax-curve which includes lines, polylines and a bunch of other entities) divides it by 2 and puts a point there. Did you try it? Quote
Johntosh Posted November 21, 2008 Author Posted November 21, 2008 Ah! Sorry, I only read it and believing that a curve only existed between two points. I hadn't known fully about curves. 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.