Registered forum members do not see this ad.
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.
Download flat.lsp 0.93 KBCode:; 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
See the original topic for more details.
Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.
AutoCAD Tutorials | How to add images to your posts | How to register successfully | Forum FAQ
Registered forum members do not see this ad.
A faster variation on the above:
The above routine will not flatten 3D blocks - if you require these to be flattened also, they will need to be exploded before running the routine.Code:(defun c:flat ( / acsel elv ) (vl-load-com) (if (ssget "_X" (list (cons 410 (getvar 'CTAB)))) (progn (vlax-for obj (setq acsel (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)) ) ) (foreach elv '(1e99 -1e99) (vl-catch-all-apply 'vla-move (list obj (vlax-3D-point '(0. 0. 0.)) (vlax-3D-point (list 0. 0. elv))) ) ) ) (vla-delete acsel) ) ) (princ) )
Last edited by Lee Mac; 6th Apr 2011 at 03:25 pm.
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
Bookmarks