/// <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); }
// Lines public Line LineToSpeckle(AcadDB.Line line) { var _line = new Line(PointToSpeckle(line.StartPoint), PointToSpeckle(line.EndPoint), ModelUnits); _line.domain = new Interval(line.StartParam, line.EndParam); _line.length = line.Length; _line.bbox = BoxToSpeckle(line.GeometricExtents, true); return(_line); }
public Line LineToSpeckle(LineSegment3d line) { var _line = new Line(PointToSpeckle(line.StartPoint), PointToSpeckle(line.EndPoint), ModelUnits); _line.length = line.Length; _line.domain = IntervalToSpeckle(line.GetInterval()); _line.bbox = BoxToSpeckle(line.OrthoBoundBlock); return(_line); }
public Line3d LineToNative(Line line) { var _line = new Line3d(PointToNative(line.start), PointToNative(line.end)); if (line.domain != null) { _line.SetInterval(IntervalToNative(line.domain)); } return(_line); }
// Line public Line LineToSpeckle(Line3d line) { var startParam = line.GetParameterOf(line.StartPoint); var endParam = line.GetParameterOf(line.EndPoint); var _line = new Line(PointToSpeckle(line.StartPoint), PointToSpeckle(line.EndPoint), ModelUnits); _line.length = line.GetLength(startParam, endParam, tolerance); _line.domain = IntervalToSpeckle(line.GetInterval()); _line.bbox = BoxToSpeckle(line.OrthoBoundBlock); return(_line); }
public Base ColumnToSpeckle(DB.FamilyInstance revitColumn) { var symbol = Doc.GetElement(revitColumn.GetTypeId()) as FamilySymbol; var speckleColumn = new RevitColumn(); speckleColumn.family = symbol.FamilyName; speckleColumn.type = Doc.GetElement(revitColumn.GetTypeId()).Name; speckleColumn.level = ConvertAndCacheLevel(revitColumn, BuiltInParameter.FAMILY_BASE_LEVEL_PARAM); speckleColumn.topLevel = ConvertAndCacheLevel(revitColumn, BuiltInParameter.FAMILY_TOP_LEVEL_PARAM); speckleColumn.baseOffset = GetParamValue <double>(revitColumn, BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM); speckleColumn.topOffset = GetParamValue <double>(revitColumn, BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM); speckleColumn.facingFlipped = revitColumn.FacingFlipped; speckleColumn.handFlipped = revitColumn.HandFlipped; speckleColumn.isSlanted = revitColumn.IsSlantedColumn; //speckleColumn.structural = revitColumn.StructuralType == StructuralType.Column; //geometry var baseGeometry = LocationToSpeckle(revitColumn); var baseLine = baseGeometry as ICurve; //make line from point and height if (baseLine == null && baseGeometry is Point basePoint) { var elevation = ConvertAndCacheLevel(revitColumn, BuiltInParameter.FAMILY_TOP_LEVEL_PARAM).elevation; baseLine = new Line(basePoint, new Point(basePoint.x, basePoint.y, elevation + speckleColumn.topOffset, ModelUnits), ModelUnits); } if (baseLine == null) { return(RevitElementToSpeckle(revitColumn)); } speckleColumn.baseLine = baseLine; //all speckle columns should be line based GetAllRevitParamsAndIds(speckleColumn, revitColumn, new List <string> { "FAMILY_BASE_LEVEL_PARAM", "FAMILY_TOP_LEVEL_PARAM", "FAMILY_BASE_LEVEL_OFFSET_PARAM", "FAMILY_TOP_LEVEL_OFFSET_PARAM", "SCHEDULE_BASE_LEVEL_OFFSET_PARAM", "SCHEDULE_TOP_LEVEL_OFFSET_PARAM" }); if (revitColumn.Location is LocationPoint) { speckleColumn.rotation = ((LocationPoint)revitColumn.Location).Rotation; } speckleColumn.displayMesh = GetElementMesh(revitColumn); return(speckleColumn); }
public RevitColumn ColumnToSpeckle(DB.FamilyInstance revitColumn) { var speckleColumn = new RevitColumn(); speckleColumn.type = Doc.GetElement(revitColumn.GetTypeId()).Name; speckleColumn.level = ConvertAndCacheLevel(revitColumn, BuiltInParameter.FAMILY_BASE_LEVEL_PARAM); speckleColumn.topLevel = ConvertAndCacheLevel(revitColumn, BuiltInParameter.FAMILY_TOP_LEVEL_PARAM); speckleColumn.baseOffset = GetParamValue <double>(revitColumn, BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM); speckleColumn.topOffset = GetParamValue <double>(revitColumn, BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM); speckleColumn.facingFlipped = revitColumn.FacingFlipped; speckleColumn.handFlipped = revitColumn.HandFlipped; speckleColumn.isSlanted = revitColumn.IsSlantedColumn; speckleColumn.structural = revitColumn.StructuralType == StructuralType.Column; //geometry var baseGeometry = LocationToSpeckle(revitColumn); var baseLine = baseGeometry as ICurve; //make line from point and height if (baseLine == null && baseGeometry is Point basePoint) { var topLevelParam = revitColumn.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_PARAM); var elevation = (double)((RevitLevel)ParameterToSpeckle(topLevelParam).value).elevation; baseLine = new Line(basePoint, new Point(basePoint.x, basePoint.y, elevation + speckleColumn.topOffset, ModelUnits), ModelUnits); } if (baseLine == null) { throw new Speckle.Core.Logging.SpeckleException("Only line based Columns are currently supported."); } speckleColumn.baseLine = baseLine; //all speckle columns should be line based GetAllRevitParamsAndIds(speckleColumn, revitColumn, new List <string> { "FAMILY_BASE_LEVEL_PARAM", "FAMILY_TOP_LEVEL_PARAM", "FAMILY_BASE_LEVEL_OFFSET_PARAM", "FAMILY_TOP_LEVEL_OFFSET_PARAM" }); if (revitColumn.Location is LocationPoint) { speckleColumn.rotation = ((LocationPoint)revitColumn.Location).Rotation; } speckleColumn["@displayMesh"] = GetElementMesh(revitColumn); return(speckleColumn); }
public AcadDB.Line LineToNativeDB(Line line) { return(new AcadDB.Line(PointToNative(line.start), PointToNative(line.end))); }