Delete dwg layer

Delete dwg layer

Eri.Myalitsin
Contributor Contributor
929 Views
4 Replies
Message 1 of 5

Delete dwg layer

Eri.Myalitsin
Contributor
Contributor

Hi,

 

I am trying to delete a specific layer of dwg files inserted to rvt file.

Following code works only for the first dwg but cannot work for other files.

doc.Delete(c.Id)

It means the foreach loop in the following code doesn't work.

 

FilteredElementCollector eCollector = new FilteredElementCollector(doc);
eCollector.OfClass(typeof(ImportInstance)); foreach ( ImportInstance e in eCollector) { foreach ( Category c in e.Category.SubCategories) { if (c.Name == "0") // layer name { doc.Delete(c.Id); } } }

 

Any feedback would be appreciated.

 

Thanks,

Eri

 

0 Likes
Accepted solutions (1)
930 Views
4 Replies
Replies (4)
Message 2 of 5

Eri.Myalitsin
Contributor
Contributor
Accepted solution

Sorry, this code worked! Implementation was interrupted due to different part of the program.

Thank you very much for your attention.

0 Likes
Message 3 of 5

Anonymous
Not applicable

But what's about the geometry that still remains in DWG? The deletion procedure has just removed the layer from DWG's subcategories list and the "Layer" property of geometry objects in the DWG has just changed into "Undefined".

0 Likes
Message 4 of 5

775184106
Community Visitor
Community Visitor
I have the same issue that the geometry object could not be deleted when the layer has been removed. do we have some resolution to do the deletion on both layer and geometry?
0 Likes
Message 5 of 5

Dale.Bartlett
Collaborator
Collaborator

I didn't look at this closely, but it appears to me that you are deleting an object that is inside your foreach loop. You should loop foreach, and add every found c.id to a list. Then outside the foreach loop, delete everything in the found list.




______________
Yes, I'm Satoshi.
0 Likes