+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Super Member
    Using
    AutoCAD 2010
    Join Date
    Dec 2010
    Posts
    1,229

    Default cant flatten a drawing

    Registered forum members do not see this ad.

    hi

    i cant flatten this dwg.

    can anyone take a look?

    thanks
    Shay

  2. #2
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,603

    Default

    I used Zero.lsp and it said "all done" problem is I do not want to spend 1/2 hour searching for non zero objects.

    Please post dwg with objects that Flatten does not work on so we can help you. You have posted so obviously there are objects with non zero.

    Any one a lisp non zero objects ??
    A man who never made mistakes never made anything

  3. #3
    Super Member
    Using
    AutoCAD 2010
    Join Date
    Dec 2010
    Posts
    1,229

    Default

    the drawing ive posted is after flattern.lsp but it didnt help

    i didnt get what you are saying

    flatten didnt edit anything in this drawing

  4. #4
    Senior Member pendean's Avatar
    Computer Details
    pendean's Computer Details
    Operating System:
    Windows 10 64it Pro
    Computer:
    Lenovo WorkStation
    Discipline
    Architectural
    Using
    AutoCAD 2018
    Join Date
    Jun 2011
    Location
    Texas
    Posts
    132

    Default

    Use this lisp, it worked on your file just fine to move all of your errant objects back to Z=0.

    Code:
    ; FLATTEN3 flattens entities onto the Z=0 X-Y plane in AutoCAD's World Coordinate System (WCS).
    (defun C:FLATTEN3 (/ olderr oldcmd ss1 ss1len i numchg numnot numno0 ssno0
                        ename elist etype yorn)
    ;*error handler
       (setq olderr *error*)
       (defun *error* (msg)
          (if (= msg "quit / exit abort")
             (princ)
             (princ (strcat "error: " msg))
          )
          (setq *error* olderr)
          (command "._UCS" "_Restore" "$FLATTEN-TEMP$"
                   "._UCS" "_Delete" "$FLATTEN-TEMP$")
          (command "._UNDO" "_End")
          (setvar "CMDECHO" oldcmd)
          (princ)
       )
    
    ;*setup
       (setq oldcmd (getvar "CMDECHO"))
       (setvar "CMDECHO" 0)
       (command "._UNDO" "_Group")
       (command "._UCS" "_Save" "$FLATTEN-TEMP$" "._UCS" "World") ;set World UCS
    
    ;*get input
       (prompt (strcat 
          "\nFLATTEN sets the Z coordinates of lines, polylines, circles, arcs,"
          "\ntext, dimensions, block inserts, points, hatches, and solids to zero."
       ))
    
       (initget "Yes No")
       (setq yorn (getkword "\nDo you want to continue <Y>: "))
       (cond ((/= yorn "No")
             (graphscr)  
             (prompt "\nChoose entities to FLATTEN ")
             (prompt "[press return to select all entities in the drawing]")
             (setq ss1 (ssget))
             (if (null ss1)             ;if enter...
                 (setq ss1 (ssget "X"))    ;select all entities in database
             )
    
    
    ;*initialize variables
             (setq ss1len (sslength ss1)   ;length of selection set
                   i 0                     ;loop counter
                   numchg 0                ;number changed counter
                   numnot 0                ;number not changed counter
                   numno0 0                ;number not changed and Z /= 0 counter
                   ssno0 (ssadd)           ;selection set of unchanged entities
             );setq
    
    ;*do the work
             (prompt "\nWorking.")
             (while (< i ss1len)                    ;while more members in the SS
                (if (= 0 (rem i 10)) (prompt "."))
                (setq ename (ssname ss1 i)             ;entity name
                      elist (entget ename)             ;entity data list
                      etype (cdr (assoc 0 elist))      ;entity type
                )
    
    ;*Keep track of entities not flattened
                (if (not (member etype 
                                 '("LINE" "POLYLINE" "TEXT" "INSERT" 
                                   "CIRCLE" "ARC" "POINT" "SOLID" 
                                   "DIMENSION" "LWPOLYLINE" "HATCH" "MTEXT")))
                   (progn                           ;leave others alone
                      (setq numnot (1+ numnot))     
                      (if (/= 0.0 (car (reverse (assoc 10 elist))))
                         (progn                  ;add it to special list if Z /= 0
                            (setq numno0 (1+ numno0))
                            (ssadd ename ssno0)
                         )
                      )
                   )
                )
    
    ;*change group 10 Z coordinate to 0 for listed entity types
                (if (member etype '("LINE" "POLYLINE" "TEXT" "INSERT" "CIRCLE"
                                     "ARC" "POINT" "SOLID" "DIMENSION" "HATCH" 
                                     "MTEXT"))
                   (setq elist (zeroz 10 elist)     ;change entities in list above
                         numchg (1+ numchg)
                   )
                )
    
    ;*change group 11 Z coordinate to 0 for LINEs, TEXT, and SOLIDs
                (if (member etype '("LINE" "TEXT" "SOLID" "DIMENSION"))
                   (setq elist (zeroz 11 elist))
                )
    
    ;*change groups 12 and 13 Z coordinate to 0 for SOLIDs
                (if (member etype '("SOLID"))
                   (progn
                      (setq elist (zeroz 12 elist))
                      (setq elist (zeroz 13 elist))
                   )
                )
    
    ;*change groups 13, 14, 15, and 16 Z coordinate to 0 for DIMENSIONs
                (if (member etype '("DIMENSION"))
                   (progn
                      (setq elist (zeroz 13 elist))
                      (setq elist (zeroz 14 elist))
                      (setq elist (zeroz 15 elist))
                      (setq elist (zeroz 16 elist))
                   )
                )
    
    ;*special handling for R14 LWPOLYLINEs
                (if (member etype '("LWPOLYLINE"))
                   (progn
                      (setq elist (subst (cons 38 0.0) (assoc 38 elist) elist)
                            numchg (1+ numchg)
                      )
                      (entmod elist)
                   )
                )
    
                (setq i (1+ i))               ;next entity
             );while
             (prompt " Done.")
    
    ;*print results
             (prompt (strcat "\n" (itoa numchg) " entity(s) flattened"))
             (prompt (strcat "\n" (itoa numnot) " entity(s) not flattened"))
    
             (if (/= 0 numno0)          ;if there any entities in ssno0, show them
                (progn
                   (prompt (strcat "  [" (itoa numno0) 
                         " with non-zero base points]"))
                   (getstring "\nPress enter to see non-zero unchanged entities... ")
                   (command "._SELECT" ssno0)
                   (getstring "\nPress enter to unhighlight them... ")
                   (command "")
                )
             )
       ))
    
       (command "._UCS" "_Restore" "$FLATTEN-TEMP$"
                "._UCS" "_Delete" "$FLATTEN-TEMP$")
       (command "._UNDO" "_End")
       (setvar "CMDECHO" oldcmd)
       (setq *error* olderr)
       (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)
    )
    (princ);end
    Last edited by rkmcswain; 13th Jun 2018 at 03:27 pm. Reason: added [CODE] tags
    --
    Dean Saadallah
    AutoCAD and LT User
    BLOG|TW|FB|PIN
    --

  5. #5
    Super Member
    Using
    AutoCAD 2010
    Join Date
    Dec 2010
    Posts
    1,229

    Default

    i get this :

    Command: FLATTEN3
    Yes or No, please.
    error: Function cancelled
    Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
    Converting (command) calls to (command-s) is recommended.
    UCS "$FLATTEN-TEMP$" already exists. Replace it? <N>

  6. #6
    Senior Member pendean's Avatar
    Computer Details
    pendean's Computer Details
    Operating System:
    Windows 10 64it Pro
    Computer:
    Lenovo WorkStation
    Discipline
    Architectural
    Using
    AutoCAD 2018
    Join Date
    Jun 2011
    Location
    Texas
    Posts
    132

    Default

    Are you still on AutoCAD 2010? Simply start PROPERTIES, select everything on screen, sort by object type in the pulldown and set any/all Z settings to 0 (that's a zero). Should take about 3-minutes max to fix your Z=something problem entities.
    --
    Dean Saadallah
    AutoCAD and LT User
    BLOG|TW|FB|PIN
    --

  7. #7
    Super Member
    Using
    AutoCAD 2010
    Join Date
    Dec 2010
    Posts
    1,229

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by pendean View Post
    Use this lisp, it worked on your file just fine to move all of your errant objects back to Z=0.

    Code:
    ; FLATTEN3 flattens entities onto the Z=0 X-Y plane in AutoCAD's World Coordinate System (WCS).
    (defun C:FLATTEN3 (/ olderr oldcmd ss1 ss1len i numchg numnot numno0 ssno0
                        ename elist etype yorn)
    ;*error handler
       (setq olderr *error*)
       (defun *error* (msg)
          (if (= msg "quit / exit abort")
             (princ)
             (princ (strcat "error: " msg))
          )
          (setq *error* olderr)
          (command "._UCS" "_Restore" "$FLATTEN-TEMP$"
                   "._UCS" "_Delete" "$FLATTEN-TEMP$")
          (command "._UNDO" "_End")
          (setvar "CMDECHO" oldcmd)
          (princ)
       )
    
    ;*setup
       (setq oldcmd (getvar "CMDECHO"))
       (setvar "CMDECHO" 0)
       (command "._UNDO" "_Group")
       (command "._UCS" "_Save" "$FLATTEN-TEMP$" "._UCS" "World") ;set World UCS
    
    ;*get input
       (prompt (strcat 
          "\nFLATTEN sets the Z coordinates of lines, polylines, circles, arcs,"
          "\ntext, dimensions, block inserts, points, hatches, and solids to zero."
       ))
    
       (initget "Yes No")
       (setq yorn (getkword "\nDo you want to continue <Y>: "))
       (cond ((/= yorn "No")
             (graphscr)  
             (prompt "\nChoose entities to FLATTEN ")
             (prompt "[press return to select all entities in the drawing]")
             (setq ss1 (ssget))
             (if (null ss1)             ;if enter...
                 (setq ss1 (ssget "X"))    ;select all entities in database
             )
    
    
    ;*initialize variables
             (setq ss1len (sslength ss1)   ;length of selection set
                   i 0                     ;loop counter
                   numchg 0                ;number changed counter
                   numnot 0                ;number not changed counter
                   numno0 0                ;number not changed and Z /= 0 counter
                   ssno0 (ssadd)           ;selection set of unchanged entities
             );setq
    
    ;*do the work
             (prompt "\nWorking.")
             (while (< i ss1len)                    ;while more members in the SS
                (if (= 0 (rem i 10)) (prompt "."))
                (setq ename (ssname ss1 i)             ;entity name
                      elist (entget ename)             ;entity data list
                      etype (cdr (assoc 0 elist))      ;entity type
                )
    
    ;*Keep track of entities not flattened
                (if (not (member etype 
                                 '("LINE" "POLYLINE" "TEXT" "INSERT" 
                                   "CIRCLE" "ARC" "POINT" "SOLID" 
                                   "DIMENSION" "LWPOLYLINE" "HATCH" "MTEXT")))
                   (progn                           ;leave others alone
                      (setq numnot (1+ numnot))     
                      (if (/= 0.0 (car (reverse (assoc 10 elist))))
                         (progn                  ;add it to special list if Z /= 0
                            (setq numno0 (1+ numno0))
                            (ssadd ename ssno0)
                         )
                      )
                   )
                )
    
    ;*change group 10 Z coordinate to 0 for listed entity types
                (if (member etype '("LINE" "POLYLINE" "TEXT" "INSERT" "CIRCLE"
                                     "ARC" "POINT" "SOLID" "DIMENSION" "HATCH" 
                                     "MTEXT"))
                   (setq elist (zeroz 10 elist)     ;change entities in list above
                         numchg (1+ numchg)
                   )
                )
    
    ;*change group 11 Z coordinate to 0 for LINEs, TEXT, and SOLIDs
                (if (member etype '("LINE" "TEXT" "SOLID" "DIMENSION"))
                   (setq elist (zeroz 11 elist))
                )
    
    ;*change groups 12 and 13 Z coordinate to 0 for SOLIDs
                (if (member etype '("SOLID"))
                   (progn
                      (setq elist (zeroz 12 elist))
                      (setq elist (zeroz 13 elist))
                   )
                )
    
    ;*change groups 13, 14, 15, and 16 Z coordinate to 0 for DIMENSIONs
                (if (member etype '("DIMENSION"))
                   (progn
                      (setq elist (zeroz 13 elist))
                      (setq elist (zeroz 14 elist))
                      (setq elist (zeroz 15 elist))
                      (setq elist (zeroz 16 elist))
                   )
                )
    
    ;*special handling for R14 LWPOLYLINEs
                (if (member etype '("LWPOLYLINE"))
                   (progn
                      (setq elist (subst (cons 38 0.0) (assoc 38 elist) elist)
                            numchg (1+ numchg)
                      )
                      (entmod elist)
                   )
                )
    
                (setq i (1+ i))               ;next entity
             );while
             (prompt " Done.")
    
    ;*print results
             (prompt (strcat "\n" (itoa numchg) " entity(s) flattened"))
             (prompt (strcat "\n" (itoa numnot) " entity(s) not flattened"))
    
             (if (/= 0 numno0)          ;if there any entities in ssno0, show them
                (progn
                   (prompt (strcat "  [" (itoa numno0) 
                         " with non-zero base points]"))
                   (getstring "\nPress enter to see non-zero unchanged entities... ")
                   (command "._SELECT" ssno0)
                   (getstring "\nPress enter to unhighlight them... ")
                   (command "")
                )
             )
       ))
    
       (command "._UCS" "_Restore" "$FLATTEN-TEMP$"
                "._UCS" "_Delete" "$FLATTEN-TEMP$")
       (command "._UNDO" "_End")
       (setvar "CMDECHO" oldcmd)
       (setq *error* olderr)
       (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)
    )
    (princ);end
    it works!@
    thanks!

Similar Threads

  1. Flatten a drawing
    By samifox in forum CAD Management
    Replies: 7
    Last Post: 21st Apr 2017, 10:20 pm
  2. Can't FLATTEN a particular drawing
    By bababarghi in forum AutoCAD Drawing Management & Output
    Replies: 7
    Last Post: 6th Jan 2016, 11:22 am
  3. Please help flatten my drawing
    By kizaerf in forum AutoCAD Drawing Management & Output
    Replies: 4
    Last Post: 28th Jul 2014, 12:53 pm
  4. Flatten 3D drawing to 2D
    By gtwatson in forum AutoCAD Beginners' Area
    Replies: 12
    Last Post: 25th May 2011, 01:15 pm
  5. flatten drawing to 2d
    By jkaran in forum AutoCAD Drawing Management & Output
    Replies: 4
    Last Post: 12th Dec 2005, 09:10 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts