Change Linestyle parameter?

Change Linestyle parameter?

bcampbell11
Advocate Advocate
1,787 Views
5 Replies
Message 1 of 6

Change Linestyle parameter?

bcampbell11
Advocate
Advocate

Is it even possible to change the linestle parameter of a line via the API?  For example, change a detail "Line Style" from Centerline to Hidden.  I can change the color, but that is not what I want to do.  Please help.

 

 

Thanks

0 Likes
Accepted solutions (1)
1,788 Views
5 Replies
Replies (5)
Message 2 of 6

bcampbell11
Advocate
Advocate

Or how about setting the default detail line style to a desired line style, whenever I create a line with the API now, it always puts lines on the "Thin Lines" style.

0 Likes
Message 3 of 6

jeremytammik
Autodesk
Autodesk

Dear Bcampbell,

 

Thank you for your query.

 

Can you achieve the desired changes manually through the user interface?

 

If so, it is probably possible programmatically as well.

 

The procedure for you to explore this yourself is always the same:

 

Set up a simple minimal starting point situation manually through the user interface.

 

Explore the elements and their properties using RevitLookup, BipChecker, the element lister, and other, more intimate database exploration tools:

 

http://thebuildingcoder.typepad.com/blog/2013/11/intimate-revit-database-exploration-with-the-python...

 

Make the desired modification.

 

Analyse what changed.

 

Now you know what to do to achieve the desired result.

 

I hope this helps.

 

Best regards,

 

Jeremy



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

0 Likes
Message 4 of 6

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

        internal static void SetLineStyles(CurveElement element, string styleName)
        {
            foreach (ElementId lineID in element.GetLineStyleIds())
            {
                GraphicsStyle style = element.Document.GetElement(lineID) as GraphicsStyle;

                if ((style != null)&&(style.Name == styleName))
                {
                    if (style.GraphicsStyleType == GraphicsStyleType.Projection)
                    {
                        element.LineStyle = style;
                    }
                }
            }
        }

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 6

jeremytammik
Autodesk
Autodesk

A much better and more helpful answer than mine  🙂



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

Message 6 of 6

bcampbell11
Advocate
Advocate

Wow, thanks!  This did it, looking at the code, I am not sure I would of figured this out any time soon.  It looks simple but does a couple things with the graphicsstyle I am not used to.  

Thanks!!

0 Likes