PDA

View Full Version : Flatten a drawing



Vince0115
30th Mar 2005, 03:48 pm
Good morning, group

What don't I know yet here: a costomer sent in a drawing which looks like this: http://www.cadimage/postimages/CADpic.jpg. When I import it into my CAM program, it appears in 3 dimensions, with the title blocks and text/dimensions facing top and the drawing proper facing front, like this:http://www.cadimage.net/postimages/CAMpic.jpg.

Where do I go/what do I do, using 2005LT to rotate all entities to be visible in the top plane? In other words, how do I achieve a "flat" drawing to import into my CAM program?

Thanks in advance,

Vince

f700es
30th Mar 2005, 04:03 pm
My question is what are you going to do with an architectural floorplan in a CAM application :?
That looks like a milling machine/interface. Is it?

hendie
30th Mar 2005, 04:17 pm
maybe it's a water mill :lol:

Vince0115
30th Mar 2005, 04:21 pm
Our business is cutting architectural stone to shape and size.

Vince0115
30th Mar 2005, 04:23 pm
We rough mill the individual pieces to shape and size, then our stone cutters hand finish the pieces.

f700es
30th Mar 2005, 04:31 pm
Our business is cutting architectural stone to shape and size.

Ah!! That makes sense now. Didn't even think of that :oops: DOH!

CAB
30th Mar 2005, 06:07 pm
If you want to e-mail it to me I'll see if I can flatten it for you but I don't think you can do it in Acad Lt.

ab2draft@NoSpamTampabay.rr.com
Remove the NoSpam

Vince0115
30th Mar 2005, 06:16 pm
Thanks for the offer; I'll e-mail it under separate cover if necessary. The problem is, we have received drawings like this before, and will probably get more like it in the future. I don't want to have to impose on people every time one of these comes in.

The good news is: in addition to 2 seats of 2005LT, we also own 2 seats of 2005 "full". So if it takes the "full" version to flatten it, we ARE equipped to do it. I just don't know HOW to do it.

Again, if you want me to e-mail it, I will. And thanks.

Vince :?

CAB
30th Mar 2005, 06:33 pm
Have not tested this in acad2005 but give it a try.

