samifox Posted June 13, 2018 Share Posted June 13, 2018 hi i cant flatten this dwg. can anyone take a look? thanks Shay Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 13, 2018 Share Posted June 13, 2018 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 ?? Quote Link to comment Share on other sites More sharing options...
samifox Posted June 13, 2018 Author Share Posted June 13, 2018 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 Quote Link to comment Share on other sites More sharing options...
pendean Posted June 13, 2018 Share Posted June 13, 2018 (edited) Use this lisp, it worked on your file just fine to move all of your errant objects back to Z=0. ; 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 Edited June 13, 2018 by rkmcswain added [CODE] tags Quote Link to comment Share on other sites More sharing options...
samifox Posted June 13, 2018 Author Share Posted June 13, 2018 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? Quote Link to comment Share on other sites More sharing options...
pendean Posted June 13, 2018 Share Posted June 13, 2018 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. Quote Link to comment Share on other sites More sharing options...
samifox Posted June 13, 2018 Author Share Posted June 13, 2018 Use this lisp, it worked on your file just fine to move all of your errant objects back to Z=0. ; 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! Quote Link to comment Share on other sites More sharing options...
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.