- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
In Revit 2014, I can't successfully get a point reference so I can create a boundary condition. A null is returned and I'm not sure why (after the transaction finishes, I can manually create a boundary condition).
Sample code to reproduce this is below.
Thanks,
Jon
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class ImportIFCGeomGym : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document doc = commandData.Application.ActiveUIDocument.Document;
Transaction trn = new Transaction(doc, "ggTest");
trn.Start();
int cat = (int)BuiltInCategory.OST_StructuralFraming;
FamilySymbol fs = null;
FilteredElementCollector fec = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol));
foreach (FamilySymbol f in fec)
{
if (f != null & f.Category.Id.IntegerValue == cat)
{
fs = f;
break;
}
}
Level lvl = null;
fec = new FilteredElementCollector(doc).OfClass(typeof(Level));
foreach (Level l in fec)
{
if (l != null)
{
lvl = l;
break;
}
}
Line line = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(0, 3, 0));
FamilyInstance fi = doc.Create.NewFamilyInstance(line, fs, lvl, StructuralType.Beam);
doc.Regenerate();
AnalyticalModel am = fi.GetAnalyticalModel();
if (am != null)
{
if (am.IsSingleCurve())
{
Autodesk.Revit.DB.Curve c = am.GetCurve();
if (c.GetEndPointReference(0) == null)
System.Windows.Forms.MessageBox.Show("Null REference!");
}
}
trn.Commit();
return Result.Succeeded;
}
}
Solved! Go to Solution.