Jump to content

Recommended Posts

Posted

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... :cry:

 

(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

Posted

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

Posted

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

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