TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Q1241274614 on October 29, 2012, 11:23:30 AM

Title: help!
Post by: Q1241274614 on October 29, 2012, 11:23:30 AM

(VL-CMDF "_SPLINE")
       (mapcar 'command pt_mlist_01)
       (VL-CMDF "" "" "")
Title: Re: By POLYLINE node is converted to spline, use entmake to generate spline.
Post by: CAB on October 29, 2012, 12:10:34 PM
Example:
Code: [Select]
;;  Add Spline
(defun c:test ( / *mspace* p pts spline)
  (setq *mspace*
    (vla-get-ModelSpace
      (vla-get-ActiveDocument
        (vlax-get-acad-object)
      )
    )
  )
  (setq p (getpoint "\nPick point: "))
  (while (setq p (getpoint p "\nPick point: ")) (setq pts (cons p pts)))
  (setq pts (append pts (list (car pts))))
 
  (setq spline
    (vlax-invoke *mspace* 'AddSpline (apply 'append pts)
      '(0.0 0.0 0.0) '(0.0 0.0 0.0)
    )
  )
  (setq fd (vlax-curve-getFirstDeriv spline 0))
  (vlax-put spline 'StartTangent fd)
  (vlax-put spline 'EndTangent fd)
  (princ)
)
Title: Re: By POLYLINE node is converted to spline, How to use entmake to generate spline?
Post by: Tharwat on October 29, 2012, 12:19:36 PM
Hope this helps . :)

Code - Auto/Visual Lisp: [Select]
  1. (defun c:Pl2Sp (/ pl pts s)
  2. ;;; Tharwat 29. Oct. 2012 ;;;
  3.   (if (and (setq pl (car (entsel "\n Select Polyline :")))
  4.            (eq (cdr (assoc 0 (entget pl))) "LWPOLYLINE")
  5.       )
  6.     (progn
  7.       (mapcar '(lambda (x)
  8.                  (if (eq (car x) 10)
  9.                    (setq pts (cons (list (cadr x) (caddr x)) pts))
  10.                  )
  11.                )
  12.               (entget pl)
  13.       )
  14.       (setq s (entmake
  15.                 (append
  16.                   (list
  17.                     '(0 . "SPLINE")
  18.                     '(100 . "AcDbEntity")
  19.                     '(100 . "AcDbSpline")
  20.                     (cons 70 (length pts))
  21.                     '(71 . 3)
  22.                     (cons 74 (length pts))
  23.                     '(44 . 1.0e-010)
  24.                   )
  25.                   (mapcar '(lambda (x) (cons 11 x)) pts)
  26.                 )
  27.               )
  28.       )
  29.     )
  30.     (princ "\n Nothing selected or not LWpolyline ")
  31.   )
  32.   (if s
  33.     (entdel pl)
  34.   )
  35.   (princ)
  36. )
  37.  
Title: Re: By POLYLINE node is converted to spline, How to use entmake to generate spline?
Post by: CAB on October 29, 2012, 12:40:02 PM
Good one, but "LWPOLYLINE" may be better as it won't work with 3D or heavy plines.
Title: Re: By POLYLINE node is converted to spline, How to use entmake to generate spline?
Post by: Tharwat on October 29, 2012, 12:52:50 PM
Good one, but "LWPOLYLINE" may be better as it won't work with 3D or heavy plines.
Thanks CAB .

CODE UPDATED
Title: Re: By POLYLINE node is converted to spline, How to use entmake to generate spline?
Post by: Stefan on October 29, 2012, 01:58:09 PM
For every type of open Polyline
Code - Auto/Visual Lisp: [Select]
  1. (defun C:PL2SPL ( / ss i)
  2.   (if
  3.     (setq ss (ssget '((0 . "*POLYLINE"))))
  4.     (repeat (setq i (sslength ss))
  5.       (make_spline
  6.         (pl_list (ssname ss (setq i (1- i))))
  7.       )
  8.     )
  9.   )
  10.   (princ)
  11. )
  12.  
  13. (defun pl_list (e / r i)
  14.     (setq r (cons (cons 11 (vlax-curve-GetPointAtParam e (setq i (1- i)))) r))
  15.     )
  16.   r
  17. )
  18.  
  19. (defun make_spline (l)
  20.     (append
  21.       (list
  22.         '(0 . "SPLINE")
  23.         '(100 . "AcDbEntity")
  24.         '(100 . "AcDbSpline")
  25.         '(71 . 3)
  26.         (cons 74 (length l))
  27.         '(44 . 1.0e-005)
  28.       )
  29.       l
  30.     )
  31.   )
  32. )
For the closed ones, dxf code 70 must be set to a proper value.
Well, they have changed Splines in Acad2012 but DXF reference is the old one, with an incomplete description for dxf code 70.
If somebody has a newer version of DXF reference, I'll be glad if he'll share it with us.
Title: Re: By POLYLINE node is converted to spline, How to use entmake to generate spline?
Post by: Lee Mac on October 29, 2012, 02:01:26 PM
If somebody has a newer version of DXF reference, I'll be glad if he'll share it with us.

AutoCAD Exchange DXF Reference (http://exchange.autodesk.com/autocad/enu/online-help/browse#WS73099cc142f48755a52158612bd434e551-7fdd.htm)
Title: Re: By POLYLINE node is converted to spline, How to use entmake to generate spline?
Post by: Stefan on October 29, 2012, 02:10:22 PM
If somebody has a newer version of DXF reference, I'll be glad if he'll share it with us.

AutoCAD Exchange DXF Reference (http://exchange.autodesk.com/autocad/enu/online-help/browse#WS73099cc142f48755a52158612bd434e551-7fdd.htm)
Thank you Lee. I have that one but is incomplete. How do you explain this?
Title: Re: By POLYLINE node is converted to spline, How to use entmake to generate spline?
Post by: MP on October 29, 2012, 02:15:07 PM
How do you explain this?

Autodesk's robust QA/QC department.
Title: Re: By POLYLINE node is converted to spline, How to use entmake to generate spline?
Post by: Tharwat on October 29, 2012, 02:20:14 PM
The same in 2013 .

Title: Re: By POLYLINE node is converted to spline, How to use entmake to generate spline?
Post by: Stefan on October 29, 2012, 02:29:50 PM
Well, we can try to decode the secret.
Here is the same 3d Spline, closed in left and open in right.
Title: Re: By POLYLINE node is converted to spline, How to use entmake to generate spline?
Post by: Q1241274614 on October 29, 2012, 02:50:04 PM
thank