/// <summary> /// Tries to to get the location as a Curve /// </summary> /// <param name="loc"></param> /// <returns></returns> private Base TryGetLocationAsCurve(FamilyInstance familyInstance) { if (familyInstance.CanHaveAnalyticalModel()) { //no need to apply offset transform var analyticalModel = familyInstance.GetAnalyticalModel(); if (analyticalModel != null) { return(CurveToSpeckle(analyticalModel.GetCurve()) as Base); } } var point = PointToSpeckle((familyInstance.Location as LocationPoint).Point); try { //apply offset transform and create line var baseOffset = GetParamValue <double>(familyInstance, BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM); var baseLevel = ConvertAndCacheLevel(familyInstance, BuiltInParameter.FAMILY_BASE_LEVEL_PARAM); var topOffset = GetParamValue <double>(familyInstance, BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM); var topLevel = ConvertAndCacheLevel(familyInstance, BuiltInParameter.FAMILY_TOP_LEVEL_PARAM); var baseLine = new Line(new [] { point.x, point.y, baseLevel.elevation + baseOffset, point.x, point.y, topLevel.elevation + topOffset }, ModelUnits); baseLine.length = Math.Abs(baseLine.start.z - baseLine.end.z); return(baseLine); } catch { } //everything else failed, just return the base point without moving it return(point); }
/// <summary> /// Tries to to get the location as a Curve /// </summary> /// <param name="loc"></param> /// <returns></returns> private Base TryGetLocationAsCurve(FamilyInstance familyInstance) { if (familyInstance.CanHaveAnalyticalModel()) { //no need to apply offset transform var analiticalModel = familyInstance.GetAnalyticalModel(); if (analiticalModel != null) { return(CurveToSpeckle(analiticalModel.GetCurve()) as Base); } } var point = (familyInstance.Location as LocationPoint).Point; try { //apply offset tranform and create line var baseOffset = familyInstance.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM).AsDouble(); //keep internal units var topOffset = familyInstance.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM).AsDouble(); //keep internal units var topLevel = (DB.Level)Doc.GetElement(familyInstance.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_PARAM).AsElementId()); //keep internal units var baseLine = DB.Line.CreateBound(new XYZ(point.X, point.Y, point.Z + baseOffset), new XYZ(point.X, point.Y, topLevel.Elevation)); return(LineToSpeckle(baseLine)); } catch { } //everything else failed, just retun the base point without moving it return(PointToSpeckle(point)); }