The problem is the method NewFloor doesn't match the floor type that you passed in.
If you want to create a slab with the "BaseSlab" type , please use NewSlab() method.
Here is the code to create a normal floor.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.ApplicationServices;
namespace GGYM
{
[Autodesk.Revit.Attributes.Transaction(TransactionMode.Manual)]
publicclassImportIFCGeomGym : IExternalCommand
{
publicResult Execute(ExternalCommandData commandData,
refstring message, ElementSet elements)
{
Document doc = commandData.Application.ActiveUIDocument.Document;
Application app = commandData.Application.Application;
Transaction trn = newTransaction(doc, "ggTest");
trn.Start();
CurveArray ca = newCurveArray();
double d = 16.404199500;
XYZ p1 = newXYZ(-d, -d, 0), p2 = newXYZ(-d, d, 0),
p3 = newXYZ(d, d, 0), p4 = newXYZ(d, -d, 0);
ca.Append(app.Create.NewLine(p1, p2, true));
ca.Append(app.Create.NewLine(p2, p3, true));
ca.Append(app.Create.NewLine(p3, p4, true));
ca.Append(app.Create.NewLine(p4, p1, true));
ElementClassFilter filter = newElementClassFilter(typeof(Level));
FilteredElementCollector coll = newFilteredElementCollector(doc);
coll.WherePasses(filter);
System.Collections.IEnumerator i = coll.GetElementIterator();
i.Reset();
Level l = null;
while (i.MoveNext())
{
l = i.Current asLevel;
if (l != null)
{
break;
}
}
FloorType ft = null;
foreach (FloorType t in doc.FloorTypes)
{
if (t != null && string.Compare(t.Name, "Generic 300mm", true) == 0)
{
ft = t;
break;
}
}
Floor f = doc.Create.NewFloor(ca, ft, l, false);
//doc.Regenerate();
trn.Commit();
returnResult.Succeeded;
}
}
}
______________________________________________________________
If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!