Jump to content

Recommended Posts

Posted

I'm familiar with vlax get start and get end point but what about the midpoint?

Posted

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) :oops:

Posted

Thanks Lee

 

Am I right in thinking this is only for a line and not a polyline?

Posted

Sorry John,

Slight error in my first code - corrected :P

 

But yes, sorry, it is for lines only. :oops:

Posted

Thanks all the same

 

I'd like to use polar and angle as I learn more...and know I know how.

 

:)

Posted

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)
)

Posted

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.

Posted
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

Posted
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?

Posted

Ah! Sorry, I only read it and believing that a curve only existed between two points.

 

I hadn't known fully about curves.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...