PDA

View Full Version : Extract data problem



Chupa
3rd Apr 2007, 10:17 am
Hi! I'm very happy i found this forum.. i have a DWG, which was originally exported from a GIS program which contains a city's pipes infrastruture. On another layer there are blocks under the form of circles which are the nodes of the pipes.
I need to extract the location(The one which appears in the most left lower corner of autocad) of nodes(in this case the center of the little circles) and their name. The problem is that is go to the properties the coordinates appear 0 and 0. But if i hoover the mouse over the node on the map, i get the right numbers in that corner i was mentioning. So what i try the Data extraction tutorial and i try to get the coordinates i get their names and a bunch of zeros.
Any ideas? :(
P.S. -> I'm using AutoCAD 2008

eldon
3rd Apr 2007, 11:37 am
If your "nodes" are blocks, then you should be able to extract the insertion point.

To help identify the solution, it would be helpful if you could make available a scrap of your drawing, and saved in an earlier version of AutoCAD than 2008.

Chupa
3rd Apr 2007, 01:02 pm
I was unable to cope with forum filesize rules, even by deleting the whole content of the file, it would still go beyond 300Kb. Zip it didn't help.
After the post above i managed to save the X and Y of all the mid points but no name field.
So i can save the blocks but just with their name, and another file with the midpoints X and Y.
I have to find a way to merge those 2... The Block names with the X and Y of the insertion point.
So here it is... chopped :
www.instalatie.ro/modelare2004.dwg (http://www.instalatie.ro/modelare2004.dwg)

fuccaro
3rd Apr 2007, 01:59 pm
The problem is the way how the blocks are created; all the blocks-whenever are placed on the screen- have the insertion point in the origin of WCS!

dbroada
3rd Apr 2007, 02:09 pm
I don't know about anybody else but I can't work with that drawing. I can't even draw a line on the screen.

However, it looks like each block is an individual item created in-situ so all have insertion points of 0,0 rather than where the block is on the screen (a pet hate of mine) AND the block appears to comprise ONLY a point, although there are attributes defined which I can't locate. You can tell the blocks are points by changing the value of PDMODE. If you explode all the blocks you will get their X,Y but you will lose their name. You may be able to read their X,Y using an OSNAP of node but I can't think of an easy way to export the data.

fuccaro
3rd Apr 2007, 02:12 pm
You can not draw lines because the current layer is off!
Those are not circles but points-just PDMODE is set to 32 so the points appears as circles. All of them was converted to block but (from mistake, I supose) the drafter forgot to set the insertion point. It left all as default 0,0,0. I think only a program could help our new friend...

dbroada
3rd Apr 2007, 02:17 pm
You can not draw lines because the current layer is off!
Those are not circles but points but PDMODE is set to 32 so the points appears as circles. All of them was converted to block but (from mistake, I supose) the drafter forgot to set the insertion point. It left all as default 0,0,0. I think only a program could help our new friend...Thanks fuccaro, I didn't even think of checking if the current layer is off. That may be why I couldn't find the attributes too.

I am beginning to hate the Make Block dialogue box. So often you find that a block has been created without setting the X,Y(,Z) to something sensible! I seem to spend most of my time correcting insertion points in other peoples blocks. :x

I agree that a program will be required. At least the node point can give the location but I'm not willing to give this one a try. :roll:

eldon
3rd Apr 2007, 02:35 pm
There is something strange going on. If you list an object, it says it is a Block, and lists the insertion point as 0,0,0, but all the Attributes have a start position which is the insertion point of the object.

However, if you go into Block Attribute Manager a message comes up saying there are "no attributed blocks".

This sounds as if the translating programme is not quite clever enough to put the correct information where AutoCAD expects it!! :(

dbroada
3rd Apr 2007, 02:39 pm
There is something strange going on. If you list an object, it says it is a Block, and lists the insertion point as 0,0,0, but all the Attributes have a start position which is the insertion point of the object.

However, if you go into Block Attribute Manager a message comes up saying there are "no attributed blocks".

This sounds as if the translating programme is not quite clever enough to put the correct information where AutoCAD expects it!! :(
I'm glad somebody else couldn't find the attributes! If you double click etc. it says "no attributes" but if you DDEDIT or use PROPERTIES the attributes are there for you to modify. Listing says they are invisible but you can't select them to un-invisible them. And there are 2 blocks at each (or at some) location too!

eldon
3rd Apr 2007, 02:43 pm
I cheated with the visibilty by setting ATTMODE to 2

dbroada
3rd Apr 2007, 02:46 pm
I cheated with the visibilty by setting ATTMODE to 2I've never used that before. Thanks.

(No wonder I'm at the top of the most posters lists with all these one line replies)

Chupa
3rd Apr 2007, 08:36 pm
Wow! So many replies :shock: ! Thank you, a lot!
I recived this "homework" from a teacher of mine which i wanted to help. I wanted to be a surprise, but it seems that he faced the same problem... X,Y and the names can only be extracted separately. This is why he asked for help.. he asked us to manually select each node and write its coordinates.
So it looks like the GIS program exported a weird DWG.. :( The problem is that there are about 1500 nodes! :huh: Not just 20-30, or how many are in the sample dwg i uploaded.

Thanks a lot!

CarlB
3rd Apr 2007, 08:50 pm
It looks like the attribute insertion point is the point coordinate point you want. Someone could whip up a routine to export these to a text file. Anyone ??

dbroada
3rd Apr 2007, 09:20 pm
I did one a couple of months back!










you want me to look for it?

this is the post
http://www.cadtutor.net/forum/showthread.php?t=9958&page=2&highlight=insert
but I don't think we ever sorted the code out but it does show how much I hate badly defined blocks.

Chupa
3rd Apr 2007, 09:48 pm
It looks like the attribute insertion point is the point coordinate point you want. Someone could whip up a routine to export these to a text file. Anyone ??
Yup, the coordinates are saveable... so do the names... but not in the same table..so you cannot create a link between the names and the coordinates :cry:

CarlB
3rd Apr 2007, 10:26 pm
Try this lisp routine, quick & dirty write block name & attribute insert coordinate to a file:


(defun c:att2file ()
(setq File1 (getfiled "File name" "" "txt" 1))
(setq Fopen (open File1 "w"))
(princ "\nSelect blocks to write att coords: ")
(setq BlockSet (ssget '((0 . "INSERT") (66 . 1))))
(setq Ecount 0)
(repeat (sslength BlockSet)
(setq Bname (ssname BlockSet Ecount))
(setq Blabel (cdr (assoc 2 (entget Bname))))
(setq AttName (entnext Bname))
(setq AttData (entget AttName))
(setq TxtIns (cdr (assoc 10 AttData)))
(setq Xtxt (rtos (car TxtIns) 2 4))
(setq ytxt (rtos (cadr TxtIns) 2 4))
(setq XY_Txt (strcat Blabel " " xtxt "," ytxt))
(write-line XY_Txt Fopen)
(setq Ecount (1+ Ecount))
)
(close Fopen)
(princ)
)

Chupa
4th Apr 2007, 12:34 am
:cry: My god, Carl!! I belive it works! I've never seen in my 10 years of Internet browsing such a great and dedicated community :?. I'm still shocked.. uhm.. Thanks! Thank you all. A lot! If i can help in anyway...
I'll contact my teacher.. i belive he'll say the results are perfect.

LISP syntax seems imposible to me.. but it looks like i should learn it.. it helped a lot!
Thanks for the "Load LISP" tutorial, really helpful !! ;)

fuccaro
4th Apr 2007, 05:44 am
Nice to see a happy face in here! :-)

Chupa
4th Apr 2007, 03:23 pm
I don;t wanna be a pain.. but.. if i want to get the "ID" field from "Attributes", instead of "name" from "Misc" ? What do i have to replace? i've tryed several versions of renaming various "name"s to "ID" in the LISP script above, but no succes :oops:.

Later edit: I've done it! I've used data extraction wizard to extract name+ID, and i merged it with the name+X&Y, you helped me with. But i still would be curious how could i have done it in LISP :D