.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reading objacts location (X Y)

7 REPLIES 7
Reply
Message 1 of 8
GeoSchaap
523 Views, 7 Replies

Reading objacts location (X Y)

 

hi, a noob quation:

i want to write a command in C# that alow user to do 2 things:
1. choose a layer to work on
2. make a list/table of all objects in that layer, and their X Y coordinates.

for example - if a DWG file contain few layers, one of them has names (and only names). there are ~1500 objacts (text type) in that layer. every objact have a string (100,101,...,1350,1351...) and locating (X and Y). I want to be able to pick this layer, then bild a text file like this: (name X Y)
100 20456 40789
101 20344 40348
102 21034 40456
.
.
.

its dont has to be sorted. how do I do it? can you give me the solution or any lift to proggress? 

thanks 🙂

7 REPLIES 7
Message 2 of 8
hgasty1001
in reply to: GeoSchaap

Hi,

 

Are you sure you need an application to do that?, i think that is a good task for the dataextraction command.

 

-gnb

Message 3 of 8
GeoSchaap
in reply to: GeoSchaap

thanks for your answer. My aim is to create a data stracture that holds all this info, for calculations and so. In the far end, I want it to be an auto script that bild that proccesed text file.

For start, how do I read the atributs of an entity? How do I choose a layer, and read every object from it?

Thanks, EATTEXT will help me for now, and I do wait for your help to continue.
Message 4 of 8
jamierobertson1
in reply to: GeoSchaap

You can quite get the objectIDs of all text on a layer passing a SelectionFilter to the Editor.selectAll method::

 

TypedValue[] tv = new TypedValue[] {new TypedValue((int)DxfCode.Start, "TEXT"), new TypedValue((int)DxfCode.LayerName, "Layer 1")};

SelectionFilter sf = new SelectionFilter(tv);
SelectionSet set = ed.SelectAll(sf).Value;

 You can then open the text entities from the objectIDs in the selectionSet and then access their properties.

 

 

Message 5 of 8
GeoSchaap
in reply to: jamierobertson1

ok Man Happy

 

and how can I let the user to pick the layer he wants to work with?

Message 6 of 8
jamierobertson1
in reply to: GeoSchaap

You could either get the user to type in a layer name using Editor.GetString() or you could put a combobox on a form and get the user to pick one or smething like that.

 

You can get all layer names by iterating through all the LayerTableRecords in the LayerTable:

 

List<string> names = new List<string>();
LayerTable lt = (LayerTable)trans.GetObject(db.LayerTableId, OpenMode.ForRead);
foreach(ObjectId id in lt)
{
     LayerTableRecord ltr = (LayerTableRecord)trans.GetObject(id, OpenMode.ForRead);
     names.Add(ltr.Name);
}
Message 7 of 8
GeoSchaap
in reply to: jamierobertson1


@jamierobertson1 wrote:

You can quite get the objectIDs of all text on a layer passing a SelectionFilter to the Editor.selectAll method::

 

TypedValue[] tv = new TypedValue[] {new TypedValue((int)DxfCode.Start, "TEXT"), new TypedValue((int)DxfCode.LayerName, "Layer 1")};

SelectionFilter sf = new SelectionFilter(tv);
SelectionSet set = ed.SelectAll(sf).Value;

 You can then open the text entities from the objectIDs in the selectionSet and then access their properties.

 


 

Sorry for the begginer question, beside "Hello World" its my first program in this enviroment. Do I write it in a CommandMethod?  What do I do with the objectIDs?

 

thanks.

Message 8 of 8
jamierobertson1
in reply to: GeoSchaap

Have a look at some of the .net training material and samples here

 

http://http://usa.autodesk.com/adsk/servlet/index?id=1911627&siteID=123112

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost