How to modify FillRegion with Invisible lines

How to modify FillRegion with Invisible lines

BIM.Frankliang
Collaborator Collaborator
607 Views
2 Replies
Message 1 of 3

How to modify FillRegion with Invisible lines

BIM.Frankliang
Collaborator
Collaborator

Dear Friends,

 

         I want to know how to modify FillRegion with Invisible lines, I try two methods below, but all failed:

re.SetLineStyleId(Category.GetCategory(doc, BuiltInCategory.OST_InvisibleLines).
GetGraphicsStyle(GraphicsStyleType.Projection).Id);
var _styles = new FilteredElementCollector(doc)
            .OfClass(typeof(GraphicsStyle))
            .Cast<GraphicsStyle>()
            .ToList();

GraphicsStyle invisibleLineStyle = null;
foreach (GraphicsStyle g in _styles)
{
      if (g.Category.Id.IntegerValue.Equals((int)BuiltInCategory.OST_InvisibleLines))
      {
           invisibleLineStyle = g;
           break;
      }
}
re.SetLineStyleId(invisibleLineStyle.Id)

Does anyone know why and how to modify?

 

Many Thanks

0.png

 

 

0 Likes
Accepted solutions (1)
608 Views
2 Replies
Replies (2)
Message 2 of 3

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @BIM.Frankliang ,

try using the below code.

 

//GRAPHICS STYLE
               FilteredElementCollector collector = new FilteredElementCollector(doc).OfClass(typeof(GraphicsStyle));
               GraphicsStyle GS = null;
               foreach(Element e in collector)
               {
                     if(e.Name.Contains("Invisible"))
                     {
                        GS = e as GraphicsStyle;
                     }
               }

//FILLED REGION
                FilledRegion FR = null;
                FilteredElementCollector collector1 = new FilteredElementCollector(doc).OfClass(typeof(FilledRegion)).WhereElementIsNotElementType();
                foreach(Element e in collector1)
                {
                    FR = e as FilledRegion;
                    if(FR!=null)
                    {
                        FR.SetLineStyleId(GS.Id);
                    }
                }

I tried and the boundary lines are hidden.

 

Is this what you are looking for?

You mentioned the code you tried and failed so if this is not what you are looking for can you explain what you want in detail?

I hope this helps.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 3

BIM.Frankliang
Collaborator
Collaborator

Dear  Naveen,

          Thank you very much for your code, I have try, that's works good !

I improve codes to avoid multi language issue by using Id.IntegerValue :

var collector = new FilteredElementCollector(doc).OfClass(typeof(GraphicsStyle));
GraphicsStyle g = null;
foreach (GraphicsStyle e in collector)
{
   if (e.GraphicsStyleCategory.Id.IntegerValue.Equals((int)BuiltInCategory.OST_InvisibleLines))
   {
       g = e;
       break;
   }
}

I use e.Category, not e.GraphicsStyleCategory before, so it makes mistake...

 

Thank you !

Yours sincerely

0.png