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 🙂
Hi,
Are you sure you need an application to do that?, i think that is a good task for the dataextraction command.
-gnb
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.
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); }
@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.
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.