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 Set Line Pattern in Line Style

10 REPLIES 10
Reply
Message 1 of 11
dhorger
7817 Views, 10 Replies

How to Set Line Pattern in Line Style

I'm creating new line styles in Revit MEP 2013 through the API in VB.Net, and I've almost got everything figured out... except setting the line pattern. There doesn't seem to be a way to do this one, last step. Any ideas?

Here's what I have so far:

 

   

PublicFunction LoadStyle(ByVal n AsInteger) AsBoolean

       

Dim lineCat As Categories = m_RvtDoc.Settings.Categories

       

ForEach objCategory As Category In lineCat

           

If objCategory.Name = "Lines"Then

               

If objCategory.CanAddSubcategory = TrueThen

                   

Try

                       

Dim cat As Category = lineCat.NewSubcategory(objCategory, MEP(n, 6))

                       

'set color

                       

If MEP(n, 7) <> ""Then

                           

Dim r, g, b AsInteger

                            r = MEP(n, 7)

                            g = MEP(n, 😎

                            b = MEP(n, 9)

                           

Dim c As Autodesk.Revit.DB.Color = New Autodesk.Revit.DB.Color(r, g, b)

                            cat.LineColor = c

                       

EndIf

                       

'set lineweight

                       

If MEP(n, 11) <> ""Then

                            cat.SetLineWeight(

CInt(MEP(n, 11)), GraphicsStyleType.Projection)

                       

EndIf

                       

'set line pattern

                       

If MEP(n, 10) <> ""Then

                           

'cat.LinePatternId = GetElementByName(GetType(LinePatternElement), MEP(n, 10))

                       

EndIf

                   

Catch

                        MsgBox(

"Line style " & MEP(n, 6) & " already exists.", MsgBoxStyle.Information, "Load Systems Error")

                   

EndTry

                   

Exit For

               

Else

                    MsgBox(

"Can't add line style.")

                   

Exit For

               

EndIf

           

EndIf

       

Next

 

   

EndFunction

 

 

10 REPLIES 10
Message 2 of 11
Joe.Ye
in reply to: dhorger

Revit didn't expose the API to change category's line pattern. Revit engineering team already knew this request. Hope this will come not long.


Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 3 of 11
dhorger
in reply to: Joe.Ye

Thanks for the response, Joe. Would it be possible to check to see if it's exposed in Revit 2014? And are there any workarounds? This is very important for my project.

 

Thanks,

 

Dave Horger

Interface Engineering, Inc.

Message 4 of 11
Joe.Ye
in reply to: dhorger

Thanks for your comments on the API wish. I passed on your comments on this request to the engineering team.


Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 5 of 11
atiefenbach
in reply to: Joe.Ye

+1 to adding this feature!
Anthony Tiefenbach
BIM Manager
HuntonBrady Architects
Message 6 of 11
jdbreazeale
in reply to: atiefenbach

+1 Please add this feature

Message 7 of 11
boostyourbim
in reply to: jdbreazeale

Yes, please fill this gap Autodesk so we can set the line style's line pattern via the API

Message 8 of 11

Dear All,

 

I have added your comments to the Epic story, there is still plans to work on this, but still needs to be prioritzed agains all other requests. 

 

Thank you very much for all your patience and collaboration. 

 

Cheers,



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
Message 9 of 11

Yes, please add this! Has it been done yet? How many more years?

Message 10 of 11
Revitalizer
in reply to: roberto.levy

Hey,

 

in Revit 2017 API, there is a new Category.SetLinePatternId method.

 

Seems that Autodesk provides a solution, finally.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 11 of 11
Ning_Zhou
in reply to: Revitalizer

but SetLinePatternId() doesn't work, SetLineWeight() works fine along w/ LineColor

Ning_Zhou_0-1595755599925.png

subCat.SetLineWeight((int)cat.GetLineWeight(GraphicsStyleType.Projection), GraphicsStyleType.Projection); // works OK
subCat.LineColor = cat.LineColor; // works OK
subCat.SetLinePatternId(cat.GetLinePatternId(GraphicsStyleType.Projection), GraphicsStyleType.Projection); // doesn't work

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community