public DetailCurve DetailCurveToSpeckle(DB.DetailCurve revitCurve) { var speckleCurve = new DetailCurve(CurveToSpeckle(revitCurve.GeometryCurve), revitCurve.LineStyle.Name); speckleCurve.elementId = revitCurve.Id.ToString(); speckleCurve.applicationId = revitCurve.UniqueId; speckleCurve.units = ModelUnits; return(speckleCurve); }
public List <ApplicationPlaceholderObject> DetailCurveToNative(DetailCurve speckleCurve) { var docObj = GetExistingElementByApplicationId(speckleCurve.applicationId); //delete and re-create line //TODO: check if can be modified if (docObj != null) { Doc.Delete(docObj.Id); } var placeholders = new List <ApplicationPlaceholderObject>(); var crvEnum = CurveToNative(speckleCurve.baseCurve).GetEnumerator(); while (crvEnum.MoveNext() && crvEnum.Current != null) { var baseCurve = crvEnum.Current as DB.Curve; DB.DetailCurve revitCurve = null; try { revitCurve = Doc.Create.NewDetailCurve(Doc.ActiveView, baseCurve); } catch (Exception) { throw (new Exception($"Detail curve creation failed\nView is not valid for detail curve creation.")); } var lineStyles = revitCurve.GetLineStyleIds(); var lineStyleId = lineStyles.FirstOrDefault(x => Doc.GetElement(x).Name == speckleCurve.lineStyle); if (lineStyleId != null) { revitCurve.LineStyle = Doc.GetElement(lineStyleId); } placeholders.Add(new ApplicationPlaceholderObject() { applicationId = speckleCurve.applicationId, ApplicationGeneratedId = revitCurve.UniqueId, NativeObject = revitCurve }); Report.Log($"Created DetailCurve {revitCurve.Id}"); } return(placeholders); }
public ApplicationPlaceholderObject DetailCurveToNative(DetailCurve speckleCurve) { var docObj = GetExistingElementByApplicationId(speckleCurve.applicationId); //TODO: support polybline/polycurve lines var baseCurve = CurveToNative(speckleCurve.baseCurve).get_Item(0); //delete and re-create line //TODO: check if can be modified if (docObj != null) { Doc.Delete(docObj.Id); } DB.DetailCurve revitCurve = null; try { revitCurve = Doc.Create.NewDetailCurve(Doc.ActiveView, baseCurve); } catch (Exception) { ConversionErrors.Add(new Error("Detail curve creation failed", $"View is not valid for detail curve creation.")); throw; } var lineStyles = revitCurve.GetLineStyleIds(); var lineStyleId = lineStyles.FirstOrDefault(x => Doc.GetElement(x).Name == speckleCurve.lineStyle); if (lineStyleId != null) { revitCurve.LineStyle = Doc.GetElement(lineStyleId); } return(new ApplicationPlaceholderObject() { applicationId = speckleCurve.applicationId, ApplicationGeneratedId = revitCurve.UniqueId, NativeObject = revitCurve }); }