public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIDocument uidoc = commandData.Application.ActiveUIDocument; if (string.IsNullOrEmpty(uidoc.Document.PathName)) { throw new IcnException("The project must be saved before it can be exported to a BIMserver", 10, "QuickExport"); } if (uidoc.Document.PathName.EndsWith(".rfa", StringComparison.InvariantCultureIgnoreCase)) { throw new IcnException("Revit Families can not be exported to a BIMserver", 10, "QuickExport"); } try { BimServerExchangeForm form = new BimServerExchangeForm(uidoc); form.Cmd.BimServerExchange.Init(); while (!form.Cmd.BimServerExchange.CheckLogin()) { BimServerLoginForm login = new BimServerLoginForm(uidoc, form.Data, false); if (DialogResult.Cancel == login.ShowDialog()) { return(Result.Cancelled); } form.Data.CopyFrom(login.Data); break; } // show the export/import dialog (now it is connected to a BimServer that we can query) form.InitialiseProjects(); form.PreselectProject(uidoc.Document?.PathName); form.ShowDialog(); } catch (IcnException iex) { iex.Display(@"Exception in BIMserver Export"); } catch (Exception ex) { string mssg = ex.Message; MessageBox.Show(mssg, @"Exception in BIMserver Export"); } // autocancel for now return(Result.Cancelled); }
internal Commander(Form form, UIDocument uidoc) { if (null == form || null == uidoc) { throw new IcnException("One or more parameters not set to a reference", 10, "BimServerExchange Commander"); } // shared commander ServerInterface = new CmdServerInterface(this); IfcExporter = new CmdIfcExporterAPI(this, uidoc); // foreach form and context that has a separate commander create it here if (form is BimServerLoginForm) { BimServerLogin = new CmdBimServerLogin((BimServerLoginForm)form, uidoc); return; } if (form is BimServerExportForm) { BimServerExportForm qx = (BimServerExportForm)form; BimServerExport = new CmdBimServerExport(qx, uidoc); ServerInterface.ReportStatus = qx.ReportStatus; return; } if (form is BimServerExchangeForm) { BimServerExchangeForm ex = (BimServerExchangeForm)form; BimServerExchange = new CmdBimServerExchange(ex, uidoc); ServerInterface.ReportStatus = ex.ReportStatus; return; } if (form is ProcessingStatusForm) { ProcessingStatusForm sx = (ProcessingStatusForm)form; ProcessingStatus = new CmdProcessingStatus(sx); ServerInterface.ReportStatus = sx.ReportStatus; return; } throw new IcnException($"Unhandled Form of type '{form.GetType().Name}'", 20, "Commander"); }
internal CmdBimServerExchange(BimServerExchangeForm form, UIDocument uidoc) { Form = form; UIDoc = uidoc; }