public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { m_app = commandData.Application; m_doc = m_app.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("Utilities-RenameFamily", commandData.Application.Application.VersionNumber)); var viewModel = new RenameViewModel(commandData.Application); var window = new RenameWindow { DataContext = viewModel }; window.ShowDialog(); Log.AppendLog(LogMessageType.INFO, "Ended"); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Log.AppendLog(LogMessageType.INFO, "Started"); try { // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontinue the unused ones. AddinUtilities.PublishAddinLog( new AddinLog("Feedback Tool", commandData.Application.Application.VersionNumber)); var title = "HOK Feedback Tool v." + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; var model = new FeedbackModel(); var viewModel = new FeedbackViewModel(model, title); var view = new FeedbackView { DataContext = viewModel }; var unused = new WindowInteropHelper(view) { Owner = Process.GetCurrentProcess().MainWindowHandle }; view.ShowDialog(); } catch (Exception e) { Log.AppendLog(LogMessageType.EXCEPTION, e.Message); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { m_app = commandData.Application; m_doc = m_app.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("ViewAnalysis-LPD Analysis", commandData.Application.Application.VersionNumber)); var docPath = RevitDocument.GetCentralPath(m_doc); if (!string.IsNullOrEmpty(docPath)) { var commandForm = new CommandForm(m_app); commandForm.ShowDialog(); } else { Log.AppendLog(LogMessageType.WARNING, "File not saved"); MessageBox.Show(Properties.Resources.Command_FileNotSaved, Properties.Resources.Command_FileNotSavedHeader, MessageBoxButtons.OK, MessageBoxIcon.Information); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { var uiApp = commandData.Application; var doc = uiApp.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); try { // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("MissionControl-GroupsManager", commandData.Application.Application.VersionNumber)); var model = new GroupsManagerModel(doc); var viewModel = new GroupsManagerViewModel(model); var view = new GroupsManagerView { DataContext = viewModel }; var unused = new WindowInteropHelper(view) { Owner = Process.GetCurrentProcess().MainWindowHandle }; view.Show(); } catch (Exception e) { Log.AppendLog(LogMessageType.EXCEPTION, e.Message); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { Log.AppendLog(LogMessageType.INFO, "Started"); try { // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("Beta-BetaInstaller", commandData.Application.Application.VersionNumber)); var model = AppCommand.Instance.ViewModel; var viewModel = new AddinInstallerViewModel(model); var view = new AddinInstallerWindow { DataContext = viewModel }; var unused = new WindowInteropHelper(view) { Owner = Process.GetCurrentProcess().MainWindowHandle }; view.ShowDialog(); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { m_app = commandData.Application; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("Utilities-CameraDuplicator", m_app.Application.VersionNumber)); if (m_app.Application.Documents.Size > 1) { var vm = new CameraViewModel(); var cameraWindow = new CameraWindow(m_app) { DataContext = vm }; if (true == cameraWindow.ShowDialog()) { cameraWindow.Close(); } } else { MessageBox.Show("Please open more than two Revit documents before running this tool.\n A source model and a recipient model are required.", "Opened Revit Documents Required!", MessageBoxButton.OK, MessageBoxImage.Information); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
protected override object RequestComAddInAutomationService() { if (_addinUtilities == null) { _addinUtilities = new AddinUtilities(); } return(_addinUtilities); }
public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { Log.AppendLog(LogMessageType.INFO, "Started"); try { var addins = AppCommand.thisApp.addins; StoreTempCollection(addins.AddinCollection); var viewModel = new AddInViewModel(addins); var mainWindow = new MainWindow { DataContext = viewModel }; if (mainWindow.ShowDialog() == true) { var vm = (AddInViewModel)mainWindow.DataContext; try { // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. // If Window was closed using the OK button we can collect more details about the app to publish. var log = new AddinLog("AddinManager", commandData.Application.Application.VersionNumber) { DetailInfo = vm.AddinsObj.AddinCollection .Select(x => new InfoItem { Name = x.ToolName, Value = x.ToolLoadType.ToString() }) .ToList() }; AddinUtilities.PublishAddinLog(log); } catch (Exception e) { Log.AppendLog(LogMessageType.EXCEPTION, e.Message); } // write setting and load addins. AppCommand.thisApp.addins = vm.AddinsObj; AppCommand.thisApp.ProcessPlugins(); } else { // If user cancelled out of this window, we don't need to log all the details, other than that it was opened. AddinUtilities.PublishAddinLog(new AddinLog("AddinManager", commandData.Application.Application.VersionNumber)); OverrideTempSettings(); } } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { var uiApp = commandData.Application; var doc = uiApp.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); try { // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontinue the unused ones. AddinUtilities.PublishAddinLog( new AddinLog("MissionControl-WebsiteLink", commandData.Application.Application.VersionNumber)); var launchHome = false; if (!string.IsNullOrWhiteSpace(doc.PathName)) { var centralPath = FileInfoUtil.GetCentralFilePath(doc); if (!string.IsNullOrWhiteSpace(centralPath)) { if (MissionControlSetup.Projects.ContainsKey(centralPath)) { var id = MissionControlSetup.Projects[centralPath].Id; Process.Start(ServerUtilities.RestApiBaseUrl + "/#/projects/edit/" + id); } else { launchHome = true; } } else { launchHome = true; } } else { launchHome = true; } if (launchHome) { Process.Start(ServerUtilities.RestApiBaseUrl + "/#/home"); } } catch (Exception e) { Log.AppendLog(LogMessageType.EXCEPTION, e.Message); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog( new AddinLog("MissionControl-Communicator", commandData.Application.Application.VersionNumber)); ToggleCommunicator(commandData.Application); Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { m_app = commandData.Application; m_doc = m_app.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog( new AddinLog("MassTools-CreateMass", commandData.Application.Application.VersionNumber)); GetModelInformation(); var sourceWindow = new MassSourceWindow(m_app, modelDictionary); if (sourceWindow.ShowDialog() == true) { selectedSource = sourceWindow.SelectedSourceType; switch (selectedSource) { case SourceType.Rooms: roomDictionary = sourceWindow.RoomDictionary; var roomWindow = new RoomWindow(m_app, modelDictionary, roomDictionary); roomWindow.ShowDialog(); break; case SourceType.Areas: areaDictionary = sourceWindow.AreaDictionary; var areaWindow = new AreaWindow(m_app, modelDictionary, areaDictionary); areaWindow.ShowDialog(); break; case SourceType.Floors: floorDictionary = sourceWindow.FloorDictionary; var floorWindow = new FloorWindow(m_app, modelDictionary, floorDictionary); floorWindow.ShowDialog(); break; } } Log.AppendLog(LogMessageType.INFO, "Ended."); return(Result.Succeeded); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); return(Result.Failed); } }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { m_app = commandData.Application; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog( new AddinLog("ElementMover", commandData.Application.Application.VersionNumber)); AppCommand.thisApp.ShowMover(m_app); Log.AppendLog(LogMessageType.INFO, "Ended."); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { m_app = commandData.Application; m_doc = m_app.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("Utilities-ViewDepth", commandData.Application.Application.VersionNumber)); var overrideViewDepth = new OverrideViewDepth(m_app); Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { m_app = commandData.Application; m_doc = m_app.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog( new AddinLog("MassTools-MassCommands", commandData.Application.Application.VersionNumber)); m_app.Application.FailuresProcessing += OnFailuresProcessing; var linkedFilesForm = new Form_LinkedFiles(m_app); if (linkedFilesForm.ShowDialog() == DialogResult.OK) { var assignForm = new Form_Assigner(m_app) { WorksetDictionary = linkedFilesForm.WorksetDictionary, IntegratedMassList = linkedFilesForm.IntegratedMassList, LinkedMassDictionary = linkedFilesForm.LinkedMassDictionary, ElementDictionary = linkedFilesForm.ElementDictionary, ElementCategories = linkedFilesForm.ElementCategories, MassParameters = linkedFilesForm.MassParameters, SelectedSourceType = linkedFilesForm.SelectedSourceType, ParameterMaps = linkedFilesForm.ParameterMaps }; linkedFilesForm.Close(); if (assignForm.ShowDialog() == DialogResult.OK) { assignForm.Close(); } } Log.AppendLog(LogMessageType.INFO, "Ended."); return(Result.Succeeded); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); return(Result.Failed); } }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog( new AddinLog("Smart BCF", commandData.Application.Application.VersionNumber)); AppCommand.thisApp.ShowWindow(commandData.Application); return(Result.Succeeded); } catch (Exception ex) { message = ex.Message; return(Result.Failed); } }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { m_app = commandData.Application; Log.AppendLog(LogMessageType.INFO, "Started."); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("Utilities-Arrowhead", m_app.Application.VersionNumber)); var assignerWindow = new HeadAssignerWindow(m_app); if (assignerWindow.ShowDialog() == true) { assignerWindow.Close(); } Log.AppendLog(LogMessageType.INFO, "Ended."); return(Result.Succeeded); }
Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { try { m_app = commandData.Application; doc = m_app.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("DataEditor", doc)); var settings = new DefaultSettings(m_app); dbExist = settings.DatabaseExist; dbPath = settings.DefaultDBFile; if (dbExist && File.Exists(dbPath)) { if (viewerForm == null || !viewerForm.Visible) { viewerForm = new form_Viewer(m_app, dbPath, false); viewerForm.FormClosed += form_Viwer_FormClosed; viewerForm.Show(); } } else { MessageBox.Show("A linked database does not exist.\n" + settings.DefaultDBFile, "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Information); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); return(Result.Failed); } }
public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { Log.AppendLog(LogMessageType.INFO, "Started"); try { // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("Beta-SheetManager", commandData.Application.Application.VersionNumber)); m_app = commandData.Application; AppCommand.thisApp.ShowWindow(m_app); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { m_app = commandData.Application; Log.AppendLog(LogMessageType.INFO, "Started."); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog( new AddinLog("ElementFlatter", m_app.Application.VersionNumber)); var viewModel = new CommandViewModel(m_app); var cmdWindow = new CommandWindow { DataContext = viewModel }; cmdWindow.ShowDialog(); Log.AppendLog(LogMessageType.INFO, "Ended."); return(Result.Succeeded); }
private void button5_Click(object sender, EventArgs e) { word.Application wordApp = new word.Application(); COMAddIns addins = wordApp.COMAddIns; foreach (COMAddIn addin in addins) { if (addin.Description.Equals("Pdw")) { AddinUtilities util = (AddinUtilities)addin.Object; string result = util.DoSomething("from1"); MessageBox.Show(result); Object pdwApp = addin.Object; object[] invokeArgs = { "name in form1" }; object retVal = pdwApp.GetType().InvokeMember("DoSomething", System.Reflection.BindingFlags.InvokeMethod, null, pdwApp, invokeArgs); MessageBox.Show(retVal.ToString()); } } }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { m_app = commandData.Application; m_doc = m_app.ActiveUIDocument.Document; uidoc = m_app.ActiveUIDocument; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("Utilities-RoomElevation", commandData.Application.Application.VersionNumber)); var elevationWindow = new ElevationWindow(m_app); if (elevationWindow.CheckPrerequisites()) { if (elevationWindow.DisplayUI()) { var dr = elevationWindow.ShowDialog(); if (dr == true) { var toolSettings = elevationWindow.ToolSettings; var linkedInstances = elevationWindow.LinkedDocuments; var roomDictionary = elevationWindow.RoomDictionary; elevationWindow.Close(); //pick elements mode var elevationCreator = new ElevationByPickElements(m_app, toolSettings, linkedInstances, roomDictionary); elevationCreator.StartSelection(); } } } } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { m_app = commandData.Application; m_doc = m_app.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("Utilities-WorksetView", commandData.Application.Application.VersionNumber)); var mainWindow = new ViewCreatorWindow(m_app); var dialog = mainWindow.ShowDialog(); if (dialog != null && (bool)dialog) { mainWindow.Close(); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { Log.AppendLog(LogMessageType.INFO, "Started"); try { // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog( new AddinLog("HOK Navigator", commandData.Application.Application.VersionNumber)); var helpForm = new HelpForm(); helpForm.ShowDialog(); } catch (Exception e) { Log.AppendLog(LogMessageType.EXCEPTION, e.Message); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { m_app = commandData.Application; m_doc = m_app.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("Utilities-XYZLocator", commandData.Application.Application.VersionNumber)); var found = FindLocatorFamily(); if (found) { var mainWindow = new MainWindow(m_app); if (mainWindow.ShowDialog() == true) { var xyzLocation = mainWindow.Location; var assigned = AssignParameter(xyzLocation); if (assigned) { MessageBox.Show("Parameter values for XYZ locaiton have been assigned.", "XYZ Locator", MessageBoxButton.OK, MessageBoxImage.Information); } } } else { MessageBox.Show("Please load a Generic Model family, " + locationFamilyName, "Family Not Found", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { m_app = commandData.Application; m_doc = m_app.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("Utilities-RoomUpdater", commandData.Application.Application.VersionNumber)); var roomUpdater = new RoomUpdaterWindow(m_app); if (roomUpdater.ShowDialog() == true) { } var categoryList = new List <Category>(); foreach (Category category in m_doc.Settings.Categories) { if (!category.HasMaterialQuantities) { continue; } if (category.CategoryType == CategoryType.Model) { categoryList.Add(category); } } } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { Log.AppendLog(LogMessageType.INFO, "Started"); try { // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("Citrix-CopyFiles", commandData.Application.Application.VersionNumber)); Process.Start(@"C:\HOK\FileCopyTool\CitrixCopyBdrive.exe"); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { m_app = commandData.Application; m_doc = m_app.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("Utilities-LevelManager", commandData.Application.Application.VersionNumber)); var managerForm = new LevelManagerForm(m_app); managerForm.ShowDialog(); Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); return(Result.Cancelled); } }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { m_app = commandData.Application; m_doc = m_app.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("Utilities-FinishCreator", commandData.Application.Application.VersionNumber)); var uidoc = m_app.ActiveUIDocument; var title = "Finish Creator v." + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; var mainDialog = new TaskDialog(title) { MainInstruction = "Select a Finish Type", MainContent = "Start selecting rooms to create floors or ceilings and click Finish on the options bar.", AllowCancellation = true }; mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Floors"); mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Floors from Linked Rooms"); mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink3, "Ceilings"); mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink4, "Ceilings from Linked Rooms"); var tResult = mainDialog.Show(); if (TaskDialogResult.CommandLink1 == tResult) { //floor var selectedElement = uidoc.Selection.PickObjects(ObjectType.Element, new RoomElementFilter(), "Select rooms to create floors with their room boundary. Click Finish on the options bar when you're done selecting rooms."); var selectedRooms = new List <Element>(); foreach (var reference in selectedElement) { var element = m_doc.GetElement(reference.ElementId); if (null != element) { selectedRooms.Add(element); } } if (selectedRooms.Any()) { var floorCreator = new FloorCreator(m_app, selectedRooms); floorCreator.CreateFloorFromRoom(); } } else if (TaskDialogResult.CommandLink2 == tResult) { //floor from linked element var selectedElement = uidoc.Selection.PickObjects(ObjectType.LinkedElement, "Select linked rooms to create floors with their room boundary. Click Finish on the options bar when you're done selecting rooms."); var selectedRooms = new List <LinkedRoomProperties>(); foreach (var reference in selectedElement) { var linkInstance = m_doc.GetElement(reference.ElementId) as RevitLinkInstance; // Link Instance if (null != linkInstance) { var linkedRoom = new LinkedRoomProperties(linkInstance, reference.LinkedElementId); if (null != linkedRoom.LinkedRoom) { selectedRooms.Add(linkedRoom); } } } if (selectedRooms.Count > 0) { var floorCreator = new FloorCreator(m_app, selectedRooms); floorCreator.CreateFloorFromLink(); } } else if (TaskDialogResult.CommandLink3 == tResult) { //ceiling var selectedElement = uidoc.Selection.PickObjects( ObjectType.Element, new RoomElementFilter(), "Select rooms to create ceilings with their room boundary. Click Finish on the options bar when you're done selecting rooms."); var selectedRooms = new List <Room>(); foreach (var reference in selectedElement) { var room = m_doc.GetElement(reference.ElementId) as Room; if (null != room) { selectedRooms.Add(room); } } if (selectedRooms.Any()) { var ceilingCreator = new CeilingCreator(m_app, selectedRooms); if (ceilingCreator.CreateCeilingFromRoom()) { var ceilingCount = 0; foreach (var roomid in ceilingCreator.CreatedCeilings.Keys) { ceilingCount += ceilingCreator.CreatedCeilings[roomid].Count; } MessageBox.Show(ceilingCount + " ceiling finishes are created in " + ceilingCreator.CreatedCeilings.Count + " rooms.", "Ceiling Finishes Created", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else if (TaskDialogResult.CommandLink4 == tResult) { //ceiling var selectedElement = uidoc.Selection.PickObjects(ObjectType.LinkedElement, "Select linked rooms to create ceilings with their room boundary. Click Finish on the options bar when you're done selecting rooms."); var selectedRooms = new List <LinkedRoomProperties>(); foreach (var reference in selectedElement) { var linkInstance = m_doc.GetElement(reference.ElementId) as RevitLinkInstance; // Link Instance if (null != linkInstance) { var linkedRoom = new LinkedRoomProperties(linkInstance, reference.LinkedElementId); if (null != linkedRoom.LinkedRoom) { selectedRooms.Add(linkedRoom); } } } if (selectedRooms.Count > 0) { var ceilingCreator = new CeilingCreator(m_app, selectedRooms); if (ceilingCreator.CreateCeilingFromLink()) { var ceilingCount = 0; foreach (var roomid in ceilingCreator.CreatedCeilings.Keys) { ceilingCount += ceilingCreator.CreatedCeilings[roomid].Count; } MessageBox.Show(ceilingCount + " ceiling finishes are created in " + ceilingCreator.CreatedCeilings.Count + " rooms.", "Ceiling Finishes Created", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); return(Result.Failed); } }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { var uiApp = commandData.Application; var doc = uiApp.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); try { // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog( new AddinLog("MissionControl-PublishFamilyData", commandData.Application.Application.VersionNumber)); var pathName = doc.PathName; if (string.IsNullOrEmpty(pathName)) { Log.AppendLog(LogMessageType.ERROR, "Path is Empty. File was not saved yet."); var dialog = new FamilyMonitorView { DataContext = new FamilyMonitorViewModel(null, "...establish a connection to Mission Control for unsaved files."), CancelButton = { Visibility = Visibility.Collapsed } }; dialog.ShowDialog(); return(Result.Failed); } var centralPath = FileInfoUtil.GetCentralFilePath(doc); if (string.IsNullOrEmpty(centralPath)) { Log.AppendLog(LogMessageType.ERROR, "Could not get Central Path."); var dialog = new FamilyMonitorView { DataContext = new FamilyMonitorViewModel(null, "...get a Central File Path. Only Workshared projects can be added to Mission Control."), CancelButton = { Visibility = Visibility.Collapsed } }; dialog.ShowDialog(); return(Result.Failed); } if (!MissionControlSetup.Projects.ContainsKey(centralPath) || !MissionControlSetup.Configurations.ContainsKey(centralPath) || !MissionControlSetup.FamilyData.ContainsKey(centralPath)) { Log.AppendLog(LogMessageType.ERROR, "No Config Found."); var dialog = new FamilyMonitorView { DataContext = new FamilyMonitorViewModel(null, "...find your project in Mission Control database. Please make sure that it was added."), CancelButton = { Visibility = Visibility.Collapsed } }; dialog.ShowDialog(); return(Result.Failed); } uiApp.Application.FailuresProcessing += FailureProcessing; var familiesId = MissionControlSetup.FamilyData[centralPath].Id; var model = new FamilyMonitorModel(doc, MissionControlSetup.Configurations[centralPath], MissionControlSetup.Projects[centralPath], familiesId, centralPath); var viewModel = new FamilyMonitorViewModel(model, "...make this any faster. Hang in there!") { ExecuteFamilyPublish = true }; var view = new FamilyMonitorView { DataContext = viewModel, CloseButton = { Visibility = Visibility.Collapsed } }; var unused = new WindowInteropHelper(view) { Owner = Process.GetCurrentProcess().MainWindowHandle }; view.ShowDialog(); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } uiApp.Application.FailuresProcessing -= FailureProcessing; Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { m_app = commandData.Application; m_doc = m_app.ActiveUIDocument.Document; Log.AppendLog(LogMessageType.INFO, "Started"); // (Konrad) We are gathering information about the addin use. This allows us to // better maintain the most used plug-ins or discontiue the unused ones. AddinUtilities.PublishAddinLog(new AddinLog("Utilities-CeilingHeight", commandData.Application.Application.VersionNumber)); try { var uidoc = m_app.ActiveUIDocument; var room = new FilteredElementCollector(m_doc).OfCategory(BuiltInCategory.OST_Rooms).FirstElement() as Room; var parameterRequirements = new Dictionary <string, ParameterType> { { "Ceiling Height", ParameterType.Length }, { "Secondary Ceiling Heights", ParameterType.Text }, { "Ceiling Plan", ParameterType.Text }, { "Ceiling Type", ParameterType.Text } }; var notFoundParams = new StringBuilder(); foreach (var paramName in parameterRequirements.Keys) { var paramType = parameterRequirements[paramName]; if (!FindParameter(room, paramName, paramType)) { notFoundParams.AppendLine("[" + paramName + " : " + paramType + "] "); } } if (notFoundParams.Length > 0) { var dresult = MessageBox.Show("The following parameters are required in Room elements.\n" + notFoundParams + "\nThe tool will create the parameters in your current shared parameter file. Would you like to proceed?", "Parameters Required", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dresult == DialogResult.Yes) { var dr = MessageBox.Show("Start selecting rooms to create floors and click Finish on the options bar.The windowed area will filter out Room category only.", "Select Rooms", MessageBoxButtons.OK, MessageBoxIcon.Information); if (dr == DialogResult.OK) { var selectedElement = uidoc.Selection.PickObjects(ObjectType.Element, new RoomElementFilter(), "Select rooms to measure the height from floors to ceiling."); var selectedRooms = new List <Element>(); foreach (var reference in selectedElement) { var element = m_doc.GetElement(reference.ElementId); if (null != element) { selectedRooms.Add(element); } } if (selectedRooms.Count > 0) { var util = new CeilingHeightUtil(m_app, selectedRooms); util.MeasureHeight(); } } } } else { var dr = MessageBox.Show("Start selecting rooms to create floors and click Finish on the options bar.The windowed area will filter out Room category only.", "Select Rooms", MessageBoxButtons.OK, MessageBoxIcon.Information); if (dr == DialogResult.OK) { var selectedElement = uidoc.Selection.PickObjects(ObjectType.Element, new RoomElementFilter(), "Select rooms to measure the height from floors to ceiling."); var selectedRooms = new List <Element>(); foreach (var reference in selectedElement) { var element = m_doc.GetElement(reference.ElementId); if (null != element) { selectedRooms.Add(element); } } if (selectedRooms.Count > 0) { var util = new CeilingHeightUtil(m_app, selectedRooms); util.MeasureHeight(); } } } } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); return(Result.Failed); } Log.AppendLog(LogMessageType.INFO, "Ended"); return(Result.Succeeded); }