giving the entity a name wich can be returned

giving the entity a name wich can be returned

Anonymous
Not applicable
471 Views
13 Replies
Message 1 of 14

giving the entity a name wich can be returned

Anonymous
Not applicable
Hi everyone!

This topic is about extracting entity's to a database and still being able to recognize them. I'd like to give each entity a name or code of my choosing. This name should be extractable using VB later. This way I can get an entity's properties in my excelsheet and still recognize it by name. I've looked in to labeling my entity's but can't really figure out how to do that or how to extract the label. Any other suggestions are very welcome too.

best regards,

Rick
0 Likes
472 Views
13 Replies
Replies (13)
Message 2 of 14

Anonymous
Not applicable
I would look at XData (ExtendedData). XData is meta data that is attached to an object (any object in a drawing, including the document object...). I have done something similar. I have attached a unique identifier to all of my objects using XData, witch represents a specific row in a database.

WARNING WITH XDATA : Some XData is modified with an object when you modify this object (Scale, Move...). Look at the docum. to make sure the codes you are using will not be affected by modifications on the object. (Specified in the description of the Code.

Hope this helps.
Let me know if you need more details or exemple.
0 Likes
Message 3 of 14

Anonymous
Not applicable
thanks for your quick reply. I've been exploring autocad and searching the internet for more documentation about how to attach Xdata to an entity. All i'm finding out about is tools to add Xdata but i'd like to try the conventional way first. I feel kind of stupid asking but how do i do this? I'm using AutoCAD 2008.

secondly i found out that Xdata doesn't work with blocks and i'll be better off using the attributes. Is this right?

thanks again
0 Likes
Message 4 of 14

Anonymous
Not applicable
If your purpose to give an entity a name/code is to identify entities in s
drawing, you do not have to re-invent the small wheel. You can use
AcadEntity.Handle to identify entities existing in a drawing file, which
persists between Acad sessions.

"RickVE" wrote in message news:5821730@discussion.autodesk.com...
Hi everyone!

This topic is about extracting entity's to a database and still being able
to recognize them. I'd like to give each entity a name or code of my
choosing. This name should be extractable using VB later. This way I can get
an entity's properties in my excelsheet and still recognize it by name. I've
looked in to labeling my entity's but can't really figure out how to do that
or how to extract the label. Any other suggestions are very welcome too.

best regards,

Rick
0 Likes
Message 5 of 14

Anonymous
Not applicable
This was my first plan too. The handle has all the properties i'm looking for but has one big downside. it's generated by AutoCAD automatically and can't be altered in a manner of my own choosing so is not recognizable as being a certain component. Instead of the hexadecimal number like the handle i'd like to call my polyline "pipe1A" for example. But thanks for your input.
0 Likes
Message 6 of 14

Anonymous
Not applicable
You said you were using a database.
So your name is one field, and the handle is another.

(since a handle could occur in more than one dwg, if you work with multiple
dwgs you need to combine to avoid duplicates) these could become your
primary key or just used by your app to identify the object

Then your app does whatever to identify your "chosen name" with that
uniquely identified object.
? or we're missing something in your requirements...
Mark

wrote in message news:5821869@discussion.autodesk.com...
This was my first plan too. The handle has all the properties i'm looking
for but has one big downside. it's generated by AutoCAD automatically and
can't be altered in a manner of my own choosing so is not recognizable as
being a certain component. Instead of the hexadecimal number like the handle
i'd like to call my polyline "pipe1A" for example. But thanks for your
input.
0 Likes
Message 7 of 14

Anonymous
Not applicable
I'll just be working with a single DWG so the handle is always unique. All i'm doing is looping thru a selectionset of entity's collecting their properties and placing them in an excelsheet. I'd like to give these entities a name in AutoCAD and also pull this name with VB. Xdata was recommended to me so i'm looking into this now. I'd like to find out how Xdata can be manually added to an entity in AutoCAD 2008 since my helpfiles are incomplete.
0 Likes
Message 8 of 14

Anonymous
Not applicable
I seems to me that if you provided more info about what you are trying to achieve, you could get better help. If what you are trying to collect is just length, ends, rotation and things like that (properties), then I would just put them on a layer and extract all these properties from entities on that layer, without the name or use the handle to differentiate them. If you want to create a BOM system, then I would suggest using blocks with attributes to store the info in the drawing and then extract them. You can name the blocks or have an attribute called name. I think there are many ways of extracting info from a drawing.
0 Likes
Message 9 of 14

Anonymous
Not applicable
Good morning nyme! You seem to be the only one who understands what i'm trying to do here. Could you explain to me how I can attach Extended Data to the objects in AutoCAD 2008? and maybe post an example of how to extract this data.

thanks!
0 Likes
Message 10 of 14

Anonymous
Not applicable
Hi,

What's wrong with the sample files and the sample code in the Help files?

--


Regards

Laurie Comerford
wrote in message news:5822745@discussion.autodesk.com...
Good morning nyme! You seem to be the only one who understands what i'm
trying to do here. Could you explain to me how I can attach Extended Data to
the objects in AutoCAD 2008? and maybe post an example of how to extract
this data.

thanks!
0 Likes
Message 11 of 14

Anonymous
Not applicable
my help files are missing :S
0 Likes
Message 12 of 14

Anonymous
Not applicable
all I really need to know is how I can attach extended data to my entities in AutoCAD
0 Likes
Message 13 of 14

Anonymous
Not applicable
Hi,

Try a repair install.

You can also press the F2 key in the VBAIDE to view the object model.
Select any object like a line and view its methods and properties.

--


Regards

Laurie Comerford
wrote in message news:5822847@discussion.autodesk.com...
my help files are missing :S
0 Likes
Message 14 of 14

Anonymous
Not applicable
Ok, here is a small exemple:

Lets say you have a vEntObj object set to an object of handle "ABABA"

[code]
Dim vEntObj As AcadEntity
Set vEntObj = ThisDrawing.HandleToObject("ABABA")

'Setting XData
Dim xTYPE() as Integer, xData as Variant
Redim xType(0 to 1)
Redim xData(0 to 1)

xType(0) = 1001 'Application Name
xData(0) = "YourApplicationName"
xTYPE(1) = 1000
xData(1) = "This is a test string to store in the XData"

vEntObj.SetXData xTYPE, xData

'Now to get xData
Dim xgTYPE as Variant
Dim xgDATA as Variant

EntObj.GetXData "YourApplicationName", xgTYPE, xgDATA

Dim I as Integer
'Check for existence of xdata in the object (based on the
''application name
If TypeName(xgTYPE) <> "Empty" Then
For I = lbound(xgTYPE) to UBound(xgTYPE)
Msgbox "Data index " & I & vbcrlf & _
"Data type code : " & xgTYPE(i) & Vbcrlf & _
"Data : " & xgDATA(i)
Next I
End If
[/code]

»This should be enought to start yourself with.

Enjoy, and don't hesitate to ask more questions.
0 Likes