CADTutor
3rd Dec 2004, 07:31 pm
Flatten
This routine will flatten a 3D drawing so that all Z values are set to zero. Although LDT has a specific function for this purpose, if you're using plain AutoCAD, this neat routine could save hours.
; Flatten a 3D drawing
; Written by Eduard
; This command will set all elevations and points to zero, efectively flattening any 3D drawing.
;
(defun c:flat (/ total-nabor)
(vl-load-com)
(if
(setq total-nabor (ssget "x" '((410 . "model"))))
(progn
(setq total-nabor
(mapcar 'vlax-ename->vla-object
(mapcar 'cadr
(ssnamex total-nabor)
) ;_ end of mapcar
) ;_ end of mapcar
) ;_ end of setq
(foreach i '(1e99 -1e99)
(mapcar (function (lambda (x)
(vla-move x
(vlax-3d-point (list 0 0 0))
(vlax-3d-point (list 0 0 i))
) ;_ end of vla-move
) ;_ end of lambda
) ;_ end of function
total-nabor
) ;_ end of mapcar
) ;_ end of foreach
) ;_ end of progn
) ;_ end of if
(princ)
) ;_ end of defun
Download flat.lsp (http://www.cadimage.net/cadtutor/lisp/files/flat.lsp) 0.93 KB
See the original topic (http://www.cadtutor.net/forum/viewtopic.php?t=2119) for more details.
This routine will flatten a 3D drawing so that all Z values are set to zero. Although LDT has a specific function for this purpose, if you're using plain AutoCAD, this neat routine could save hours.
; Flatten a 3D drawing
; Written by Eduard
; This command will set all elevations and points to zero, efectively flattening any 3D drawing.
;
(defun c:flat (/ total-nabor)
(vl-load-com)
(if
(setq total-nabor (ssget "x" '((410 . "model"))))
(progn
(setq total-nabor
(mapcar 'vlax-ename->vla-object
(mapcar 'cadr
(ssnamex total-nabor)
) ;_ end of mapcar
) ;_ end of mapcar
) ;_ end of setq
(foreach i '(1e99 -1e99)
(mapcar (function (lambda (x)
(vla-move x
(vlax-3d-point (list 0 0 0))
(vlax-3d-point (list 0 0 i))
) ;_ end of vla-move
) ;_ end of lambda
) ;_ end of function
total-nabor
) ;_ end of mapcar
) ;_ end of foreach
) ;_ end of progn
) ;_ end of if
(princ)
) ;_ end of defun
Download flat.lsp (http://www.cadimage.net/cadtutor/lisp/files/flat.lsp) 0.93 KB
See the original topic (http://www.cadtutor.net/forum/viewtopic.php?t=2119) for more details.