Set Solid In view Structural Rebar

Set Solid In view Structural Rebar

jamess166
Advocate Advocate
3,347 Views
6 Replies
Message 1 of 7

Set Solid In view Structural Rebar

jamess166
Advocate
Advocate

Good day,
I need to apply the SetSolidInView method for all the Structural Rebar in active 3d view, I hope suggestion. Thanks in advance.

 

Captura.PNG

0 Likes
Accepted solutions (1)
3,348 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

HI jamess,

ICollection<Element> rebers = new FilteredElementCollector(doc, doc.ActiveView.Id).OfCategory(BuiltInCategory.OST_Rebar).ToElements();
                List<Rebar> List_Rebar = new List<Rebar>();
                if(rebers==null)
                {
                    TaskDialog.Show("REBAR", "NO REBAR EXISTS IN THE DRAWINGS");
                } 
                Transaction trans = new Transaction(doc);
                trans.Start("ACTRAN");
                IEnumerable<ViewFamilyType> VFT = from Element in new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType)) let type = Element as ViewFamilyType where type.ViewFamily == ViewFamily.ThreeDimensional select type;
                View3D v3d = View3D.CreatePerspective(doc, VFT.First().Id);
               foreach(Rebar r in rebers)
                {
                    r.SetSolidInView(v3d, true);
                    List_Rebar.Add(r);
                }
                TaskDialog.Show("LIST_REBAR", List_Rebar.Count().ToString());
                trans.Commit();
0 Likes
Message 3 of 7

jamess166
Advocate
Advocate

Thank you very much for your help, I have modified my code according to your recommendation, but two things happen:

 

- I do not detect any structural Rebar.
- Create a new 3D view and do not use the current view I have.

 

Captura.PNG

0 Likes
Message 4 of 7

Anonymous
Not applicable

Hi @jamess166,

 

From your screenshot it shows that the condition is set to (rebar !=null).

 

could you please change this condition to (rebar= =null).

Message 5 of 7

jamess166
Advocate
Advocate

If it really works for me, but there is some way to execute the solid rebar in view method without having to create a new 3d view, and apply it to the 3d active view.

 

Captura.PNG

0 Likes
Message 6 of 7

jamess166
Advocate
Advocate
I still can not find the solution
0 Likes
Message 7 of 7

so-chong
Advocate
Advocate
Accepted solution

Hi,

Try to replace this line of code:

View3D v3d = View3D.CreatePerspective(doc, VFT.First().Id);

with this line of code:

View3D v3d = doc.ActiveView as View3D;

Also try to reuse the 'using' statement in your code.

Your first screenshot shows that you were using it.

Hope this helps!

0 Likes