;;; FLATTEN.LSP version 2k.01f, 14-Jul-2000
;;;
;;; 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-2000 by Mark Middlebrook
;;; Daedalus Consulting
;;; e-mail: mark@markcad.com
;;;
;;; Before you e-mail me with support questions, please make sure that
;;; you're using the current version. You can download it from
;;; http://markcad.com.
;;;
;;; This program is free software. You can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation: http://www.gnu.org/copyleft/gpl.html.
;;;
;;; Thanks to Vladimir Livshiz for improvements in polyline handling
;;; and the addition of several other object types.
;;;
;;;-----------------------------------------------------------------------
;;; 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.
;;; v. 2k.01f 14-Jul-1999 Added GNU GPL and download info to header.
;;;
;;;-----------------------------------------------------------------------
;;;*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:FLAT (/ 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")
(command "._UCS" "_Delete" tmpucs "._UCS" "_Save" tmpucs "._UCS" "_World")
;set World UCS

;;Get input
(prompt
(strcat
"\nFLATTEN sets the Z coordinates of most objects to zero."
)
)

(initget "Yes No")
&#40;setq yorn &#40;getkword "\nDo you want to continue <Y>&#58; "&#41;&#41;
&#40;cond &#40;&#40;/= yorn "No"&#41;
&#40;graphscr&#41;
&#40;prompt "\nChoose objects to FLATTEN "&#41;
&#40;prompt
"&#91;press return to select all objects in the drawing&#93;"
&#41;
&#40;setq ss1 &#40;ssget&#41;&#41;
&#40;if &#40;null ss1&#41; ;if enter...
&#40;setq ss1 &#40;ssget "_X"&#41;&#41; ;select all entities in database
&#41;


;;*initialize variables
&#40;setq ss1len &#40;sslength ss1&#41; ;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 &#40;ssadd&#41; ;selection set of unchanged entities
&#41; ;setq

;;*do the work
&#40;prompt "\nWorking."&#41;
&#40;while &#40;< i ss1len&#41; ;while more members in the SS
&#40;if &#40;= 0 &#40;rem i 10&#41;&#41;
&#40;prompt "."&#41;
&#41;
&#40;setq ename &#40;ssname ss1 i&#41; ;entity name
elist &#40;entget ename&#41; ;entity data list
etype &#40;cdr &#40;assoc 0 elist&#41;&#41; ;entity type
&#41;

;;*Keep track of entities not flattened
&#40;if &#40;not &#40;member etype
'&#40;"3DFACE" "ARC" "ATTDEF"
"CIRCLE" "DIMENSION" "ELLIPSE"
"HATCH" "INSERT" "LINE"
"LWPOLYLINE" "MTEXT" "POINT"
"POLYLINE" "SOLID" "TEXT"
&#41;
&#41;
&#41;
&#40;progn ;leave others alone
&#40;setq numnot &#40;1+ numnot&#41;&#41;
&#40;if &#40;/= 0.0 &#40;car &#40;reverse &#40;assoc 10 elist&#41;&#41;&#41;&#41;
&#40;progn ;add it to special list if Z /= 0
&#40;setq numno0 &#40;1+ numno0&#41;&#41;
&#40;ssadd ename ssno0&#41;
&#41;
&#41;
&#41;
&#41;

;;Change group 10 Z coordinate to 0 for listed entity types.
&#40;if &#40;member etype
'&#40;"3DFACE" "ARC" "ATTDEF" "CIRCLE"
"DIMENSION" "ELLIPSE" "HATCH" "INSERT"
"LINE" "MTEXT" "POINT" "POLYLINE"
"SOLID" "TEXT"
&#41;
&#41;
&#40;setq elist &#40;zeroz 10 elist&#41; ;change entities in list above
numchg &#40;1+ numchg&#41;
&#41;
&#41;

;;Change group 11 Z coordinate to 0 for listed entity types.
&#40;if &#40;member etype
'&#40;"3DFACE" "ATTDEF" "DIMENSION" "LINE" "TEXT" "SOLID"&#41;
&#41;
&#40;setq elist &#40;zeroz 11 elist&#41;&#41;
&#41;

;;Change groups 12 and 13 Z coordinate to 0 for SOLIDs and 3DFACEs.
&#40;if &#40;member etype '&#40;"3DFACE" "SOLID"&#41;&#41;
&#40;progn
&#40;setq elist &#40;zeroz 12 elist&#41;&#41;
&#40;setq elist &#40;zeroz 13 elist&#41;&#41;
&#41;
&#41;

;;Change groups 13, 14, 15, and 16
;;Z coordinate to 0 for DIMENSIONs.
&#40;if &#40;member etype '&#40;"DIMENSION"&#41;&#41;
&#40;progn
&#40;setq elist &#40;zeroz 13 elist&#41;&#41;
&#40;setq elist &#40;zeroz 14 elist&#41;&#41;
&#40;setq elist &#40;zeroz 15 elist&#41;&#41;
&#40;setq elist &#40;zeroz 16 elist&#41;&#41;
&#41;
&#41;

;;Change each polyline vertex Z coordinate to 0.
;;Code provided by Vladimir Livshiz, 09-Oct-1998
&#40;if &#40;= etype "POLYLINE"&#41;
&#40;progn
&#40;setq vrt ename&#41;
&#40;while &#40;not &#40;equal &#40;cdr &#40;assoc 0 &#40;entget vrt&#41;&#41;&#41; "SEQEND"&#41;&#41;
&#40;setq elist &#40;entget &#40;entnext vrt&#41;&#41;&#41;
&#40;setq crz &#40;cadddr &#40;assoc 10 elist&#41;&#41;&#41;
&#40;if &#40;/= crz 0&#41;
&#40;progn
&#40;zeroz 10 elist&#41;
&#40;entupd ename&#41;
&#41;
&#41;
&#40;setq vrt &#40;cdr &#40;assoc -1 elist&#41;&#41;&#41;
&#41;
&#41;
&#41;

;;Special handling for LWPOLYLINEs
&#40;if &#40;member etype '&#40;"LWPOLYLINE"&#41;&#41;
&#40;progn
&#40;setq elist &#40;subst &#40;cons 38 0.0&#41; &#40;assoc 38 elist&#41; elist&#41;
numchg &#40;1+ numchg&#41;
&#41;
&#40;entmod elist&#41;
&#41;
&#41;

&#40;setq i &#40;1+ i&#41;&#41; ;next entity
&#41;
&#40;prompt " Done."&#41;

;;Print results
&#40;prompt &#40;strcat "\n" &#40;itoa numchg&#41; " object&#40;s&#41; flattened."&#41;&#41;
&#40;prompt
&#40;strcat "\n" &#40;itoa numnot&#41; " object&#40;s&#41; not flattened."&#41;
&#41;

;;If there any entities in ssno0, show them
&#40;if &#40;/= 0 numno0&#41;
&#40;progn
&#40;prompt &#40;strcat " &#91;"
&#40;itoa numno0&#41;
" with non-zero base points&#93;"
&#41;
&#41;
&#40;getstring
"\nPress enter to see non-zero unchanged objects... "
&#41;
&#40;command "._SELECT" ssno0&#41;
&#40;getstring "\nPress enter to unhighlight them... "&#41;
&#40;command ""&#41;
&#41;
&#41;
&#41;
&#41;

&#40;command "._UCS" "_Restore" tmpucs "._UCS" "_Delete" tmpucs&#41;
&#40;command "._UNDO" "_End"&#41;
&#40;setvar "CMDECHO" oldcmd&#41;
&#40;setq *error* olderr&#41;
&#40;princ&#41;
&#41;

&#40;prompt
"\nFLATTEN version 2k.01f loaded. Type FLATTEN to run it."
&#41;
&#40;princ&#41;

;;;eof

Vince0115
30th Mar 2005, 07:34 pm
Many thanks, CAB

I'll have a chance to type it in upstairs at one of the "full" seats tomorrow morning; I'll let you know how it works.

Again, large amounts of "thank you". And a note to the entire community: I am continually amazed at the sheer volume of knowledge out there. Thanks to all, and to CadTutor for making this place available to all of us.

Vince :D

Vince0115
8th Apr 2005, 02:01 pm
Hey CAB,
It worked!!!! You are a genius. Again thanks
Vince

CAB
8th Apr 2005, 09:36 pm
I didn't write it, but I'm glad it worked for you.