Lee Mac Posted February 28, 2009 Posted February 28, 2009 Hi Guys, Was trying to help another user in the ACAD General Forum who wanted to draw a spline midway between two other splines. I made a LISP that would construct a pline midway between the splines, but couldn't stop it from endlessly looping... This is driving me up the wall, as its a relatively simple LISP and not much could really go wrong... (defun c:off (/ vLst oVar aEnt bEnt acy i pnt nrpnt) (vl-load-com) (setq vLst (list "CMDECHO" "OSMODE" "CLAYER") oVar (mapcar 'getvar vLst)) (setvar "CMDECHO" 0) (setvar "OSMODE" 0) (if (not (tblsearch "LAYER" "INTERMEDIATE")) (command "-layer" "M" "INTERMEDIATE" "_C" "15" "INTERMEDIATE" "") (setvar "CLAYER" "INTERMEDIATE")) (if (and (setq aEnt (car (entsel "\nSelect First Contour... ")) bEnt (car (entsel "\nSelect Second Contour..."))) (= "SPLINE" (cdadr (entget aEnt)) (cdadr (entget bEnt)))) (progn (setq acy 10.0 i 1.0) (command "_pline") (while (setq pnt (vlax-curve-GetPointAtDist aEnt (* i acy))) (setq nrpnt (vlax-curve-GetClosestPointTo bEnt pnt)) (command (polar pnt (angle pnt nrpnt) (/ (distance pnt nrpnt) 2))) (setq i (1+ i))) (command)) (princ "\nNo Spline Selected or this isn't a Spline...")) (mapcar 'setvar vLst oVar) (princ)) Any help is much appeciated as always Cheers Lee Quote
CarlB Posted February 28, 2009 Posted February 28, 2009 Perhaps "vlax-curve-GetPointAtDist " keeps returning a value even when distance is longer than line length. If so, first determine spline/curve length, then base loop on distance Quote
Lee Mac Posted February 28, 2009 Author Posted February 28, 2009 I think you may be right there Carl, I have tested it with Polylines, Lines etc and it works to perfection, just not with splines... May have to use the method you suggested. Thanks 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.