draw structural framing between structural column

draw structural framing between structural column

Anonymous
Not applicable
326 Views
1 Reply
Message 1 of 2

draw structural framing between structural column

Anonymous
Not applicable

Hello, I want to create an addin which draw structural framing between two structural column. How can I do this?

 

 

0 Likes
327 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

This is the code which I am using, but it show the exception"NullReferenceException".

 

 

using (Transaction t = new Transaction(doc, "DrawBeam"))
            {

                t.Start();
                
                  FilteredElementCollector column = new FilteredElementCollector(doc);
                 column.OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_StructuralColumns);
                 foreach (FamilyInstance c in column)
                {
                        FilteredElementCollector collector = new FilteredElementCollector(doc);
                        collector.OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_StructuralFraming);
                        FamilySymbol symbol = collector.FirstElement() as FamilySymbol;

                        // The only way to get a Face to use with this NewFamilyInstance overload
                        // is from Element.Geometry with ComputeReferences turned on
                        Face face = null;
                        Options geomOptions = new Options();
                        geomOptions.ComputeReferences = true;
                        GeometryElement wallGeom = c.get_Geometry(geomOptions);
                        foreach (GeometryObject geomObj in wallGeom)
                        {
                                Solid geomSolid = geomObj as Solid;
                                if (null != geomSolid)
                                {
                                    foreach (Face geomFace in geomSolid.Faces)
                                    {
                                        face = geomFace;
                                        break;
                                    }
                                    break;
                                }
                        }

                        // Get the center of the wall 
                        //BoundingBoxUV bboxUV = face.GetBoundingBox();
                        BoundingBoxUV bboxUV=face.GetBoundingBox();
                        UV center = (bboxUV.Max + bboxUV.Min) / 2.0;
                        XYZ location = face.Evaluate(center);
                        XYZ normal = face.ComputeNormal(center);
                        XYZ refDir = normal.CrossProduct(XYZ.BasisZ);

                        FamilyInstance instance = doc.Create.NewFamilyInstance(face, location, refDir, symbol);         
                }
                 t.Commit();

0 Likes