i need lisp to get( point) center of lines or Polylines

i need lisp to get( point) center of lines or Polylines

Mohamed32Samy
Advocate Advocate
644 Views
4 Replies
Message 1 of 5

i need lisp to get( point) center of lines or Polylines

Mohamed32Samy
Advocate
Advocate

plz help me
i need lisp or solution to get points of (center) lines or polyliens 

plz check attache file

0 Likes
Accepted solutions (2)
645 Views
4 Replies
Replies (4)
Message 2 of 5

komondormrex
Mentor
Mentor
Accepted solution

check this.

 

(defun c:point_middle_line nil
	(foreach line_object (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget '((0 . "line")))))))
		(vla-addpoint (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)))) 
					  (vlax-3d-point (polar (vlax-get line_object 'startpoint)
									 		(angle (vlax-get line_object 'startpoint) (vlax-get line_object 'endpoint))
									 		(* 0.5 (distance (vlax-get line_object 'startpoint) (vlax-get line_object 'endpoint)))
									 )
					  )
		)
	)
)
Message 3 of 5

Mohamed32Samy
Advocate
Advocate
thanx alot

really great lisp
0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution
(defun C:PLM (/ ss n lin); = Points at Line Midpoints
  (if (setq ss (ssget '((0 . "LINE"))))
    (repeat (setq n (sslength ss))
      (setq lin (ssname ss (setq n (1- n))))
      (command "_.point" "_non"
        (mapcar '/
          (mapcar '+ (vlax-curve-getStartPoint lin) (vlax-curve-getEndPoint lin))
          '(2 2 2)
        ); mapcar
      ); command
    ); repeat
  ); if
  (prin1)
)
Kent Cooper, AIA
Message 5 of 5

Mohamed32Samy
Advocate
Advocate
you made my day

another great lisp
thx
0 Likes