2

(see my comment below for answer) I have a program, rigorously tested (I thought) that uses:

Options options = new Options();
AnalyticalModel model = Source_Beam.GetAnalyticalModel() as AnalyticalModel; ;
Curve Curvy = model.GetCurve();
XYZ End1 = Curvy.GetEndPoint(0); XYZ End2 = Curvy.GetEndPoint(1);

This used to work just fine, but now using it in a project (with beams of the SAME family as used before), it fails when it tries to do the "Curvy.GetEndPoint(0)".

The error I get is "Revit encountered a System.NullReferenceException: Object reference not set to an instance of any object."

This is very weird, of course, because the Element Source_Beam is certainly a beam, from which it knows how to GetAnalyticalModel, and the compiler is happy to allow the "model.GetCurve()".

Note that I added the "as AnalyticalModel" after it first failed in an attempt to patch the error, since I saw an example on line that had added that code -- it fails with or without casting. And as I mentioned, this program had been use on a test project using exactly the same beam family.

Does anyone know if there is some setting in my real world project that disables abilities of GetAnalyticalModel, or perhaps a better method to simply get the defined start/end points of a beam?

KeachyPeen
  • 147
  • 2
  • 13
  • Never Mind....I found out why. Should keep this question just in case others have this issue.....you have to check on the "Enable Analytical Model" on your model elements in order for ".GetAnalyticalModel" to work. – KeachyPeen Jul 22 '14 at 20:48

0 Answers0