也许这个口齿不清也会这样做
- ;;; FLATTEN.LSP version 2k.01, 25-Jun-1999
- ;;;
- ;;; FLATTEN sets the Z-coordinates of these types of objects to 0
- ;;; in the World Coordinate System:
- ;;; "3DFACE" "ARC" "ATTDEF" "CIRCLE" "DIMENSION"
- ;;; "ELLIPSE" "HATCH" "INSERT" "LINE" "LWPOLYLINE"
- ;;; "MTEXT" "POINT" "POLYLINE" "SOLID" "TEXT"
- ;;;
- ;;;-----------------------------------------------------------------------
- ;;; copyright 1990-1999 by Mark Middlebrook
- ;;; Daedalus Consulting
- ;;; e-mail: markmiddlebrook@compuserve.com
- ;;;
- ;;; Thanks to Vladimir Livshiz for improvements in polyline handling
- ;;; and the addition of several other object types.
- ;;;
- ;;; You are free to distribute FLATTEN.LSP to others so long as you do not
- ;;; charge for it.
- ;;;
- ;;;-----------------------------------------------------------------------
- ;;; Revision history
- ;;; v. 2k.0 25-May-1999 First release for AutoCAD 2000.
- ;;; v. 2k.01 25-Jun-1999 Fixed two globalization bugs ("_World" & "_X")
- ;;; and revised error handler.
- ;;;-----------------------------------------------------------------------
- ;;;*Why Use FLATTEN?
- ;;;
- ;;; FLATTENing is useful in at least two situations:
- ;;; 1) You receive a DXF file created by another CAD program and discover
- ;;; that all the Z coordinates contain small round-off errors. These
- ;;; round-off errors can prevent you from object snapping to
- ;;; intersections and make your life difficult in other ways as well.
- ;;; 2) In a supposedly 2D drawing, you accidentally create one object with
- ;;; a Z elevation and end up with a drawing containing objects partly
- ;;; in and partly outside the Z=0 X-Y plane. As with the round-off
- ;;; problem, this situation can make object snaps and other procedures
- ;;; difficult.
- ;;;
- ;;; Warning: FLATTEN is not for flattening the custom objects created by
- ;;; applications such as Autodesk's Architectural Desktop. ADT and similar
- ;;; programs create "application-defined objects" that only the
- ;;; application really knows what to do with. FLATTEN has no idea how
- ;;; to handle application-defined objects, so it leaves them alone.
- ;;;
- ;;;-----------------------------------------------------------------------
- ;;;*How to Use FLATTEN
- ;;;
- ;;; This version of FLATTEN works with AutoCAD R12 through 2000.
- ;;;
- ;;; To run FLATTEN, load it using AutoCAD's APPLOAD command, or type:
- ;;; (load "FLATTEN")
- ;;; at the AutoCAD command prompt. Once you've loaded FLATTEN.LSP, type:
- ;;; FLATTEN
- ;;; to run it. FLATTEN will tell you what it's about to do and ask you
- ;;; to confirm that you really want to flatten objects in the current
- ;;; drawing. If you choose to proceed, FLATTEN prompts you to select objects
- ;;; to be flattened (press ENTER to flatten all objects in the drawing).
- ;;; After you've selected objects and pressed ENTER, FLATTEN goes to work.
- ;;; It reports the number of objects it flattens and the number left
- ;;; unflattenened (because they were objects not recognized by FLATTEN; see
- ;;; the list of supported objects above).
- ;;;
- ;;; If you don't like the results, just type U to undo FLATTEN's work.
- ;;;
- ;;;-----------------------------------------------------------------------
- ;;;*Known limitations
- ;;; 1) FLATTEN doesn't support all of AutoCAD's object types. See above
- ;;; for a list of the object types that it does work on.
- ;;; 2) FLATTEN doesn't flatten objects nested inside of blocks.
- ;;; (You can explode blocks before flattening. Alternatively, you can
- ;;; WBLOCK block definitions to separate DWG files, run FLATTEN in
- ;;; each of them, and then use INSERT in the parent drawing to update
- ;;; the block definitions. Neither of these methods will flatten
- ;;; existing attributes, though.
- ;;; 3) FLATTEN flattens objects onto the Z=0 X-Y plane in AutoCAD's
- ;;; World Coordinate System (WCS). It doesn't currently support
- ;;; flattening onto other UCS planes.
- ;;;
- ;;;=======================================================================
- (defun C:FLATTEND (/ tmpucs olderr oldcmd zeroz ss1 ss1len
- i numchg numnot numno0 ssno0 ename elist
- etype yorn vrt crz
- )
- (setq tmpucs "$FLATTEN-TEMP$") ;temporary UCS
- ;;Error handler
- (setq olderr *error*)
- (defun *error* (msg)
- (if (or
- (= msg "Function cancelled")
- (= msg "quit / exit abort")
- )
- ;;if user cancelled or program aborted, exit quietly
- (princ)
- ;;otherwise report error message
- (princ (strcat "\nError: " msg))
- )
- (setq *error* olderr)
- (if (tblsearch "UCS" tmpucs)
- (command "._UCS" "_Restore" tmpucs "._UCS" "_Delete" tmpucs)
- )
- (command "._UNDO" "_End")
- (setvar "CMDECHO" oldcmd)
- (princ)
- )
- ;;Function to change Z coordinate to 0
- (defun zeroz (key zelist / oplist nplist)
- (setq oplist (assoc key zelist)
- nplist (reverse (append '(0.0) (cdr (reverse oplist))))
- zelist (subst nplist oplist zelist)
- )
- (entmod zelist)
- )
- ;;Setup
- (setq oldcmd (getvar "CMDECHO"))
- (setvar "CMDECHO" 0)
- (command "._UNDO" "_Group")
|