Extract Entities using Layer

Extract Entities using Layer

amitnkukanur
Collaborator Collaborator
606 Views
2 Replies
Message 1 of 3

Extract Entities using Layer

amitnkukanur
Collaborator
Collaborator

Hello To All,

 

I am doing a project where i am required to extract data from autocad files layer wise.

I straight away extracted data from Autocad database by bounding box concept which gave me results in co-ordinates and entity names such as lwpolyline, text,dbtext... etc

 

But now i also have to extract data from Autocad based on layer concept which include coordinates, type of data such as text, polyline,spline.

 

This extraction i am little confident to do, if some one gives me idea this would be helpfull.

 

Regards,

Rishikesh

Senior Software Engineer
0 Likes
Accepted solutions (1)
607 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

Hi Rishikesh. if I understand you right,

you can use selection set with layers filter:
/// <summary> /// return selection set with filter of layers /// </summary> /// <param name="layers">Layers name string collection</param> /// <returns>Selection set</returns> static public PromptSelectionResult SelectEntitiesByLayers(stringCollection layers) { Editor ed = acadApp.DocumentManager.MdiActiveDocument.Editor; Database db = HostApplicationServices.WorkingDatabase; // Build a conditional filter list so that only // entities with the specified properties are // selected int i = 0; TypedValue[] tvs = new TypedValue[1]; tvs[0] = new TypedValue((int)DxfCode.Operator, "<or"); foreach (string lay in layers) { //i = tvs.Length; //TypedValue[] temp = new TypedValue[tvs.Length + 4]; TypedValue[] temp = new TypedValue[tvs.Length + 1]; if (tvs != null) Array.Copy(tvs, temp, Math.Min(tvs.Length, temp.Length)); //VB redim preserve tvs = temp; //tvs[i + 1] = new TypedValue((int)DxfCode.Operator, "<and"); //tvs[i + 2] = new TypedValue((int)DxfCode.LayerName, lay); tvs[i + 1] = new TypedValue((int)DxfCode.LayerName, lay); //tvs[i + 3] = new TypedValue((int)DxfCode.Operator, "and>"); i++; } i = tvs.Length; //TypedValue[] temp1 = new TypedValue[tvs.Length + 2]; TypedValue[] temp1 = new TypedValue[tvs.Length + 1]; if (tvs != null) Array.Copy(tvs, temp1, Math.Min(tvs.Length, temp1.Length)); tvs = temp1; //tvs[i + 1] = new TypedValue((int)DxfCode.Operator, "or>"); tvs[i] = new TypedValue((int)DxfCode.Operator, "or>"); SelectionFilter sf = new SelectionFilter(tvs); PromptSelectionResult psr = ed.SelectAll(sf); return psr; // ed.WriteMessage("\nFound {0} entit{1}.", psr.Value.Count, (psr.Value.Count == 1 ? "y" : "ies")); }

  

0 Likes
Message 3 of 3

amitnkukanur
Collaborator
Collaborator
Perfect
Senior Software Engineer
0 Likes