Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get the relationship between a Line Style and a Line Pattern?

11 REPLIES 11
Reply
Message 1 of 12
CoderBoy
2436 Views, 11 Replies

How to get the relationship between a Line Style and a Line Pattern?

CoderBoy
Advocate
Advocate

One of my teammates is struggling to figure out how to find the relationship between a line style and a line pattern in the Revit project environment.  He has done lots of searching, but has not found a solution.  I believe he's currently working in the Revit 2014 environment, but we'd obviously want this to work in newer versions of Revit, and will take what we can get.

 

For example, line styles are basically a subcategory of the Line category.  The general Line category can have many Line Style subcategories, and all subcategories of the Line category apparently *are* line styles.

 

To get to line patterns, you use a FilteredElementCollector.OfClass(LinePatternElement)

 

Line Patterns have a name and a list of LineSegment classes, each which has a Lengh double and an enum LineSegmentType (e.g. dash, dot or space).

 

Each line style can have exactly 1 line pattern or no line patterns.  What we need to find out is which line pattern (if any) is related to each line style (subcategory).  There does not seem to be, for example, a LinePattern property on the Category class (Category class is used for both Categories and SubCategories, so in reality a Line Style is of the Category class).

 

Thanks very much for any assistance you can provide.

 

 

0 Likes

How to get the relationship between a Line Style and a Line Pattern?

One of my teammates is struggling to figure out how to find the relationship between a line style and a line pattern in the Revit project environment.  He has done lots of searching, but has not found a solution.  I believe he's currently working in the Revit 2014 environment, but we'd obviously want this to work in newer versions of Revit, and will take what we can get.

 

For example, line styles are basically a subcategory of the Line category.  The general Line category can have many Line Style subcategories, and all subcategories of the Line category apparently *are* line styles.

 

To get to line patterns, you use a FilteredElementCollector.OfClass(LinePatternElement)

 

Line Patterns have a name and a list of LineSegment classes, each which has a Lengh double and an enum LineSegmentType (e.g. dash, dot or space).

 

Each line style can have exactly 1 line pattern or no line patterns.  What we need to find out is which line pattern (if any) is related to each line style (subcategory).  There does not seem to be, for example, a LinePattern property on the Category class (Category class is used for both Categories and SubCategories, so in reality a Line Style is of the Category class).

 

Thanks very much for any assistance you can provide.

 

 

11 REPLIES 11
Message 2 of 12
jeremytammik
in reply to: CoderBoy

jeremytammik
Autodesk
Autodesk

Dear CoderBay,

 

I checked with the development team and have not heard back from them yet.

 

That may possibly mean that they have nothing that comes to mind right away.

 

I'll let you know as soon as I have anything to report.

 

Best regards,

 

Jeremy



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

0 Likes

Dear CoderBay,

 

I checked with the development team and have not heard back from them yet.

 

That may possibly mean that they have nothing that comes to mind right away.

 

I'll let you know as soon as I have anything to report.

 

Best regards,

 

Jeremy



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

Message 3 of 12
CoderBoy
in reply to: jeremytammik

CoderBoy
Advocate
Advocate

Hi Jeremy.

 

Thank you very much for checking into this one and making this request of the Revit development team.  We have a huge AEC customer (literally one of the biggest) who wants to do some reporting on the data in their projects, which has been the primary source of my recent set of requests for assistance.

 

Thanks again, and please let me know whatever the official answer is.

 

 

0 Likes

Hi Jeremy.

 

Thank you very much for checking into this one and making this request of the Revit development team.  We have a huge AEC customer (literally one of the biggest) who wants to do some reporting on the data in their projects, which has been the primary source of my recent set of requests for assistance.

 

Thanks again, and please let me know whatever the official answer is.

 

 

Message 4 of 12
jeremytammik
in reply to: CoderBoy

jeremytammik
Autodesk
Autodesk

Dear CoderBoy,

 

I heard back on this from the development team. They say:

 

We discussed this not long ago in the following Q & A:

 

