MACRO TO CLEAN UP SHEET WITH DRAFTING VIEW IN REVIT (USING VB.Net)

MACRO TO CLEAN UP SHEET WITH DRAFTING VIEW IN REVIT (USING VB.Net)

Anonymous
Not applicable
745 Views
5 Replies
Message 1 of 6

MACRO TO CLEAN UP SHEET WITH DRAFTING VIEW IN REVIT (USING VB.Net)

Anonymous
Not applicable

Hello All,

 

I am trying to create a macro that

1. Activates a viewport on sheet which contains a drafting view ( or recursively asks user to select sheet and viewport to modify and then activates that viewport)

2. Selects all elements of the drafting view 

3. Filters out all the horizontal lines and sends to back

4. Filters out all the detail items and brings to front

5. Filters out all detail item tags and brings to front

6. keeps all vertical lines where they are 

 

Any Ideas how to do this.

0 Likes
746 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

Activating a view and selecting specific elements in it is easy to do programmatically.

 

I am not so certain about the sending to front and back.

 

Does Revit support that at all?

 

In any case, the way to proceed to solve a programming task in the Revit API is always to research for an optimal workflow and best practices manually in the user interface first.

 

Once that approach is totally is clear, you can start implementing your macro.

 

 



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

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hello Jeremy Tammik

Thankyou for your reply.

 

I was able to change the draw order of the elements within revit api. However, I am stuck on another front.

How does one filter out lines by Linestyles on a sheet

so basically how does one group lines based on their linestyle

 

Any ideas

 

Mithun Cherian

0 Likes
Message 4 of 6

stever66
Advisor
Advisor

With a filtered element collector.  See if this post from Jeremy helps:

 

https://thebuildingcoder.typepad.com/blog/2016/10/how-to-create-a-new-line-style.html

 

once you know you need a filtered element collector, this was the 3rd result of a search for:

 

filteredelementcollector linestyles revit api

0 Likes
Message 5 of 6

Anonymous
Not applicable

Hello stever66, 

Thankyou for your reply

Unfortunately linestyle it seems is a subcategory of ost_lines and a type of graphicstyle class

Let say I am able to create a list of all gŕaphicstyles or linestyles in the viewport

For each curveelements, i need to loop through the distince linestyles and add that curveelement to a distinct list corresponding to the linestyle it belongs to.

How would i create a list<elements> corresponding to each distinct linestyle 

0 Likes
Message 6 of 6

Anonymous
Not applicable

int i = 0;

ICollection<GraphicsStyle> gas = new List<GraphicsStyle>();
                foreach (CurveElement cv in LineCollect)
                {
               if (gas.Contains(cv.LineStyle))
                    {
                        
                    }
                    else
                {
                        gas.Append(cv.LineStyle);
                }
                    
                }
                foreach (GraphicsStyle gs in gas)
                    {
                    IList<Element> listy[i] = new List<Element>();
                        foreach (CurveElement cv1 in LineCollect)
                        {
                            if (cv1.LineStyle==gs)
                                listy[i].add(cv1);
                        }
                        i=i+1;
                    }
                

 

the syntax is probably wrong. can you declare lists of type list[0], list[1] and so forth?

 

 

 

0 Likes