CADTutor Posted December 3, 2004 Posted December 3, 2004 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 0.93 KB See the original topic for more details. Quote
Lee Mac Posted April 14, 2009 Posted April 14, 2009 (edited) Below is a faster variation on the above: (defun c:flat ( / doc org ) (setq doc (vla-get-activedocument (vlax-get-acad-object)) org (vlax-3D-point 0 0 0) ) (vlax-for blk (vla-get-blocks doc) (if (= :vlax-false (vla-get-isxref blk)) (vlax-for obj blk (if (vlax-write-enabled-p obj) (foreach elv '(1e99 -1e99) (vla-move obj org (vlax-3D-point 0 0 elv))) ) ) ) ) (vla-regen doc acallviewports) (princ) ) (vl-load-com) (princ) Edited November 4, 2014 by Lee Mac Quote
symoin Posted December 19, 2018 Posted December 19, 2018 On 4/15/2009 at 1:26 AM, Lee Mac said: Below is a faster variation on the above: (defun c:flat ( / doc org ) (setq doc (vla-get-activedocument (vlax-get-acad-object)) org (vlax-3D-point 0 0 0) ) (vlax-for blk (vla-get-blocks doc) (if (= :vlax-false (vla-get-isxref blk)) (vlax-for obj blk (if (vlax-write-enabled-p obj) (foreach elv '(1e99 -1e99) (vla-move obj org (vlax-3D-point 0 0 elv))) ) ) ) ) (vla-regen doc acallviewports) (princ) ) (vl-load-com) (princ) how to select required objects and not all objects. Quote
ReMark Posted December 19, 2018 Posted December 19, 2018 You have managed to resurrect a thread from 12 years ago. One option would be to isolate the objects you want to flatten from all the other objects in the drawing. You are familiar with freezing layers are you not? 1 Quote
ketxu Posted December 19, 2018 Posted December 19, 2018 6 hours ago, symoin said: how to select required objects and not all objects. Maybe use the first post and supress "x" character ? Quote
symoin Posted December 20, 2018 Posted December 20, 2018 On 12/19/2018 at 3:04 PM, ReMark said: You have managed to resurrect a thread from 12 years ago. One option would be to isolate the objects you want to flatten from all the other objects in the drawing. You are familiar with freezing layers are you not? Today I am in a situation, which the mentors might have foreseen 12 years ago. Thanks for the archive. 1 Quote
symoin Posted December 20, 2018 Posted December 20, 2018 20 hours ago, ketxu said: Maybe use the first post and supress "x" character ? I could not locate the "x" as I believe this is visual lisp and not autolisp Quote
ReMark Posted December 20, 2018 Posted December 20, 2018 Attach a copy of the drawing to your next post. If the file size is too large then upload it to a file sharing website like DropBox and post a link to it here. Indicate what object(s) need to be flattened. Perhaps someone here can accomplish the task and provide you a copy of the result. Quote
Josue Rincon Posted January 28, 2019 Posted January 28, 2019 Hi! Use (setq total-nabor (ssget)) instead of (setq total-nabor (ssget "x" '((410 . "model")))) ssget without arguments will prompt the user to select objects through the AutoCAD general 'Select objects:' mechanism. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.