Is it possible to covert a line to a spline?

Is it possible to covert a line to a spline?

Anonymous
Not applicable
9,838 Views
6 Replies
Message 1 of 7

Is it possible to covert a line to a spline?

Anonymous
Not applicable

Hello,

 

let me explain my current situation. My work is running a copy of AutoCAD 2010 that we do some our wire diagrams on. Unfortunately, we sometimes have to use them in another program that doesn't not support the file type AutoCAD uses. After losing about 2 hours of work today due to a corrupted save, I just started trying to find a creative way around the importing display issue. What I found was odd.

 

Most of our diagrams were drawn using lines, and when imported where scaled up and out of proportion (not AutoCAD's fault). Whats weird is that i discovered that some of our files were drawn using splines, and that these imported over almost perfectly. 

 

Actual Question

Is there a way to convert a line and arc into a spline? If so, is it possible to do it utilizing multiple selected objects?

0 Likes
Accepted solutions (2)
9,839 Views
6 Replies
Replies (6)
Message 2 of 7

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....

Is there a way to convert a line and arc into a spline? If so, is it possible to do it utilizing multiple selected objects?


A routine could easily be written that would take all selected Line objects and draw two-point Splines over them, and get rid of the Lines if you like.  Arcs are another matter....  Drawing a Spline using the ends and midpoint of an Arc doesn't result in an arc-shaped Spline.  If you draw a Spline that meets an Arc at one end, and use Join to connect them together, then Break the original Spline part off, you end up with a Spline in the shape of the Arc [within certain tolerances, I suppose].  I don't know of a way to just convert an Arc into a Spline [the way you can convert one into a Polyline] without Joining it to a Spline like that as an intermediate step.  Automating that might be possible, but could be tricky.  I don't know how a Spline gets itself into a good arc shape, so it's hard to say whether some kind of calculations could be done from the Arc, and a Spline drawn using the results.

Kent Cooper, AIA
0 Likes
Message 3 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

@Kent1Cooper wrote:

A routine could easily be written that would take all selected Line objects and draw two-point Splines over them, and get rid of the Lines if you like.  ....


Like this, for instance:

 

(defun C:L2S (/ ss lin ldata); = Line(s) [to] Spline(s)
  (prompt "\nTo convert Line(s) to Spline(s),")
  (if (setq ss (ssget '((0 . "LINE"))))
    (repeat (setq n (sslength ss))
      (setq
        lin (ssname ss (setq n (1- n)))
        ldata (entget lin)
      ); setq
      (command
        "_.spline" "_none" (cdr (assoc 10 ldata)) "_none" (cdr (assoc 11 ldata)) "" "" ""
        "_.erase" lin ""
      ); command
    ); repeat
  ); if
  (princ)
); defun
Kent Cooper, AIA
0 Likes
Message 4 of 7

Emmsleys
Alumni
Alumni

Did any of the posts in the thread help with you issue?

Post back in the thread if you are still having an issue with AutoCAD I'm sure the community will be more than happy to help.



Sarah Emmsley
Technical Support Specialist

0 Likes
Message 5 of 7

Anonymous
Not applicable
Accepted solution

I would use PEDIT to make a polyline out of your Lines and Arcs. 

 

I don't see the use of a Spline from what I read. 

 

PEDIT

  - Multiple

      - Select your lines and arcs 

            - Join 

 

I find pline a lot easier to work with than spline. 

 

Again, 

just a suggestion

       

 

0 Likes
Message 6 of 7

Anonymous
Not applicable

The best way in my opinion is to use command "join" to make a polyline of your lines. Then type command "pedit"; press enter; type "Spline"; press enter;

This should do the trick.  

0 Likes
Message 7 of 7

j.palmeL29YX
Mentor
Mentor

Convert the lines/arcs to polylines (using PEDIT), then try the attached LISP. (I grabbed it somewhere in the web, a lot of thanks to the unknown author)

 

cadder

 

;;; Convert PL to SPline. 



(defun C:PL2SPL ( / ss i acc)
  (vl-load-com)
  (initget (+ 1 2 4))
  (setq acc (getint "\nPrecision: "))
  (if
    (setq ss (ssget '((0 . "*POLYLINE"))))
    (repeat (setq i (sslength ss))
      (make_spline
        (pl_list (ssname ss (setq i (1- i))))
      )
    )
  )
  (princ)
)

(defun pl_list (e / r i j lg)
 (setq lg (* 0.05 (vlax-curve-getdistatparam e (vlax-curve-getendparam e))))  
  
  (repeat (setq i (1+ (fix (vlax-curve-getEndParam e))))
    (setq r (cons (cons 11 (vlax-curve-GetPointAtParam e (setq i (1- i)))) r))
    (if
      (and
        (> i 0)
        (> (- (vlax-curve-getdistatparam e i) (vlax-curve-getdistatparam e (1- i))) lg)
        )
      (repeat (setq j (1- acc))
        (setq r (cons (cons 11 (vlax-curve-GetPointAtParam e (+ (1- i) (* (/ 1.0 acc) j)))) r)
              j (1- j)
              )
        )
      )
    )
  r
)

(defun make_spline (l)
  (entmake
    (append
      (list
        '(0 . "SPLINE")
        '(100 . "AcDbEntity")
        '(100 . "AcDbSpline")
        '(70 . 1)
        '(71 . 3)
        (cons 74 (length l))
        '(44 . 1.0e-005)
      )
      l
    )
  )
)

 

Jürgen Palme
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes