/// <summary> /// Attemp to excecture the selected option. /// Options that will run with this method are: /// * RotateVew /// * Create3dViews /// * Create Shadow Plan /// </summary> /// <param name="log"> This log will hold warnings/errors if any occur,</param> /// <returns></returns> public bool Go(ModelSetupWizard.TransactionLog log) { if (RotateCurrentView) { var result = RotateView(activeView); if (result) { log.AddSuccess("View rotation successfull"); return(true); } else { log.AddFailure("View rotation unsuccessfull"); return(false); } } if (Create3dViews) { return(CreateWinterViews(log)); } if (CreateShadowPlans) { return(CreateShadowPlanViews(log)); } return(false); }
////[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] private bool CreateWinterViews(ModelSetupWizard.TransactionLog log) { var id = GetViewFamilyId(doc, ViewFamily.ThreeDimensional); // FIXME add error message here if (id == null) { log.AddFailure("Could not gererate 3d view. FamilyId not found"); return(false); } while (StartTime <= EndTime) { using (var t = new Transaction(doc)) { t.Start("Create Solar View"); View view = View3D.CreateIsometric(doc, id); view.ViewTemplateId = ElementId.InvalidElementId; var niceMinutes = "00"; if (StartTime.Minute > 0) { niceMinutes = StartTime.Minute.ToString(CultureInfo.CurrentCulture); } var vname = "SOLAR ACCESS - " + StartTime.ToShortDateString() + "-" + StartTime.Hour + "." + niceMinutes; view.Name = GetNiceViewName(doc, vname); var sunSettings = view.SunAndShadowSettings; sunSettings.StartDateAndTime = StartTime; if (StartTime <= sunSettings.GetSunrise(StartTime).ToLocalTime() || StartTime >= sunSettings.GetSunset(EndTime).ToLocalTime()) { doc.Delete(view.Id); log.AddFailure("Cannot rotate a view that is not in daylight hours: " + vname); StartTime = StartTime.Add(ExportTimeInterval); continue; } sunSettings.SunAndShadowType = SunAndShadowType.StillImage; t.Commit(); if (!RotateView(view)) { doc.Delete(view.Id); log.AddFailure("Could not rotate view: " + vname); continue; } log.AddSuccess("View created: " + vname); StartTime = StartTime.Add(ExportTimeInterval); } } return(true); }
public bool Go(ModelSetupWizard.TransactionLog log) { if (RotateCurrentView) { return(RotateView(activeView)); } if (Create3dViews) { return(CreateWinterViews(log)); } if (CreateShadowPlans) { return(CreateShadowPlanViews(log)); } return(true); }
////[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] private bool CreateShadowPlanViews(ModelSetupWizard.TransactionLog log) { var id = GetViewFamilyId(doc, ViewFamily.FloorPlan); var levelId = GetHighestLevel(doc); if (id == null || levelId == null) { log.AddFailure("Could not gererate shadow plans. FamilyId or LevelId not found"); return(false); } while (StartTime <= EndTime) { using (var t = new Transaction(doc)) { if (t.Start("Create Shadow Plans") == TransactionStatus.Started) { View view = ViewPlan.Create(doc, id, levelId); view.ViewTemplateId = ElementId.InvalidElementId; var niceMinutes = "00"; if (StartTime.Minute > 0) { niceMinutes = StartTime.Minute.ToString(CultureInfo.CurrentCulture); } var vname = "SHADOW PLAN - " + StartTime.ToShortDateString() + "-" + StartTime.Hour + "." + niceMinutes; view.Name = GetNiceViewName(doc, vname); var sunSettings = view.SunAndShadowSettings; sunSettings.StartDateAndTime = StartTime; sunSettings.SunAndShadowType = SunAndShadowType.StillImage; view.SunlightIntensity = 50; log.AddSuccess("Shadow Plan created: " + vname); t.Commit(); StartTime = StartTime.Add(ExportTimeInterval); } } } return(true); }