r4n Posted June 10, 2011 Posted June 10, 2011 howdy, I found this code: (defun c:ppav () (vl-load-com) (setq *model-space* (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq obj (vlax-ename->vla-object (car (entsel)))) (setq c (vlax-get obj "Coordinates") i 0) (repeat (/ (length c) 2) (setq x (nth i c) y (nth (1+ i) c)) (vla-addpoint *model-space* (vlax-3d-point (list x y 0.0))) (setq i (+ i 2)) (setq temp (osnap (list x y) "mid")) ; I added this (command "point" temp) ; and this ) (princ) ) and added the two lines to try and get points set on the midpoints of the pline segments....but it does not work as intended. Some midpoints are set on the wrong segment and 1 extra point is being set. Can Anyone Help? thanks Ray Quote
BlackBox Posted June 10, 2011 Posted June 10, 2011 Instead, consider using the vlax-curve* functions on the *Line's Object/Ename. For example, I think you'll find the vlax-curve-getDistAtParam, and vlax-curve-getParamAtDist functions to be of use. Quote
Lee Mac Posted June 10, 2011 Posted June 10, 2011 Firstly, a warm welcome to CADTutor Ray I would suggest the vlax-curve-getpointatparam function since the vertices of an LWPolyline have integer parameters, and hence the midpoints can be found at the half values of the parameters. Here is some quickly written code: (defun c:test ( / e i p s ) (vl-load-com) (if (setq s (ssget '((0 . "LWPOLYLINE")))) (repeat (setq i (sslength s)) (repeat (1+ (fix (* 2 (vlax-curve-getendparam (setq p -0.5 e (ssname s (setq i (1- i)))))))) (entmakex (list (cons 0 "POINT") (cons 10 (vlax-curve-getpointatparam e (setq p (+ p 0.5)))))) ) ) ) (princ) ) Quote
r4n Posted June 14, 2011 Author Posted June 14, 2011 Thanks Folks! this is exactly what was needed! best regards ray 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.