Here is a simple and great routine. This routine places a “point” at the mid-point of the polyline. Usually, you can simply snap to the mid-point of a polyline segment. But if you want to simply find the mid-point of the overall length of a polyline, this isn’t such a simple task. That’s where this routine comes in handy. It will place a point at the middle of the polyline. So prior to running this routine, use the DDPTYPE command to set the size and type of point that you would like to use.
Here’s how:
- MIDPOLY <enter> to start
- Select the Polyline to place the point at its mid-point.
I found this LISP routine at the following website [click here]. If you do copy the code from the linked website, don’t forget to add (vl-load-com) to the routine in order for it to work.
;; ! **************************************************************************** ;; ! C:MidPoly ;; ! **************************************************************************** ;; ! Function : Determines the mid point of a polyline and draws a point at that ;; ! location ;; ! Author : Rakesh Rao, (C) 2004, Four Dimension Technologies ;; ! Bangalore, India ;; ! Email : rakesh.rao@4d-technologies.com ;; ! Web www.4d-technologies.com ;; ! Updated : March 11, 2004 ;; ! **************************************************************************** (defun c:MidPoly ( / ent ename entl en oname param len hLen MidPt OS ) (vl-load-com) (setq ent (entsel "\nSelect polyline:")) (if ent (progn (setq ename (car ent) entl (entget ename) en (cdr (assoc 0 entl)) ) (if (member en (list "POLYLINE" "LWPOLYLINE")) (progn (setq oname (vlax-ename->vla-object ename) param (vlax-curve-getEndParam oname) len (vlax-curve-getDistAtParam oname param) hLen (* 0.5 len) MidPt (vlax-curve-getPointAtDist oname hLen) ) (vlax-release-object oname) (setq OS (getvar "OSMODE")) (setvar "OSMODE" 0) (command "._Point" MidPt) (princ "\nPoint object created at mid-point:")(princ MidPt) (setvar "OSMODE" OS) ) (princ "\nYou must pick a polyline object only.") ) )) (prin1) ) (princ "\nType 'MidPoly' to start.") (prin1)
Hi, This midpoly lisp file was excellent. very useful.
The problem is i have more than 10,000 polylines. I cannot select each and everyline to convert into points at the mid point of each line. Is there any other lisp file or can you modify this lisp file to select many objects / polylines at a time.
Request to reply to my e-mail vdramu@gmail.com.
Thanks a lot in advance.
Ramu,
Here is a simple routine that might help:
(defun C:MDIV (/ ss n segs)
(setq ss (ssget “X”)
n (1- (sslength ss))
segs (getint “\Number of segments per object: “)
)
(while (>= n 0)
(command “_.divide” (ssname ss n) segs)
(setq n (1- n))
)
(princ)
)
Note that it will select and “divide” everything by placing a Point at its midpoint
~Greg
Thanks for your prompt reply and providing new lisp file. When i tried to use this lisp the following error is coming.
Command: MDIV
Select objects: Specify opposite corner: 16 found
Select objects: too many arguments
I have two lines crossing each other at mid point (like + symbol) and i want to insert a point at the mid point or intersection of both the lines. Hope you understood the requirement.
Waiting for your reply.
Thanks.
With regards
Ramu
That also happens to me. I need exactly the same function as Ramu. Create a point in the middle of multiple lines.
The second lisp that you provided gives me the same errors:
Command: MDIV
Select objects: Specify opposite corner: 198 found
Select objects:
; error: too many arguments
Sir, I need to mark tributary area on a floor plan that takes midpoints from the surrounding edges. Can you please help me how i can draw a line between midpoints that ends up making a square.
Wow. If I could find something that did this for feature lines it would save me so much time…
Actually, nevermind. This works how I need it. When I create a bench, the first step is to extract a contour line and slope it with the midpoint being the highest point. I can use this in the time between extracting the polyline from the surface and turning it into a feature line. Thanks!