[Q] The Revit documentation says that Line Patterns are used in the definition of GraphicsStyle objects: "A line pattern is a pattern of dashes and dots used to control the way the lines of an object are drawn in Revit. Line patterns are used in the definition of GraphicsStyle objects. A line pattern is defined by a repeating sequence segments. Each segment is a dash, a dot or a space. A line pattern definition must contain an even number of segments, starting with a visible segment (a dash or a dot) and alternating between visible segments and spaces." However, I could not find any APIs to connect these objects. How are these objects connected and how to use the APIs to connect them?

 

[A] Revit does currently not expose the API to set or get a GraphicsStyle object's line pattern element. Users can only change/get the line pattern for GraphicsStyle object via the Revit UI. You can create a new line pattern element in Revit 2014 using its constructor to create a LinePattern object: LinePattern(String). You can call the LinePattern.SetSegment() method to create customized line patterns. You can create a LinePatternElement via LinePatternElement.Create(LinePattern).

 

Based on that, I don't think we currently expose any link between GraphicsStyle and line pattern. I don't think we even have the ability to get a line pattern directly from the category.

 

However, you can get the pattern id for a specific view via two OverrideGraphicSettings properties: ProjectionLinePatternId and CutLinePatternId. These get the value from the Visibility/Graphics dialog, not object styles. Not sure if it will return the object styles value if it's not overridden in the view.

Clearing up a few incorrect assumptions in the query itself:

 

  • Line style != subcategory or category. It's not a 1:1 relationship.
  • Each category and subcategory has two GraphicsStyles: cut and projection (selected via GraphicsStyleType). Each style has a color, weight & pattern reference.
  • Patterns are shared by multiple styles, so you can't map back from a line pattern back to a single line style or category because it's a one to many relationship.

 

I hope this helps.

 

Best regards,

 

Jeremy



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

0 Likes

Dear CoderBoy,

 

I heard back on this from the development team. They say:

 

We discussed this not long ago in the following Q & A:

 

[Q] The Revit documentation says that Line Patterns are used in the definition of GraphicsStyle objects: "A line pattern is a pattern of dashes and dots used to control the way the lines of an object are drawn in Revit. Line patterns are used in the definition of GraphicsStyle objects. A line pattern is defined by a repeating sequence segments. Each segment is a dash, a dot or a space. A line pattern definition must contain an even number of segments, starting with a visible segment (a dash or a dot) and alternating between visible segments and spaces." However, I could not find any APIs to connect these objects. How are these objects connected and how to use the APIs to connect them?

 

[A] Revit does currently not expose the API to set or get a GraphicsStyle object's line pattern element. Users can only change/get the line pattern for GraphicsStyle object via the Revit UI. You can create a new line pattern element in Revit 2014 using its constructor to create a LinePattern object: LinePattern(String). You can call the LinePattern.SetSegment() method to create customized line patterns. You can create a LinePatternElement via LinePatternElement.Create(LinePattern).

 

Based on that, I don't think we currently expose any link between GraphicsStyle and line pattern. I don't think we even have the ability to get a line pattern directly from the category.

 

However, you can get the pattern id for a specific view via two OverrideGraphicSettings properties: ProjectionLinePatternId and CutLinePatternId. These get the value from the Visibility/Graphics dialog, not object styles. Not sure if it will return the object styles value if it's not overridden in the view.

Clearing up a few incorrect assumptions in the query itself:

 

  • Line style != subcategory or category. It's not a 1:1 relationship.
  • Each category and subcategory has two GraphicsStyles: cut and projection (selected via GraphicsStyleType). Each style has a color, weight & pattern reference.
  • Patterns are shared by multiple styles, so you can't map back from a line pattern back to a single line style or category because it's a one to many relationship.

 

I hope this helps.

 

Best regards,

 

Jeremy



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

Message 5 of 12
CoderBoy
in reply to: jeremytammik

CoderBoy
Advocate
Advocate

Hi Jeremy.

 

Thank you so very much for getting us this information.  It is indeed unfortunate that the Revit API doesn't expose a way to find the line pattern for a line style.  

 

We'll have to tell our customer that we can't provide this information at this time.

 

We would appreciate it if accessing this kind of data would be added to the wishlist for the Revit API.

 

