public override void DoWork(Action <string, double> ReportProgress, Action Done) { ReportProgress("Opening model...", -2); Model model = new Model(); string fileName = GsaModel.FileName; ReturnValue status = model.Open(fileName); GsaModel.Model = model; if (status != 0) { string message = "Unable to open Model" + System.Environment.NewLine + status.ToString(); ReportProgress(message, -20); return; } ReportProgress("Updating units...", -2); Titles.GetTitlesFromGSA(model); string mes = Path.GetFileNameWithoutExtension(fileName); ReportProgress(mes, -1); Done(); }
protected override void SolveInstance(IGH_DataAccess DA) { Model model = new Model(); GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); if (DA.GetData(0, ref gh_typ)) { if (gh_typ.Value is GH_String) { string tempfile = ""; if (GH_Convert.ToString(gh_typ, out tempfile, GH_Conversion.Both)) { fileName = tempfile; } if (!fileName.EndsWith(".gwb")) { fileName = fileName + ".gwb"; } ReturnValue status = model.Open(fileName); if (status == 0) { GsaModel gsaModel = new GsaModel { Model = model, FileName = fileName }; Titles.GetTitlesFromGSA(model); string mes = Path.GetFileName(fileName); mes = mes.Substring(0, mes.Length - 4); Message = mes; DA.SetData(0, new GsaModelGoo(gsaModel)); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to open Model" + System.Environment.NewLine + status.ToString()); return; } } else if (gh_typ.Value is GsaAPI.Model) { gh_typ.CastTo(ref model); GsaModel gsaModel = new GsaModel { Model = model, }; DA.SetData(0, new GsaModelGoo(gsaModel)); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to open Model"); return; } } else { ReturnValue status = model.Open(fileName); if (status == 0) { GsaModel gsaModel = new GsaModel { Model = model, FileName = fileName }; Titles.GetTitlesFromGSA(model); string mes = Path.GetFileName(fileName); mes = mes.Substring(0, mes.Length - 4); Message = mes; DA.SetData(0, new GsaModelGoo(gsaModel)); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to open Model" + System.Environment.NewLine + status.ToString()); return; } } }