Message 1 of 9

Not applicable
01-13-2020
01:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm trying to insert geometry (mass) into my project, by making a family, creating the extrusions, and then inserting it into the project. But for some reason I can't make the extrusion. Whenever it tries to, I get this error (which isn't all too helpfull):
Do any of you know what I'm doing wrong?
public void CreateFamily() { //TODO: Family conceptual template option string templateFileName = "C:\\ProgramData\\Autodesk\\RVT 2019\\Family Templates\\English\\Conceptual Mass\\Metric Mass.rft"; Autodesk.Revit.DB.Document familyDocument = RevitDocument.Application.NewFamilyDocument(templateFileName); if (null == familyDocument) { return; } Transaction transaction = new Transaction(familyDocument, "Create Enveo family");
transaction.Start();
CreateMass(familyDocument); transaction.Commit(); SaveAsOptions opt = new SaveAsOptions(); opt.OverwriteExistingFile = true; string fileName = Path.Combine(Path.GetTempPath(), "EnveoOmgeving"); familyDocument.SaveAs(fileName, opt); familyDocument.Close(false); } public void CreateMass(Autodesk.Revit.DB.Document familyDocument) { FamilyItemFactory factory = familyDocument.FamilyCreate; //Application creapp = RevitDocument.Application.Create; SketchPlane sketch = FindElementByTypeAndName(familyDocument, typeof(SketchPlane), "Level 1") as SketchPlane; foreach (var bagMember in BagObjects) { for (int i = 0; i < bagMember.PolyLines.Size; i++) { try { factory.NewExtrusion(true, bagMember.PolyLines, sketch, bagMember.BuildingHeight); } catch (Exception exp) { TaskDialog.Show("ERROR", exp.Message); } } } } /// <summary> /// Return the first element found of the /// specific target type with the given name. /// </summary> Element FindElementByTypeAndName(Autodesk.Revit.DB.Document doc, Type targetType, string targetName) { var test = new FilteredElementCollector(doc) .OfClass(targetType).First<Element>(e => e.Name.Equals(targetName)); return test; }
Solved! Go to Solution.