As always, your efforts are greatly appreciated!

 

 

0 Likes

Hi Jeremy.

 

Thank you so very much for getting us this information.  It is indeed unfortunate that the Revit API doesn't expose a way to find the line pattern for a line style.  

 

We'll have to tell our customer that we can't provide this information at this time.

 

We would appreciate it if accessing this kind of data would be added to the wishlist for the Revit API.

 

As always, your efforts are greatly appreciated!

 

 

Message 6 of 12
jeremytammik
in reply to: CoderBoy

jeremytammik
Autodesk
Autodesk

Dear CoderBoy,

 

Thank you for your update, appreciation and request.

 

I published the results we obtained so far on The Building Coder:

 

http://thebuildingcoder.typepad.com/blog/2014/04/revit-as-a-service-and-sheet-view-transform.html#4

 

I am sorry that there is currently no API access to this functionality.

 

I submitted the wish list item CF-1209 [retrieve relationship between Line Style and Line Pattern -- 09521521] on your behalf for the functionality you suggest, as this issue requires exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

I hope this helps.

 

Best regards,

 

Jeremy



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

Dear CoderBoy,

 

Thank you for your update, appreciation and request.

 

I published the results we obtained so far on The Building Coder:

 

http://thebuildingcoder.typepad.com/blog/2014/04/revit-as-a-service-and-sheet-view-transform.html#4

 

I am sorry that there is currently no API access to this functionality.

 

I submitted the wish list item CF-1209 [retrieve relationship between Line Style and Line Pattern -- 09521521] on your behalf for the functionality you suggest, as this issue requires exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

I hope this helps.

 

Best regards,

 

Jeremy



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

Message 7 of 12
jeremytammik
in reply to: jeremytammik

jeremytammik
Autodesk
Autodesk

Dear CoderBoy,

 

Did you find any alternative solution since we discussed this last?

 

I am looking into a similar case right now and happened upon this thread again.

 

I also just happened to find another interesting note regarding a related issue in the Revit API roundtable notes from Autodesk Universisty 2013:

 

http://thebuildingcoder.typepad.com/blog/2013/12/au-day-2-worksharing-and-revit-2014-api-roundtables...

 

[q] can i access the Revit line pattern from a Revit style? line weight is available.
[a] augusto wrote a code about that a few weeks ago. you have to search the assets.

 

I am checking with Auusto right now to get hold of the code he mentions.

 

I hope this helps.

 

Thank you!

 

Best regards,

 

Jeremy



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

Dear CoderBoy,

 

Did you find any alternative solution since we discussed this last?

 

I am looking into a similar case right now and happened upon this thread again.

 

I also just happened to find another interesting note regarding a related issue in the Revit API roundtable notes from Autodesk Universisty 2013:

 

http://thebuildingcoder.typepad.com/blog/2013/12/au-day-2-worksharing-and-revit-2014-api-roundtables...

 

[q] can i access the Revit line pattern from a Revit style? line weight is available.
[a] augusto wrote a code about that a few weeks ago. you have to search the assets.

 

I am checking with Auusto right now to get hold of the code he mentions.

 

I hope this helps.

 

Thank you!

 

Best regards,

 

Jeremy



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

Message 8 of 12
CoderBoy
in reply to: jeremytammik

CoderBoy
Advocate
Advocate

Hi Jeremy.

 

We have not found an alternate solution, however we haven't looked at this in quite some time.

 

If we can get some sample code that even just gets us in the neighborhood, we may be able to experiment with it to see if we can go further.  So any sample code that could be provided would be great.

 

Thanks!

 

 

0 Likes

Hi Jeremy.

 

We have not found an alternate solution, however we haven't looked at this in quite some time.

 

If we can get some sample code that even just gets us in the neighborhood, we may be able to experiment with it to see if we can go further.  So any sample code that could be provided would be great.

 

Thanks!

 

 

Message 9 of 12
jeremytammik
in reply to: CoderBoy

jeremytammik
Autodesk
Autodesk

Dear CoderBoy,

Thank you for your answer.

 

