Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 66665

Curve-based family instance created in wrong location

$
0
0

Hi

I'm trying to place a line-based family on an edge of a roof. The API creates the instance but not in the location specified by the diagonal edge that was selected. Any ideas?


Untitled.png

 

        public void voidCut()
        {
            Document doc = this.Document;
            UIDocument uidoc = new UIDocument(doc);
            
            FamilySymbol voidSym = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast<FamilySymbol>().FirstOrDefault(q => q.Family.Name.Contains("BoxGutterVoidSweep"));
            
            Reference edgeRef = uidoc.Selection.PickObject(ObjectType.Edge);
            RoofBase roof = doc.GetElement(edgeRef) as RoofBase;
            Edge edge = roof.GetGeometryObjectFromReference(edgeRef) as Edge;
            Curve curve = edge.AsCurve();
            using (Transaction t = new Transaction(doc, "void"))
            {
                t.Start();
                FamilyInstance voidInstance = doc.Create.NewFamilyInstance(curve, voidSym, null, StructuralType.NonStructural);
                doc.Regenerate();
                LocationCurve lc = voidInstance.Location as LocationCurve;
                lc.Curve = curve;
                t.Commit();
            }
        }


Viewing all articles
Browse latest Browse all 66665

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>