xBimTeam / XbimExchange

XbimExchange contains several COBie schemas and serialisation functions as well as the Model Validation library adopted by theNBS digital toolkit.
https://xbimteam.github.io/
Other
46 stars 42 forks source link

null reference with GetAttributeValue - IIfcPropertyBoundedValue #64

Open dumitrugrl opened 2 years ago

dumitrugrl commented 2 years ago

Hi, I am trying to generate json from an IFC file and still getting this exception:

        Message "Object reference not set to an instance of an object." string
        SerializationStackTraceString   "   at XbimExchanger.IfcToCOBieLiteUK.XbimAttributedObject.GetAttributeValue(IIfcPropertyBoundedValue ifcPropertyBoundedValue)" string
        StackTrace  "   at XbimExchanger.IfcToCOBieLiteUK.XbimAttributedObject.GetAttributeValue(IIfcPropertyBoundedValue ifcPropertyBoundedValue)" string
        TargetSite  {Xbim.CobieLiteUk.AttributeValue GetAttributeValue(Xbim.Ifc4.Interfaces.IIfcPropertyBoundedValue)}  System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}

I am guessing that it has to do with these lines in the IFC:

#100= IFCPROPERTYBOUNDEDVALUE('RentalRatesInCategoryNow',$,$,$,$);
#101= IFCPROPERTYSINGLEVALUE('VacancyRateInCategoryFuture',$,IFCPOSITIVERATIOMEASURE(0.),$);
#102= IFCPROPERTYBOUNDEDVALUE('RentalRatesInCategoryFuture',$,$,$,$);

The line that throws the exception: exchanger.Convert();

The code I am using is the ones in the samples:

 string folder = Path.GetDirectoryName(sFilePath);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(sFilePath);                        

var facilities = new List<Facility>();
var exchanger = new IfcToCOBieLiteUkExchanger(model2, facilities);
facilities = exchanger.Convert();

var facilityType = facilities.FirstOrDefault();
if (facilityType == null)
   return;

facilityType.WriteJson(Path.Combine(folder, $"{fileNameWithoutExtension}.json"), true);

Is there something I am missing?

Thank you!

dumitrugrl commented 2 years ago

The offending ifc entry: #106=IFCPROPERTYBOUNDEDVALUE('RentalRatesInCategoryNow',$,$,$,$); Not sure if just testing for null like in the image is enough to handle this case. image