Sorry, false alarm.

 

I talked this over with Augusto, and he has no solution either after all.

So we are still stuck waiting for the wish list item CF-1209 [retrieve relationship between Line Style and Line Pattern -- 09521521].

 

Thumb-twiddle-twiddle...


Best regards,

Jeremy



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

0 Likes

Dear CoderBoy,

Thank you for your answer.

 

Sorry, false alarm.

 

I talked this over with Augusto, and he has no solution either after all.

So we are still stuck waiting for the wish list item CF-1209 [retrieve relationship between Line Style and Line Pattern -- 09521521].

 

Thumb-twiddle-twiddle...


Best regards,

Jeremy



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

Message 10 of 12
Anonymous
in reply to: jeremytammik

Anonymous
Not applicable

Correct me if I'm wrong, but we are still waiting for this in the 2016 version?  Thanks.

0 Likes

Correct me if I'm wrong, but we are still waiting for this in the 2016 version?  Thanks.

Message 11 of 12
jeremytammik
in reply to: Anonymous

jeremytammik
Autodesk
Autodesk

Dear Michael,

 

Thank you for checking.

 

Are you asking a question or making a statement?

 

You cannot be wrong, ever, as long as you are asking a question.

 

Assuming that to be the case, I checked the status of the wish list item CF-1209 [retrieve relationship between Line Style and Line Pattern -- 09521521].

 

That is apparently implemented by the change request REVIT-37842 [As a Add-In Developer, I would like to change the Line Pattern for a Category, so that I can modify a project's Object Styles in my application].

 

This in turn is marked as a duplicate of REVIT-72456 [As an API developer, I need to set the Line Pattern (in Object Styles and Line Styles) through the API so that its easy to create and configure files without having to start a template file], which has been submitted to the upcoming next major release of Revit.

 

You should therefore be able to download the most recent preview release from the Autodesk beta site and try it out yourself right away.

 

Please let us know how you fare.

 

If you encounter any issues with the fix, please urgently discuss them directly with the development team in the beta site discussion forum.

 

Thank you!

 

I hope this helps.

 

Best regards,

 

Jeremy



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

0 Likes

Dear Michael,

 

Thank you for checking.

 

Are you asking a question or making a statement?

 

You cannot be wrong, ever, as long as you are asking a question.

 

Assuming that to be the case, I checked the status of the wish list item CF-1209 [retrieve relationship between Line Style and Line Pattern -- 09521521].

 

That is apparently implemented by the change request REVIT-37842 [As a Add-In Developer, I would like to change the Line Pattern for a Category, so that I can modify a project's Object Styles in my application].

 

This in turn is marked as a duplicate of REVIT-72456 [As an API developer, I need to set the Line Pattern (in Object Styles and Line Styles) through the API so that its easy to create and configure files without having to start a template file], which has been submitted to the upcoming next major release of Revit.

 

You should therefore be able to download the most recent preview release from the Autodesk beta site and try it out yourself right away.

 

Please let us know how you fare.

 

If you encounter any issues with the fix, please urgently discuss them directly with the development team in the beta site discussion forum.

 

Thank you!

 

I hope this helps.

 

Best regards,

 

Jeremy



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

Message 12 of 12
Anonymous
in reply to: jeremytammik

Anonymous
Not applicable

I have a similar problem. How can  assign a line pattern to a line style in Revit via API? From what you said it is a limitation. There are several users out there on another post asking for the same thing. I guess my app will have its own line style, but will be solid. Oh well...It has been requested for years now if you look at the other post. Here is a link to the post so you can see :

 

http://forums.autodesk.com/t5/revit-api/how-to-set-line-pattern-in-line-style/td-p/3731078

 

 

0 Likes

I have a similar problem. How can  assign a line pattern to a line style in Revit via API? From what you said it is a limitation. There are several users out there on another post asking for the same thing. I guess my app will have its own line style, but will be solid. Oh well...It has been requested for years now if you look at the other post. Here is a link to the post so you can see :

 

http://forums.autodesk.com/t5/revit-api/how-to-set-line-pattern-in-line-style/td-p/3731078

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report