Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.

Revit API Forum

Reply
Highlighted
Post 1 of 5
Accepted Solution

GeometryObject layer name

106 Views, 4 Replies
01-27-2017 01:29 AM

Hi,

 

Using the code:

foreach (GeometryObject geometryObj in dwg.get_Geometry(new Options()))
{

}

 

I can loop the objects of the linked cad file. My problem is that I want to get the layer name  of the object.

 

Thanks & Regards

Sanjay Pandey

the information is contained in the GraphicalStyle element:

 

GraphicsStyle gStyle = document.GetElement(geometryObj.GraphicsStyleId) as GraphicsStyle;

 

layername: 

gStyle.GraphicsStyleCategory.Name

 

Post 2 of 5

Re: GeometryObject layer name

01-27-2017 02:33 AM in reply to: sanjaymann

Dear Sanjay,

 

Revit does not use layers.

 

I do not believe that a GeometryObject can be queried for that, or even has such a concept.

 

You might be able to open the original DWG file using AutoCAD.NET and analyse that instead.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Post 3 of 5

Re: GeometryObject layer name

01-28-2017 03:30 PM in reply to: sanjaymann

the information is contained in the GraphicalStyle element:

 

GraphicsStyle gStyle = document.GetElement(geometryObj.GraphicsStyleId) as GraphicsStyle;

 

layername: 

gStyle.GraphicsStyleCategory.Name

 

Post 4 of 5

Re: GeometryObject layer name

01-29-2017 09:59 PM in reply to: FAIR59

Hi,

 

Thanks for the reply.

 

I too found the layer name the same way as you mentioned but still I will accept your answer as a solution.

 

Thanks & Regards

Sanjay Pandey

Post 5 of 5

Re: GeometryObject layer name

02-02-2017 02:27 AM in reply to: sanjaymann

Thanks to Fair59 for the nice succinct answer. Promoted to a blog post:

 

http://thebuildingcoder.typepad.com/blog/2017/02/revitserverapilib-truss-members-and-layers.html#5

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post

Revit Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Revit helps you achieve greater speed, accuracy, and automation from concept to manufacturing.