Jump to content

Convert spline to polyline?


Interior

Recommended Posts

Hi, i was wondering if its is possible to convert a spline into a polyline because obviously you can't pedit i don't want to draw over it as it doesn't create a true solid but mainly because it changes the curve. or just a way to be able to extrude the curve. thank you

Link to comment
Share on other sites

See here: http://www.cadtutor.net/forum/showthread.php?t=9417

 

I've renamed this thread to something a little more appropriate, since your question really has more to do with converting splines to polylines than it does with extruding. You will notice at the bottom of this page there are now several 'Similar Threads' that relate to your question.

Link to comment
Share on other sites

I found this a while back - might suit you:

 

(defun c:CurvesToSegments(/ cSet sLen cLen sDis ptLst oOsn
             eLst cAns vCnt lPt)
 
 (vl-load-com)

 (princ "<<< Select curves to transform >>>")
 (if
   (setq cSet
      (ssget
         '((0 . "*POLYLINE,SPLINE,ARC,CIRCLE,ELLIPSE"))))
   (if(setq sLen(getdist "\nSpecify segment lentgth: "))
     (progn
   (setq oOsn(getvar "OSMODE"))
   (setvar "CMDECHO" 0)(setvar "OSMODE" 0)
       (foreach itm(setq eLst(vl-remove-if 'listp
                       (mapcar 'cadr(ssnamex cSet))))
   (setq sDis 0.0
         cLen(-(vlax-curve-getDistAtParam itm
             (vlax-curve-getEndParam itm))
           (vlax-curve-getDistAtParam itm
             (vlax-curve-getStartParam itm)))
           ); end setq
   (if(= "LWPOLYLINE"(cdr(assoc 0(entget itm))))
   (progn
     (setq vCnt 1
       ptLst(list(vlax-curve-GetPointAtDist itm sDis)))
      (while(and
          (<= sDis cLen)
          (vlax-curve-GetPointAtParam itm vCnt)
          (setq cPt(vlax-curve-GetPointAtDist itm sDis))
          ); end and
         (if(= 0.0(vla-GetBulge(vlax-ename->vla-object itm)(1- vCnt)))
       (setq ptLst(append ptLst
                 (list(vlax-curve-GetPointAtParam itm vCnt)))
             sDis(vlax-curve-GetDistAtParam itm vCnt)
             ); end setq
       (progn
         (while(<= sDis(vlax-curve-GetDistAtParam itm vCnt))
           (setq cPt(vlax-curve-GetPointAtDist itm sDis)
             ptLst(append ptLst(list cPt))
             sDis(+ sDis sLen))
           ); end while
         (setq ptLst(append ptLst
                 (list(vlax-curve-GetPointAtParam itm vCnt))))
         ); end progn
       ); end if
         (setq vCnt(1+ vCnt))
        ); end while
     ); end progn
      (while(and
          (<= sDis cLen)
          (setq cPt(vlax-curve-GetPointAtDist itm sDis))
          ); end and
        (setq ptLst(append ptLst(list cPt))
          sDis(+ sDis sLen))
      ); end while
     ); end if
     (if(not(equal(setq lPt(vlax-curve-getEndPoint itm))(last ptLst)))
       (setq ptLst(append ptLst(list lPt)))
      ); end if
   (command "_.pline")(mapcar 'command ptLst)(command "")
   (setq ptLst nil)
      ); end foreach
   (initget "Yes No")
   (setq cAns(getkword "\nRemove old curves [Yes/No] <Yes>: "))
   (if(or(null cAns)(= cAns "Yes"))
     (mapcar 'entdel eLst)
     ); end foreach
      (setvar "CMDECHO" 1)(setvar "OSMODE" oOsn)
     ); end progn
    ); end if
   ); end if
 (princ)
 ); end of c:CurvesToSegments

Link to comment
Share on other sites

Save is as a .lsp file, then in AutoCAD, go to load application, or type "appload" at the command line.

 

Load the file that you just saved.

 

Type the syntax at the command line to invoke the command - in this case:

 

CurvestoSegments

 

You can always change the syntax in the LISP file to something you can type easier - like c2s or something.

Link to comment
Share on other sites

Is there a way of making the spline a polyline without it changing the shape? because at the moment its moving the line and changing the position so it move into areas which have set distances is there a way of getting the line to run over where i have it already as a spline?

Link to comment
Share on other sites

I've done all these things repeated times and i can't get anything to place the line in the existing position will in places sit over the line and others places on the line sit correctly. i have tried turning it to world also and this has not helped. what else can i do?

Link to comment
Share on other sites

google spl2pl.lsp

 

its a lisp prog to convert splines to polys and it works great.

 

 

 

i can download it but then can't open it any suggestions

Link to comment
Share on other sites

If it is a .Vlx file, (which I think it is), you cannot open it. - it is a compiled file.

 

You will need to load it in AutoCAD, and just invoke it as you would a LISP.

 

As it is a compiled file, beware of the source as you do not know what may be in it... :unsure:

Link to comment
Share on other sites

When i convert to polyline it is not smooth it creates a new line which has ridges and not following the line created originally by the spline. i need it to run the same path as the spline because the stairs etc run to this already and cannot change. any ideas are greatly need as i have to fix it as its my final degree project. thank you

Link to comment
Share on other sites

  • 1 year later...
  • 6 years later...

Hi Lee Mac,

this is a nice Lisp, though when i'm not in "world coordinates" but have my crosshairs rotated north/south to suit my drawing, then this Lisp not only breaks a curve into smaller straight polylines, but it also moves and rotates the whole Thing...!?

Any idea why, or rather, whether there is a fix for it?

 

 

I found this a while back - might suit you:

 

(defun c:CurvesToSegments(/ cSet sLen cLen sDis ptLst oOsn
             eLst cAns vCnt lPt)
 
 (vl-load-com)

 (princ "<<< Select curves to transform >>>")
 (if
   (setq cSet
      (ssget
         '((0 . "*POLYLINE,SPLINE,ARC,CIRCLE,ELLIPSE"))))
   (if(setq sLen(getdist "\nSpecify segment lentgth: "))
     (progn
   (setq oOsn(getvar "OSMODE"))
   (setvar "CMDECHO" 0)(setvar "OSMODE" 0)
       (foreach itm(setq eLst(vl-remove-if 'listp
                       (mapcar 'cadr(ssnamex cSet))))
   (setq sDis 0.0
         cLen(-(vlax-curve-getDistAtParam itm
             (vlax-curve-getEndParam itm))
           (vlax-curve-getDistAtParam itm
             (vlax-curve-getStartParam itm)))
           ); end setq
   (if(= "LWPOLYLINE"(cdr(assoc 0(entget itm))))
   (progn
     (setq vCnt 1
       ptLst(list(vlax-curve-GetPointAtDist itm sDis)))
      (while(and
          (<= sDis cLen)
          (vlax-curve-GetPointAtParam itm vCnt)
          (setq cPt(vlax-curve-GetPointAtDist itm sDis))
          ); end and
         (if(= 0.0(vla-GetBulge(vlax-ename->vla-object itm)(1- vCnt)))
       (setq ptLst(append ptLst
                 (list(vlax-curve-GetPointAtParam itm vCnt)))
             sDis(vlax-curve-GetDistAtParam itm vCnt)
             ); end setq
       (progn
         (while(<= sDis(vlax-curve-GetDistAtParam itm vCnt))
           (setq cPt(vlax-curve-GetPointAtDist itm sDis)
             ptLst(append ptLst(list cPt))
             sDis(+ sDis sLen))
           ); end while
         (setq ptLst(append ptLst
                 (list(vlax-curve-GetPointAtParam itm vCnt))))
         ); end progn
       ); end if
         (setq vCnt(1+ vCnt))
        ); end while
     ); end progn
      (while(and
          (<= sDis cLen)
          (setq cPt(vlax-curve-GetPointAtDist itm sDis))
          ); end and
        (setq ptLst(append ptLst(list cPt))
          sDis(+ sDis sLen))
      ); end while
     ); end if
     (if(not(equal(setq lPt(vlax-curve-getEndPoint itm))(last ptLst)))
       (setq ptLst(append ptLst(list lPt)))
      ); end if
   (command "_.pline")(mapcar 'command ptLst)(command "")
   (setq ptLst nil)
      ); end foreach
   (initget "Yes No")
   (setq cAns(getkword "\nRemove old curves [Yes/No] <Yes>: "))
   (if(or(null cAns)(= cAns "Yes"))
     (mapcar 'entdel eLst)
     ); end foreach
      (setvar "CMDECHO" 1)(setvar "OSMODE" oOsn)
     ); end progn
    ); end if
   ); end if
 (princ)
 ); end of c:CurvesToSegments

Link to comment
Share on other sites

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