public static void TransferWallTypeToCurrentDoc(string SourceFilename, Revit.Elements.Element WallElementFromSource) { Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument; Autodesk.Revit.UI.UIApplication uiapp = DocumentManager.Instance.CurrentUIApplication; //TransactionManager.Instance.EnsureInTransaction(doc); //Document WallDoc = uiapp.Application.OpenDocumentFile(SourceFilename); Autodesk.Revit.DB.Element RevEle = ((Revit.Elements.Element)WallElementFromSource).InternalElement; Document WallDoc = RevEle.Document; List <ElementId> SourceElements = new List <ElementId>(); SourceElements.Add(RevEle.Id); //SourceElements.Add(RevEle.GetTypeId()); TransactionManager.Instance.EnsureInTransaction(doc); CopyPasteOptions cpOpt = new CopyPasteOptions(); try { ElementTransformUtils.CopyElements(WallDoc, SourceElements, doc, Transform.Identity, cpOpt); } catch (Exception ex) { throw; } //Close the transaction TransactionManager.Instance.TransactionTaskDone(); }
internal static void GetExtents(Autodesk.Revit.UI.UIApplication uiApp, out int x, out int y) { #if REVIT2016 || REVIT2015 try { x = uiApp.DrawingAreaExtents.Left; y = uiApp.DrawingAreaExtents.Top; } catch { x = 10; y = 10; } #else //2017+ try { x = uiApp.DrawingAreaExtents.Left; y = uiApp.DrawingAreaExtents.Top; } catch { x = 10; y = 10; } #endif }
public static List <Revit.Elements.Element> FindAllOfCategoryInFile(string SourceFilename, Revit.Elements.Category DynCat) { Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument; Autodesk.Revit.UI.UIApplication uiapp = DocumentManager.Instance.CurrentUIApplication; //TransactionManager.Instance.EnsureInTransaction(doc); Document WallDoc = uiapp.Application.OpenDocumentFile(SourceFilename); Autodesk.Revit.DB.Category FoundCat = GetRevitCategory(DynCat); BuiltInCategory BIcat = (BuiltInCategory)DynCat.Id; var Elements = new FilteredElementCollector(WallDoc) .OfCategory(BIcat); List <Revit.Elements.Element> AllElements = new List <Revit.Elements.Element>(); foreach (Autodesk.Revit.DB.Element TempEle in Elements) { Revit.Elements.Element WrappedEle = TempEle.ToDSType(false); AllElements.Add(WrappedEle); } return(AllElements); }
TestUi(Autodesk.Revit.UI.UIApplication app) : base(app) { //m_testFuncs.Add(new RevitLookupTestFuncInfo("Add Menu", "Add a menu to the menubar", "UI", new RevitLookupTestFuncInfo.TestFunc(AddMenu), RevitLookupTestFuncInfo.TestType.Modify)); //m_testFuncs.Add(new RevitLookupTestFuncInfo("Add Toolbar", "Add a toolbar item", "UI", new RevitLookupTestFuncInfo.TestFunc(AddToolbar), RevitLookupTestFuncInfo.TestType.Modify)); m_testFuncs.Add(new RevitLookupTestFuncInfo("Select Element", "Select a single element", "UI", new RevitLookupTestFuncInfo.TestFunc(SelectElement), RevitLookupTestFuncInfo.TestType.Query)); }
public Elements(Autodesk.Revit.UI.UIApplication app) { InitializeComponent(); m_app = app; InitializeTreeView(); }
public Elements(Autodesk.Revit.UI.UIApplication app) { InitializeComponent(); m_app = app; InitializeTreeView(); }
public Load(Controllers.Controller c, Autodesk.Revit.UI.UIApplication uiApp, string filename = null) { InitializeComponent(); _controller = c; //_controller.View = this; _uiApp = uiApp; //register for idling callback _uiApp.Idling += _uiApp_Idling; _action = ActionEnum.None; btn_Generate.Enabled = false; cbColorBy.Items.Add("Diameter"); cbColorBy.Items.Add("Airflow"); cbColorBy.SelectedIndex = 0; try { if (filename != null) { loadResults(filename); } } catch (Exception ex) { MessageBox.Show("Loading Issue: " + ex.GetType().Name + ": " + ex.Message); } cartesianChart1.DataClick += CartesianChart1_DataClick; }
//public TypeSelectorForm( Autodesk.Revit.UI.UIApplication revitApp, ElementSet elemSet ) // 2015, jeremy public TypeSelectorForm(Autodesk.Revit.UI.UIApplication revitApp, ICollection <ElementId> elemSet) // 2016, jeremy { m_app = revitApp; m_symbolSet = new List <Element>(); InitializeComponent(); CommonInit(elemSet); }
private Document UpdateOpenedProject(Autodesk.Revit.UI.UIApplication app) { DocumentSet docSet = app.Application.Documents; Document activeDocument = app.ActiveUIDocument.Document; return(activeDocument); }
// 2016, jeremy //public TypeSelectorForm( Autodesk.Revit.UI.UIApplication revitApp, ElementSet elemSet ) // 2015, jeremy public TypeSelectorForm( Autodesk.Revit.UI.UIApplication revitApp, ICollection<ElementId> elemSet ) { m_app = revitApp; m_symbolSet = new List<Element>(); InitializeComponent(); CommonInit( elemSet ); }
/// <summary> /// If run from Revit, returns Revit version /// </summary> /// <returns></returns> internal static string GetRevitData() { Autodesk.Revit.DB.Document doc = RevitServices.Persistence.DocumentManager.Instance.CurrentDBDocument; Autodesk.Revit.UI.UIApplication uiapp = RevitServices.Persistence.DocumentManager.Instance.CurrentUIApplication; Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; return String.Format("Revit Build: {0}", app.SubVersionNumber); }
TypeSelectorForm(Autodesk.Revit.UI.UIApplication revitApp, ElementSet elemSet) { m_app = revitApp; m_symbolSet = new List <Element>(); InitializeComponent(); CommonInit(elemSet); }
public static RevitDoc Open(string modelPath, [DefaultArgument("true")] bool reset) { Autodesk.Revit.UI.UIApplication uiapp = DocumentManager.Instance.CurrentUIApplication; Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; RevitDoc doc = app.OpenDocumentFile(modelPath); return(doc); }
///<summary> /// Implement this method as an external command for Revit. /// </summary> /// <param name="commandData">An object that is passed to the external application /// which contains data related to the command, /// such as the application object and active view.</param> /// <param name="message">A message that can be set by the external application /// which will be displayed if a failure or cancellation is returned by /// the external command.</param> /// <param name="elements">A set of elements to which the external application /// can add elements that are to be highlighted in case of failure or cancellation.</param> /// <returns>Return the status of the external command. /// A result of Succeeded means that the API external method functioned as expected. /// Cancelled can be used to signify that the user cancelled the external operation /// at some point. Failure should be returned if the application is unable to proceed with /// the operation.</returns> public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { Autodesk.Revit.UI.UIApplication revit = commandData.Application; ElementSet collection = revit.ActiveUIDocument.Selection.Elements; // check user selection if (collection.Size < 1) { message = "Please select object(s) before delete."; return(Autodesk.Revit.UI.Result.Cancelled); } bool error = true; try { error = true; // delete selection IEnumerator e = collection.GetEnumerator(); bool MoreValue = e.MoveNext(); while (MoreValue) { Element component = e.Current as Element; revit.ActiveUIDocument.Document.Delete(component); MoreValue = e.MoveNext(); } error = false; } catch { // if revit threw an exception, try to catch it foreach (Element c in collection) { elements.Insert(c); } message = "object(s) can't be deleted."; return(Autodesk.Revit.UI.Result.Failed); } finally { // if revit threw an exception, display error and return failed if (error) { MessageBox.Show("Delete failed."); } } return(Autodesk.Revit.UI.Result.Succeeded); }
public LifeSafetyResults(Autodesk.Revit.UI.UIApplication uiApp, Controller c) { InitializeComponent(); _controller = c; _controller.View = this; // set the view. _uiApp = uiApp; // register for idling callback. _uiApp.Idling += _uiApp_Idling; _action = ActionEnum.Run; }
/// <summary> /// Constructor /// </summary> /// <param name="application"></param> public MainWindow(Autodesk.Revit.UI.UIApplication application) { InitializeComponent(); m_application = application; if (m_application.ActiveUIDocument == null) { Autodesk.Revit.UI.TaskDialog.Show("RP Analysis", "Null Document"); this.Close(); } PopulatePipeTypeList(); PopulateSizeList(); }
/// <summary> /// Constructor. /// </summary> /// <param name="revit">The revit application.</param> public STLExportForm(Autodesk.Revit.UI.UIApplication revit) { InitializeComponent(); m_Revit = revit; // get new data generator m_Generator = new DataGenerator(m_Revit.Application, m_Revit.ActiveUIDocument.Document, m_Revit.ActiveUIDocument.Document.ActiveView); // scan for categories to populate category list m_CategoryList = m_Generator.ScanCategories(true); foreach (Category category in m_CategoryList.Values) { TreeNode treeNode = GetChildNode(category,m_Revit.ActiveUIDocument.Document.ActiveView); if (treeNode != null) tvCategories.Nodes.Add(treeNode); } string unitName = "Use Internal: Feet"; m_DisplayUnits.Add(unitName, DisplayUnitType.DUT_UNDEFINED); int selectedIndex = comboBox_DUT.Items.Add(unitName); if (m_SelectedDUT == DisplayUnitType.DUT_UNDEFINED) comboBox_DUT.SelectedIndex = selectedIndex; Units currentUnits = m_Revit.ActiveUIDocument.Document.GetUnits(); DisplayUnitType currentDut = currentUnits.GetFormatOptions(UnitType.UT_Length).DisplayUnits; unitName = "Use Current: " + LabelUtils.GetLabelFor(currentDut); m_DisplayUnits.Add(unitName, currentDut); selectedIndex = comboBox_DUT.Items.Add(unitName); if (m_SelectedDUT == currentDut) comboBox_DUT.SelectedIndex = selectedIndex; foreach (DisplayUnitType dut in UnitUtils.GetValidDisplayUnits(UnitType.UT_Length)) { if (currentDut == dut) continue; unitName = LabelUtils.GetLabelFor(dut); m_DisplayUnits.Add(unitName, dut); selectedIndex = comboBox_DUT.Items.Add(unitName); if (m_SelectedDUT == dut) comboBox_DUT.SelectedIndex = selectedIndex; } // initialize the UI differently for Families if (revit.ActiveUIDocument.Document.IsFamilyDocument) { cbIncludeLinked.Enabled = false; tvCategories.Enabled = false; btnCheckAll.Enabled = false; btnCheckNone.Enabled = false; } }
/// <summary> /// Construction of the main export dialog. /// </summary> /// <param name="app">The UIApplication that contains a list of all documents.</param> /// <param name="configurationsMap">The configurations to show in the dialog.</param> /// <param name="selectedConfigName">The current selected configuration name.</param> public IFCExport(Autodesk.Revit.UI.UIApplication app, IFCExportConfigurationsMap configurationsMap, String selectedConfigName) { m_configMap = configurationsMap; InitializeComponent(); RestorePreviousWindow(); UpdateCurrentSelectedSetupCombo(selectedConfigName); UpdateOpenedProjectsListView(app); Title = "IFC Export (" + IFCUISettings.GetAssemblyVersion() + ")"; }
private void GetDocumentPath(Autodesk.Revit.UI.UIApplication uiapp) { try { currentDocumentPath = uiapp.ActiveUIDocument.Document.PathName; } finally { lock (_locker) { Monitor.Pulse(_locker); } } }
public static RevitDoc DocumentFromPath(string filePath) { Autodesk.Revit.UI.UIApplication uiapp = DocumentManager.Instance.CurrentUIApplication; Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; RevitDB.DocumentSet docSet = app.Documents; foreach (RevitDoc doc in docSet) { if (doc.PathName == filePath) { return(doc); } } return(null); }
private void UpdateOpenedProjectsListView(Autodesk.Revit.UI.UIApplication app) { DocumentSet docSet = app.Application.Documents; Document activeDocument = app.ActiveUIDocument.Document; List <CheckBox> checkBoxes = new List <CheckBox>(); int exportDocumentCount = 0; OrderedDocuments = null; foreach (Document doc in docSet) { if (CanExportDocument(doc)) { // Count the number of Documents which can be exported exportDocumentCount++; } } foreach (Document doc in docSet) { if (CanExportDocument(doc)) { CheckBox cb = createCheckBoxForDocument(doc, OrderedDocuments.Count); // Add the active document as the top item. if (doc.Equals(activeDocument)) { // This should only be hit once cb.IsChecked = true; checkBoxes.Insert(0, cb); if (exportDocumentCount == 1) { // If a single project is to be exported, make it read only cb.IsEnabled = false; } OrderedDocuments.Insert(0, doc); } else { checkBoxes.Add(cb); OrderedDocuments.Add(doc); } } } this.listViewDocuments.ItemsSource = checkBoxes; }
public void Show() { if (manager.CurrentCandidate != null) { var uiapp = new Autodesk.Revit.UI.UIApplication(manager.Document.Application); Autodesk.Revit.DB.Element e = manager.Document.GetElement(manager.CurrentCandidate.ParentElementId); if (e is Autodesk.Revit.DB.View) { uiapp.ActiveUIDocument.ActiveView = (Autodesk.Revit.DB.View)e; } else { uiapp.ActiveUIDocument.ShowElements(e.Id); } } }
public static RevitDoc OpenWithOptions(string modelPath, [DefaultArgument("Synthetic.Revit.WorksetConfigurationOpenAll()")] RevitDB.WorksetConfiguration worksetConfiguration, [DefaultArgument("false")] bool audit, [DefaultArgument("true")] bool reset) { Autodesk.Revit.UI.UIApplication uiapp = DocumentManager.Instance.CurrentUIApplication; Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; RevitDoc doc = null; RevitDB.ModelPath path = RevitDB.ModelPathUtils.ConvertUserVisiblePathToModelPath(modelPath); RevitDB.OpenOptions openOptions = new RevitDB.OpenOptions(); openOptions.Audit = audit; openOptions.SetOpenWorksetsConfiguration(worksetConfiguration); doc = app.OpenDocumentFile(path, openOptions); return(doc); }
public static RevitDoc UnwrapDocument(DynamoDoc document) { string filePath = document.FilePath; Autodesk.Revit.UI.UIApplication uiapp = DocumentManager.Instance.CurrentUIApplication; Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; RevitDB.DocumentSet docSet = app.Documents; List <RevitDoc> docs = new List <RevitDoc>(); foreach (RevitDoc doc in docSet) { if (filePath == doc.PathName) { return(doc); } } return(null); }
/// <summary> /// Construction of the main export dialog. /// </summary> /// <param name="app">The UIApplication that contains a list of all documents.</param> /// <param name="configurationsMap">The configurations to show in the dialog.</param> /// <param name="selectedConfigName">The current selected configuration name.</param> public IFCExport(Autodesk.Revit.UI.UIApplication app, IFCExportConfigurationsMap configurationsMap, String selectedConfigName) { m_configMap = configurationsMap; MakeCurrentRevitWindow(this); InitializeComponent(); RestorePreviousWindow(); UpdateCurrentSelectedSetupCombo(selectedConfigName); UpdateOpenedProjectsListView(app); Title = Properties.Resources.ExportIFC; TheDocument = UpdateOpenedProject(app); int docToExport = GetDocumentExportCount(); updateFileName(); }
List<SketchPlane> m_sketchArray; // Store the SketchPlane references #endregion Fields #region Constructors /// <summary> /// The default constructor /// </summary> /// <param name="revit">The reference of the application in revit</param> public ModelLines(Autodesk.Revit.UI.UIApplication revit) { // Store the reference of the application for further use. m_revit = revit; // Get the create references m_createApp = m_revit.Application.Create; // Creation.Application m_createDoc = m_revit.ActiveUIDocument.Document.Create;// Creation.Document // Construct all the ModelCurveArray instances for model lines m_lineArray = new ModelCurveArray(); m_arcArray = new ModelCurveArray(); m_ellipseArray = new ModelCurveArray(); m_hermiteArray = new ModelCurveArray(); m_nurbArray = new ModelCurveArray(); // Construct the sketch plane list data m_sketchArray = new List<SketchPlane>(); // Construct the information list data m_informationMap = new List<ModelCurveCounter>(); }
public SDKTestFuncs(Autodesk.Revit.UI.UIApplication app) : base(app) { m_testFuncs.Add(new RevitLookupTestFuncInfo("Generate Sheet", "Generate a new sheet with a set of selected views", "SDK Samples", new RevitLookupTestFuncInfo.TestFunc(GenerateSheet), RevitLookupTestFuncInfo.TestType.Create)); m_testFuncs.Add(new RevitLookupTestFuncInfo("Analytical Support Data", "Show Analytical data for selected objects (Must be using Revit Structure)", "SDK Samples", new RevitLookupTestFuncInfo.TestFunc(AnalyticalSupportData), RevitLookupTestFuncInfo.TestType.Query)); m_testFuncs.Add(new RevitLookupTestFuncInfo("Create Shared Parameters", "Create new shared parameters", "SDK Samples", new RevitLookupTestFuncInfo.TestFunc(CreateSharedParams), RevitLookupTestFuncInfo.TestType.Create)); m_testFuncs.Add(new RevitLookupTestFuncInfo("Type Selector", "Change the Type of an Element", "SDK Samples", new RevitLookupTestFuncInfo.TestFunc(TypeSelector), RevitLookupTestFuncInfo.TestType.Modify)); m_testFuncs.Add(new RevitLookupTestFuncInfo("Move Linear Bound Element", "Move a single Element to a new location", "SDK Samples", new RevitLookupTestFuncInfo.TestFunc(MoveLinearBound), RevitLookupTestFuncInfo.TestType.Modify)); m_testFuncs.Add(new RevitLookupTestFuncInfo("Structural Sample", "Place a set of columns at equal intervals on wall's", "SDK Samples", new RevitLookupTestFuncInfo.TestFunc(StructSample), RevitLookupTestFuncInfo.TestType.Create)); m_testFuncs.Add(new RevitLookupTestFuncInfo("Level Properties", "Add, remove and modify levels", "SDK Samples", new RevitLookupTestFuncInfo.TestFunc(LevelProps), RevitLookupTestFuncInfo.TestType.Query)); m_testFuncs.Add(new RevitLookupTestFuncInfo("Fire Rating - Create Shared Parameter", "Create the \"Fire Rating\" Parameter", "SDK Samples", new RevitLookupTestFuncInfo.TestFunc(FireRatingSharedParam), RevitLookupTestFuncInfo.TestType.Create)); // SDK Samples not implemented: // DeleteObject (See TestDocument.Delete) // DesignOptionsReader (use Snoop) // RevitCommands (use Snoop) // BrowseBindings (use Snoop) // ParameterUtils (use Snoop) }
/// <summary> /// The default constructor /// </summary> /// <param name="revit">The reference of the application in revit</param> public ModelLines(Autodesk.Revit.UI.UIApplication revit) { // Store the reference of the application for further use. m_revit = revit; // Get the create references m_createApp = m_revit.Application.Create; // Creation.Application m_createDoc = m_revit.ActiveUIDocument.Document.Create; // Creation.Document // Construct all the ModelCurveArray instances for model lines m_lineArray = new ModelCurveArray(); m_arcArray = new ModelCurveArray(); m_ellipseArray = new ModelCurveArray(); m_hermiteArray = new ModelCurveArray(); m_nurbArray = new ModelCurveArray(); // Construct the sketch plane list data m_sketchArray = new List <SketchPlane>(); // Construct the information list data m_informationMap = new List <ModelCurveCounter>(); }
/// <summary> /// Construction of the main export dialog. /// </summary> /// <param name="app">The UIApplication that contains a list of all documents.</param> /// <param name="configurationsMap">The configurations to show in the dialog.</param> /// <param name="selectedConfigName">The current selected configuration name.</param> public IFCExport(Autodesk.Revit.UI.UIApplication app, IFCExportConfigurationsMap configurationsMap, String selectedConfigName) { m_configMap = configurationsMap; InitializeComponent(); RestorePreviousWindow(); currentSelectedSetup.SelectionChanged -= currentSelectedSetup_SelectionChanged; UpdateCurrentSelectedSetupCombo(selectedConfigName); UpdateOpenedProjectsListView(app); Title = Properties.Resources.ExportIFC; versionDescription.Text = IFCUISettings.GetAssemblyVersionForUI(); TheDocument = UpdateOpenedProject(app); int docToExport = GetDocumentExportCount(); updateFileName(); }
public static IDictionary GetAllOpen() { Autodesk.Revit.UI.UIApplication uiapp = DocumentManager.Instance.CurrentUIApplication; Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; RevitDB.DocumentSet docSet = app.Documents; List <RevitDoc> docs = new List <RevitDoc>(); List <string> names = new List <string>(); List <bool> family = new List <bool>(); foreach (RevitDoc doc in docSet) { docs.Add(doc); names.Add(doc.Title); family.Add(doc.IsFamilyDocument); } return(new Dictionary <string, object> { { "Documents", docs }, { "Titles", names }, { "Is a family", family } }); }
public GraphicsStreamRevit(Autodesk.Revit.UI.UIApplication app) : base(app) { SetSketchPlane(); }
public StructSample(Autodesk.Revit.UI.UIApplication app, ElementSet ss) { m_app = app; m_ss = ss; }
public Create(Autodesk.Revit.UI.UIApplication app) { m_app = app; }
public Create(Autodesk.Revit.UI.UIApplication app) { m_app = app; }
public StructSample( Autodesk.Revit.UI.UIApplication app, ICollection<ElementId> ids ) { m_app = app; //m_ss = ss; m_ids = ids; }
public RevitLookupTestFuncs( Autodesk.Revit.UI.UIApplication app ) { m_revitApp = app; }
/// <summary> /// /// </summary> /// <param name="app"></param> public LevelsCommand(Autodesk.Revit.UI.UIApplication app) { m_app = app; }
/// <summary> /// /// </summary> /// <param name="app"></param> public LevelsCommand(Autodesk.Revit.UI.UIApplication app) { m_app = app; }
TestApplication(Autodesk.Revit.UI.UIApplication app) : base(app) { m_testFuncs.Add(new RevitLookupTestFuncInfo("Batch Printing", "Prints all selected files in a batch process", typeof(Autodesk.Revit.ApplicationServices.Application), new RevitLookupTestFuncInfo.TestFunc(BatchPrinting), RevitLookupTestFuncInfo.TestType.Other)); m_testFuncs.Add(new RevitLookupTestFuncInfo("Journal Playback", "Plays back a selected journal", typeof(Autodesk.Revit.ApplicationServices.Application), new RevitLookupTestFuncInfo.TestFunc(JournalPlayBack), RevitLookupTestFuncInfo.TestType.Other)); }
public SharedParam(Autodesk.Revit.UI.UIApplication app) { m_app = app; }