/// <summary> /// Collect the parameters and export /// </summary> /// <returns></returns> public override bool Export() { base.Export(); bool exported = false; //parameter : ViewSet views ViewSet views = new ViewSet(); if (m_currentViewOnly) { views.Insert(m_activeDoc.ActiveView); } else { views = m_selectViewsData.SelectedViews; } ICollection <ElementId> viewIds = new List <ElementId>(); foreach (View view in views) { viewIds.Add(view.Id); } //parameter : DXFExportOptions dxfExportOptions SATExportOptions satExportOptions = new SATExportOptions(); //Export exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, viewIds, satExportOptions); return(exported); }
/// <summary> /// Collect the parameters and export /// </summary> /// <returns></returns> public override bool Export() { base.Export(); bool exported = false; //parameter : ViewSet views ViewSet views = new ViewSet(); if (m_currentViewOnly) { views.Insert(m_activeDoc.ActiveView); } else { views = m_selectViewsData.SelectedViews; } //parameter : DXFExportOptions dxfExportOptions SATExportOptions satExportOptions = new SATExportOptions(); //Export exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, satExportOptions); return(exported); }
/// <summary> /// Collect the parameters and export /// </summary> /// <returns></returns> public override bool Export() { base.Export(); bool exported = false; //parameter : ViewSet views ViewSet views = new ViewSet(); if (m_currentViewOnly) { views.Insert(m_activeDoc.ActiveView); } else { views = m_selectViewsData.SelectedViews; } //parameter : DXFExportOptions dxfExportOptions SATExportOptions satExportOptions = new SATExportOptions(); //Export exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, satExportOptions); return exported; }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; Selection sel = uidoc.Selection; // Retrieve all floors from the model var floors = new FilteredElementCollector(doc) .OfClass(typeof(Floor)) .ToElements() .Cast <Floor>() .ToList(); if (2 != floors.Count) { message = "Please create two intersected floors"; return(Result.Failed); } // Retrieve the floor solids Options opt = new Options(); var geometry1 = floors[0].get_Geometry(opt); var geometry2 = floors[1].get_Geometry(opt); var solid1 = geometry1.FirstOrDefault() as Solid; var solid2 = geometry2.FirstOrDefault() as Solid; // Calculate the intersection solid var intersectedSolid = BooleanOperationsUtils .ExecuteBooleanOperation(solid1, solid2, BooleanOperationsType.Intersect); // Search for the metric mass family template file string template_path = DirSearch( app.FamilyTemplatePath, "Metric Mass.rft"); // Create a new temporary family var family_doc = app.NewFamilyDocument( template_path); // Create a free form element // from the intersection solid using (var t = new Transaction(family_doc)) { t.Start("Add Free Form Element"); var freeFormElement = FreeFormElement.Create( family_doc, intersectedSolid); t.Commit(); } string dir = Path.GetTempPath(); string filepath = Path.Combine(dir, "floor_intersection_family.rfa"); SaveAsOptions sao = new SaveAsOptions() { OverwriteExistingFile = true }; family_doc.SaveAs(filepath, sao); // Create 3D View var viewFamilyType = new FilteredElementCollector(family_doc) .OfClass(typeof(ViewFamilyType)) .OfType <ViewFamilyType>() .FirstOrDefault(x => x.ViewFamily == ViewFamily.ThreeDimensional); View3D threeDView; using (var t = new Transaction(family_doc)) { t.Start("Create 3D View"); threeDView = View3D.CreateIsometric( family_doc, viewFamilyType.Id); t.Commit(); } // Export to SAT var viewSet = new List <ElementId>() { threeDView.Id }; SATExportOptions exportOptions = new SATExportOptions(); var res = family_doc.Export(dir, "SolidFile.sat", viewSet, exportOptions); return(Result.Succeeded); }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; Selection sel = uidoc.Selection; // Retrieve all floors from the model var floors = new FilteredElementCollector( doc ) .OfClass( typeof( Floor ) ) .ToElements() .Cast<Floor>() .ToList(); if( 2 != floors.Count ) { message = "Please create two intersected floors"; return Result.Failed; } // Retrieve the floor solids Options opt = new Options(); var geometry1 = floors[0].get_Geometry( opt ); var geometry2 = floors[1].get_Geometry( opt ); var solid1 = geometry1.FirstOrDefault() as Solid; var solid2 = geometry2.FirstOrDefault() as Solid; // Calculate the intersection solid var intersectedSolid = BooleanOperationsUtils .ExecuteBooleanOperation( solid1, solid2, BooleanOperationsType.Intersect ); // Search for the metric mass family template file string template_path = DirSearch( app.FamilyTemplatePath, "Metric Mass.rft" ); // Create a new temporary family var family_doc = app.NewFamilyDocument( template_path ); // Create a free form element // from the intersection solid using( var t = new Transaction( family_doc ) ) { t.Start( "Add Free Form Element" ); var freeFormElement = FreeFormElement.Create( family_doc, intersectedSolid ); t.Commit(); } string dir = Path.GetTempPath(); string filepath = Path.Combine( dir, "floor_intersection_family.rfa" ); SaveAsOptions sao = new SaveAsOptions() { OverwriteExistingFile = true }; family_doc.SaveAs( filepath, sao ); // Create 3D View var viewFamilyType = new FilteredElementCollector( family_doc ) .OfClass( typeof( ViewFamilyType ) ) .OfType<ViewFamilyType>() .FirstOrDefault( x => x.ViewFamily == ViewFamily.ThreeDimensional ); View3D threeDView; using( var t = new Transaction( family_doc ) ) { t.Start( "Create 3D View" ); threeDView = View3D.CreateIsometric( family_doc, viewFamilyType.Id ); t.Commit(); } // Export to SAT var viewSet = new List<ElementId>() { threeDView.Id }; SATExportOptions exportOptions = new SATExportOptions(); var res = family_doc.Export( dir, "SolidFile.sat", viewSet, exportOptions ); return Result.Succeeded; }
/// <summary> /// Collect the parameters and export /// </summary> /// <returns></returns> public override bool Export() { base.Export(); bool exported = false; //parameter : ViewSet views ViewSet views = new ViewSet(); if (m_currentViewOnly) { views.Insert(m_activeDoc.ActiveView); } else { views = m_selectViewsData.SelectedViews; } ICollection<ElementId> viewIds = new List<ElementId>(); foreach (View view in views) { viewIds.Add(view.Id); } //parameter : DXFExportOptions dxfExportOptions SATExportOptions satExportOptions = new SATExportOptions(); //Export exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, viewIds, satExportOptions); return exported; }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; // Access current selection Selection sel = uidoc.Selection; // get floors from the model var floors = new FilteredElementCollector(doc) .OfClass(typeof(Floor)) .ToElements() .Cast<Floor>() .ToList(); if (floors.Count != 2) { message = "Please create two intersected floors"; return Result.Failed; } // get the floors solids var geometry1 = floors[0].get_Geometry(new Options()); var geometry2 = floors[1].get_Geometry(new Options()); var solid1 = geometry1.FirstOrDefault() as Solid; var solid2 = geometry2.FirstOrDefault() as Solid; // get the solid, generated by floor intersecting var intersectedSolid = BooleanOperationsUtils.ExecuteBooleanOperation(solid1, solid2, BooleanOperationsType.Intersect); // create new family var assembly = Assembly.GetExecutingAssembly(); var fi = new FileInfo(Assembly.GetExecutingAssembly().Location); var templatePath = Path.Combine(fi.DirectoryName, "Metric Mass.rft"); var familyDocument = app.NewFamilyDocument(templatePath); //create free form element using (var t = new Transaction(familyDocument, "Add Free Form Element")) { t.Start(); var freeFormElement = Autodesk.Revit.DB.FreeFormElement.Create(familyDocument, intersectedSolid); t.Commit(); } familyDocument.SaveAs(Path.Combine(fi.DirectoryName, "new family.rfa"), new SaveAsOptions(){OverwriteExistingFile = true}); // create 3d view var viewFamilyType = new FilteredElementCollector(familyDocument) .OfClass(typeof(ViewFamilyType)) .OfType<ViewFamilyType>() .FirstOrDefault(x => x.ViewFamily == ViewFamily.ThreeDimensional); View3D threeDView; using (var t = new Transaction(familyDocument, "Create 3d view")) { t.Start(); threeDView = View3D.CreateIsometric( familyDocument, viewFamilyType.Id); t.Commit(); } // Export to Sat var viewSet = new List<ElementId>() { threeDView.Id }; SATExportOptions exportOptions = new SATExportOptions(); var res = familyDocument.Export(fi.DirectoryName, "SolidFile.sat", viewSet, exportOptions); return Result.Succeeded; }