Import Instance and line patterns

Import Instance and line patterns

Anonymous
Not applicable
1,767 Views
4 Replies
Message 1 of 5

Import Instance and line patterns

Anonymous
Not applicable

Is it possible to get the line patterns used by lines in an import instance?

 

I've noticed if I insert a CAD file the lines look correct but if I explode the block in Revit all the lines look solid. I've also noticed the GraphicStyleType on some lines is 3 but the API help file only shows Cut or Projection.

0 Likes
1,768 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

Dear Paul,

 

Thank you for your query.

 

You should be able to access absolutely all the line patterns in the entire database via a filtered element collector and RevitLookup.

 

Have you tried that?

 

I searched the Revit API docs and Internet for GraphicStyleType and found no further information on the mysterious number 3.

 

What does the user interface display string say about a line with such a setting?

 

Does this problem appear only when working through the API, or do you observe the same behaviour when working manually through the user interface?

 

If so, the product support teams may have some more fruitful suggestions for you.

 

Sorry I have nothing further to suggest off-hand...

 

Best regards,

 

Jeremy

 



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

0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi Jeremy,

The link below is a Revit project that shows what I mean:

https://www.dropbox.com/s/13eto5swx0cm35h/test.dwg.rvt?dl=0

 

The project contains a macro that will output the line patterns used by the lines contained in a block in a imported DWG file to a text file. The mysterious GraphicStyleType 3 appears here. It looks like it has to do with lines that have the linestyle overridden instead of "By Layer". These are the lines I'm trying to get the line pattern from.

0 Likes
Message 4 of 5

FAIR59
Advisor
Advisor

Lines in a DWG can't be overridden by element, just by category. So the answer to your question is to find the linetype of the category , and not of the line.

 

		private void ReadLinePattern(GeometryObject mc)
		{
			GraphicsStyle go_gs = projectDocument.GetElement(mc.GraphicsStyleId) as GraphicsStyle;
			Category cat = go_gs.GraphicsStyleCategory;
			if ( projectDocument.ActiveView.GetCategoryHidden(cat.Id)) return;
			OverrideGraphicSettings settings = projectDocument.ActiveView.GetCategoryOverrides(cat.Id);
			ElementId eid = settings.ProjectionLinePatternId;
			if (eid == ElementId.InvalidElementId) // category not overridden
			{
				eid = cat.GetLinePatternId(GraphicsStyleType.Projection);
			}
			LinePattern lpe = null;
			if (eid != LinePatternElement.GetSolidPatternId())
				{
					lpe = LinePatternElement.GetLinePattern(projectDocument, eid);
					if (lpe!=null) 
					{
						logFile.WriteLine("\tLine pattern = " + lpe.Name);
					}
					else{
						logFile.WriteLine("\tLinepatternElement==null  eid =  " + eid.IntegerValue.ToString());
					}
				}
				else
					logFile.WriteLine("\tLine pattern = Solid");
		}
Message 5 of 5

Anonymous
Not applicable

Sorry I'm not talking about overriding the line in an imported DWG in a Revit view (through the UI). I mean if the line was set to something other than "By Layer" while still in AutoCAD. I have noticed when I import a DWG file into Revit the DWG lines with a pattern set are preserved until the imported DWG is exploded. Then all the lines seem to change to the line style of the AutoCAD layer they were on.

 

I'm wondering if it is possible to get the line style before exploding the imported DWG file with the API.

0 Likes