Author Topic: Changing 3d spline to 2d spline  (Read 2297 times)

0 Members and 1 Guest are viewing this topic.

csgoh

  • Newt
  • Posts: 176
Changing 3d spline to 2d spline
« on: August 02, 2007, 10:05:24 AM »
Need a kickstart as to how to change the 3d splines to a 2d splines ? I use autocad map 2004.

csgoh

  • Newt
  • Posts: 176
Re: Changing 3d spline to 2d spline
« Reply #1 on: August 02, 2007, 10:25:04 AM »
additional requirement - to add a constant to all the z -values .

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Changing 3d spline to 2d spline
« Reply #2 on: August 02, 2007, 10:28:35 AM »
{ ... authors will need to be mindful of ucs considerations ... }
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Changing 3d spline to 2d spline
« Reply #3 on: August 02, 2007, 12:36:10 PM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

csgoh

  • Newt
  • Posts: 176
Re: Changing 3d spline to 2d spline
« Reply #4 on: August 03, 2007, 01:06:32 AM »
i just found out that using the "flatten" command changes the 3d spline to a 2d lwpolyline.could someone explain why this is so? Cant figure it.

is it just possible to change the z values for the control points, fit ,etc without changing any other properties.

Joe Burke

  • Guest
Re: Changing 3d spline to 2d spline
« Reply #5 on: August 18, 2007, 06:08:59 AM »
Take a look at the FlatSpline sub-function in SuperFlatten. It's in show your stuff.

Note, it assumes WCS is active because that's how the program works.

Joe Burke

  • Guest
Re: Changing 3d spline to 2d spline
« Reply #6 on: August 18, 2007, 08:23:25 AM »
Try this.

  ;; Argument: a flat 3D coordinate list.
  ;; (setq l '(414.576 572.128 0.0 494.558 637.135 20.0 562.58 575.117 30.0))
  ;; Returns:
  ;; (414.576 572.128 0.0 494.558 637.135 0.0 562.58 575.117 0.0)
  (defun ZZeroCoord (coord / lst)
    (repeat (/ (length coord) 3)
      (setq lst (cons (car coord) lst)
            lst (cons (cadr coord) lst)
            lst (cons 0.0 lst)
            coord (cdddr coord)
      )
    )
    (reverse lst)
  ) ;end

  ;; Flatten a spline to Z elevation zero in WCS.
  ;; Note, fit points may be lost, but that can happen during
  ;; spline edit operations anyway. The spline should not change
  ;; shape when the view is parallel to WCS.
  (defun c:2DSpline ( / obj ctrlpts testpts kts)
    (if
      (and
        (setq obj (car (entsel "\nSelect spline: ")))
        (setq obj (vlax-ename->vla-object obj))
        (eq "AcDbSpline" (vlax-get obj 'ObjectName))
      )
      (progn
        (setq ctrlpts (vlax-get obj 'ControlPoints)
              testpts (ZZeroCoord ctrlpts)         
        )
        (if
          (or
            (eq acFalse (vlax-get obj 'IsPlanar))
            (not (equal ctrlpts testpts 1e-8))
          )
          (progn
            (setq kts (vlax-get obj 'Knots))
            (vlax-put obj 'ControlPoints testpts)
            (vlax-put obj 'Knots kts)
            (princ "\nSpline was modified. ")
          )
          (princ "\nSpline was not modified. ")
        )
      )
    )
    (princ)
  ) ;end