public void Execute(Autodesk.Revit.DB.UpdaterData data) { Document doc = data.GetDocument(); try { Action <Document, ElementId> setElev = (d, id) => { FamilyInstance fi = d.GetElement(id) as FamilyInstance; SetBottomElev(fi); }; foreach (ElementId addedElemId in data.GetAddedElementIds()) { setElev(doc, addedElemId); } foreach (ElementId changedElemId in data.GetModifiedElementIds()) { setElev(doc, changedElemId); } } catch (Exception ex) { Autodesk.Revit.UI.TaskDialog.Show("Exception", (string.Format ("{0}\n{1}", ex.Message, ex.StackTrace))); } }
/// <summary> /// Set Geometry Curve /// </summary> public void SetCurve(Autodesk.DesignScript.Geometry.Curve curve) { Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument; TransactionManager.Instance.EnsureInTransaction(document); this.InternalCurveElement.SetGeometryCurve(curve.ToRevitType(), true); TransactionManager.Instance.TransactionTaskDone(); }
/// <summary> /// Init a new detail curve from curve /// </summary> /// <param name="view"></param> /// <param name="curve"></param> private void Init(Autodesk.Revit.DB.View view, Autodesk.Revit.DB.Curve curve) { // Open Transaction and get document Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument; TransactionManager.Instance.EnsureInTransaction(document); // Get exsiting element var element = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.DetailCurve>(document); if (element == null) { if (document.IsFamilyDocument) { element = document.FamilyCreate.NewDetailCurve(view, curve); } else { element = document.Create.NewDetailCurve(view, curve); } } else { element.SetGeometryCurve(curve, true); } InternalSetCurveElement(element); // Set transaction task done & element for trace TransactionManager.Instance.TransactionTaskDone(); ElementBinder.SetElementForTrace(this.InternalElement); }
/// <summary> /// Symbol Selection Form Class Instance and Initializer /// </summary> /// <param name="exEvent">External event which implemented when raise calling</param> /// <param name="handler">Revit API Externl Event Handler</param> /// <param name="m_doc">Active Revit Document</param> public SymbolSelectionForm(ExternalEvent exEvent, CreateBeamExternalEventHandler handler, Document m_doc) { InitializeComponent(); m_Handler = handler; m_ExEvent = exEvent; doc = m_doc; }
private static IList <Autodesk.Revit.DB.ViewSheetSet> GetViewSheetSet(Document doc) { return(new Collector(doc) .OfClass(typeof(Autodesk.Revit.DB.ViewSheetSet)) .Cast <Autodesk.Revit.DB.ViewSheetSet>() .ToList()); }
public static Dictionary <string, object> ByDirection(global::Revit.Elements.Wall hostingElement) { //obtains the current document for later use Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument; List <global::Revit.Elements.Mullion> horizontal = new List <Mullion>(); List <global::Revit.Elements.Mullion> vertical = new List <Mullion>(); var mullions = Mullion.ByElement(hostingElement); foreach (var mullion in mullions) { if (mullion.LocationCurve.StartPoint.Z == mullion.LocationCurve.EndPoint.Z) { horizontal.Add(mullion); } else { vertical.Add(mullion); } } var orderedHorizontal = horizontal.OrderBy(m => m.LocationCurve.StartPoint.Z).ThenBy(m => m.LocationCurve.StartPoint.X); var orderedVertical = vertical.OrderBy(m => m.LocationCurve.StartPoint.X).ThenBy(m => m.LocationCurve.StartPoint.Z); var outInfo = new Dictionary <string, object> { { "horizontal", orderedHorizontal }, { "vertical", orderedVertical } }; return(outInfo); }
public WorksheetSelectForm(List <WorksheetObject> objs, ManageExcelLinksForm parent, Autodesk.Revit.DB.Document doc) { _objs = objs; formParent = parent; _doc = doc; InitializeComponent(); int counter = 0; foreach (WorksheetObject wo in _objs) { if (wo.Image == null) { counter++; } } if (counter == _objs.Count) { this.Height = 160; previewImage.Visibility = System.Windows.Visibility.Hidden; } linkCheckBox.IsChecked = true; linkCheckBox.IsEnabled = false; wsComboBox.ItemsSource = _objs; wsComboBox.DisplayMemberPath = "Name"; wsComboBox.SelectedIndex = 0; }
public FrontForm(Autodesk.Revit.UI.UIDocument document, IList <Autodesk.Revit.DB.ViewSheet> sheets) { uidoc = document; doc = uidoc.Document; viewsheets = sheets; InitializeComponent(); }
private string suggestModelName() { Autodesk.Revit.DB.Document doc = cbSelectedModel.SelectedItem as Autodesk.Revit.DB.Document; if (doc != null) { string filename = Path.GetFileNameWithoutExtension(doc.PathName); if (doc.IsWorkshared && (!doc.IsDetached)) { try { var mp = doc.GetWorksharingCentralModelPath(); string centralPath = Autodesk.Revit.DB.ModelPathUtils.ConvertModelPathToUserVisiblePath(mp); if ((mp.ServerPath == false) && System.IO.Path.IsPathRooted(centralPath)) { string folder = Path.GetDirectoryName(centralPath); string baseName = Path.GetFileNameWithoutExtension(centralPath); filename = Path.Combine(folder, "Snapshots", baseName + "_" + DateTime.Now.ToString("yyyyMMdd_hhmm") + ".sdb"); } } catch { } } else { filename = Path.Combine(Path.GetDirectoryName(doc.PathName), filename + "_" + DateTime.Now.ToString("yyyyMMdd_hhmm") + ".sdb"); } return(filename); } return(string.Empty); }
Enumerable(string label, IEnumerable val, Autodesk.Revit.DB.Document doc) : base(label) { m_val = val; // iterate over the collection and put them in an ArrayList so we can pass on // to our Form if (m_val != null) { IEnumerator iter = m_val.GetEnumerator(); while (iter.MoveNext()) { var elementId = iter.Current as Autodesk.Revit.DB.ElementId; if (elementId != null && doc != null) { m_objs.Add(doc.GetElement(elementId)); // it's more useful for user to view element rather than element id. } else { m_objs.Add(iter.Current); } } } }
public frmSheetMaker(Autodesk.Revit.DB.Document curDoc) { // The Me.InitializeComponent call is required for Windows Forms designer support. this.InitializeComponent(); // // TODO : Add constructor code after InitializeComponents List <string> curTblocks = null; //get titleblocks in current model and output to combo box curTblocks = mFunctions.getAllTitleblockNames(curDoc); foreach (string tblock in curTblocks) { this.cmbTitleblock.Items.Add(tblock); } //set combo box to first titleblock this.cmbTitleblock.SelectedIndex = 0; //set sheet type to regular sheet this.cmbSheetType.SelectedIndex = 0; //set btnCreateCSV tooltip this.ttCreateCSV.ToolTipTitle = "Create Default CSV File"; }
/// <summary> /// Set Global Parameter Value /// </summary> /// <param name="parameter"></param> /// <param name="value"></param> public static void SetValue(GlobalParameter parameter, object value) { if (!parameter.InternalGlobalParameter.IsReporting) { // get document and open transaction Autodesk.Revit.DB.Document document = Application.Document.Current.InternalDocument; TransactionManager.Instance.EnsureInTransaction(document); if (value == null) { parameter.InternalGlobalParameter.SetValue( new Autodesk.Revit.DB.NullParameterValue()); } else if (value.GetType() == typeof(int)) { parameter.InternalGlobalParameter.SetValue( new Autodesk.Revit.DB.IntegerParameterValue((int)value)); } else if (value.GetType() == typeof(string)) { parameter.InternalGlobalParameter.SetValue( new Autodesk.Revit.DB.StringParameterValue((string)value)); } else if (value.GetType() == typeof(double)) { var valueToSet = (double)value * UnitConverter.DynamoToHostFactor(parameter.InternalGlobalParameter.GetDefinition().UnitType); parameter.InternalGlobalParameter.SetValue( new Autodesk.Revit.DB.DoubleParameterValue(valueToSet)); } TransactionManager.Instance.TransactionTaskDone(); } }
/// <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); }
public MainForm(Autodesk.Revit.DB.Document current) { InitializeComponent(); tabControl1.Appearance = TabAppearance.FlatButtons; tabControl1.ItemSize = new Size(0, 1); tabControl1.SizeMode = TabSizeMode.Fixed; _currentDoc = current; initialRender(); }
/// <summary> /// This will attempt to set the leader elbow position of the tag. /// </summary> /// <param name="tag">The tag to set leader elbow position of.</param> /// <param name="location">The new location for the leader elbow.</param> /// <search> /// Tag, Tag.Location /// </search> public static void SetLeaderElbowPosition(global::Revit.Elements.Tag tag, Point location) { Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument; Autodesk.Revit.DB.IndependentTag internalTag = (Autodesk.Revit.DB.IndependentTag)tag.InternalElement; TransactionManager.Instance.EnsureInTransaction(doc); internalTag.LeaderElbow = location.ToXyz(); TransactionManager.Instance.TransactionTaskDone(); }
public FormSelectCategories(Autodesk.Revit.DB.Document doc, List <MyCategory> categories) { InitializeComponent(); foreach (MyCategory mycat in categories) { checkedListBox1.Items.Add(mycat, CheckState.Checked); } }
public PrintWnd(RvtDocument doc) { InitializeComponent(); IList <ViewSheetSet> viewSheetSets = SheetSelectorCmd.GetViewSheetSets(doc); this.lb_view_sets.ItemsSource = viewSheetSets; }
internal ImportedDWGForm(Autodesk.Revit.UI.UIDocument uidoc, List <ImportedDWG> dwg) { InitializeComponent(); this.uidoc = uidoc; this.doc = uidoc.Document; this.dwgList = dwg; InitializeList(); }
public static List <global::Revit.Elements.Element> UGrids(Autodesk.Revit.DB.CurtainGrid curtainGrid) { Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument; //gets U Grid Ids ICollection <Autodesk.Revit.DB.ElementId> uGridIds = curtainGrid.GetUGridLineIds(); //make new list for U grids List <global::Revit.Elements.Element> uGrids = new List <global::Revit.Elements.Element>(uGridIds.Select(id => doc.GetElement(id).ToDSType(true)).ToArray()); return(uGrids); }
public Apartment(Document doc, string number) { m_doc = doc; m_number = number; m_iRoomId = new List <int>(); m_totalArea = 0; m_totalAreaSansPartitions = 0; m_totalAreaSansWetAreas = 0; m_roomAreas = new List <double>(); }
public void AddDocument(string documentGuid, Document document) { if (Documents.ContainsKey(documentGuid)) { return; } { Documents[documentGuid] = document; } }
public static object DbDocumentToOrchidDocument(Autodesk.Revit.DB.Document document) { //find the orchid assembly var assembly = AppDomain.CurrentDomain.GetAssemblies().First(a => a.FullName.Contains("OrchidRB") && !a.FullName.Contains("customization")); Type type = assembly.GetType("Orchid.RevitProject.Common.Document"); //find the path of the document return(type.InvokeMember("BackgroundOpen", BindingFlags.Default | BindingFlags.InvokeMethod, null, null, new object[] { document.PathName })); }
public ExportSelectionForm(IList <Autodesk.Revit.DB.Document> docs, Autodesk.Revit.DB.Document current) { InitializeComponent(); cbSelectedModel.DataSource = docs.ToArray(); cbSelectedModel.Refresh(); cbSelectedModel.SelectedItem = current; this.Text += " " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; }
public DRInterface(Autodesk.Revit.UI.UIDocument uidoc, Command cmd) { this.uidoc = uidoc; this.doc = uidoc.Document; this.cmd = cmd; InitializeComponent(); InitializeUI(); doorTypes = new List <string>(); }
/// <summary> /// This method does most of the work of the IPerformanceAdviserRule implementation. /// It is called by PerformanceAdviser. /// It examines the element passed to it (which was previously filtered by the filter /// returned by GetElementFilter() (see below)). After checking to make sure that the /// element is an instance, it checks the FacingFlipped property of the element. /// /// If it is flipped, it adds the instance to a list to be used later. /// </summary> /// <param name="document">The active document</param> /// <param name="element">The current element being checked</param> public void ExecuteElementCheck(Autodesk.Revit.DB.Document document, Autodesk.Revit.DB.Element element) { if ((element is Autodesk.Revit.DB.FamilyInstance)) { Autodesk.Revit.DB.FamilyInstance doorCurrent = element as Autodesk.Revit.DB.FamilyInstance; if (doorCurrent.FacingFlipped) { m_FlippedDoors.Add(doorCurrent.Id); } } }
/// <summary> /// Try to found an open <see cref="Autodesk.Revit.UI.UIDocument"/> that is referencing the specified <see cref="Autodesk.Revit.DB.Document"/>. /// </summary> /// <param name="document"></param> /// <param name="uiDocument"></param> /// <returns>true on succes.</returns> public static bool TryGetOpenUIDocument(this Autodesk.Revit.DB.Document document, out Autodesk.Revit.UI.UIDocument uiDocument) { uiDocument = new Autodesk.Revit.UI.UIDocument(document); if (uiDocument.GetOpenUIViews().Count == 0) { uiDocument.Dispose(); uiDocument = default; return(false); } return(true); }
private void ImportAllSelectedParamsToTargetFile(Autodesk.Revit.DB.Document targetDoc) { // --- rebuild the insertlist //todo - put back //foreach (DataGridViewRow oRow in ParentFormParameterJerk. DataGridViewFromFile.SelectedRows) //{ // // If oRow.Selected Then // ClassOneParamAssociation thisParameterData = oRow.DataBoundItem as ClassOneParamAssociation; // thisParameterData.createSharedParameter(ParentFormParameterJerk.CheckBoxDeleteIfExists.Checked, targetDoc); // // End If //} }
public static List <global::Revit.Elements.Element> Members(global::Revit.Elements.Element BeamSystem) { Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument; //convert input beam system to internal version Autodesk.Revit.DB.BeamSystem beamSystemInternal = (Autodesk.Revit.DB.BeamSystem)BeamSystem.InternalElement; //get beam ids from system var beamIdCollection = beamSystemInternal.GetBeamIds(); //create list for the elements and add the beams to that list. List <global::Revit.Elements.Element> members = new List <global::Revit.Elements.Element>(beamIdCollection.Select(id => doc.GetElement(id).ToDSType(true)).ToArray()); return(members); }
/// <summary> /// Does some preliminary work before executing tests on elements. In this case, /// we instantiate a list of FamilyInstances representing all doors that are flipped. /// </summary> /// <param name="document">The document being checked</param> public void InitCheck(Autodesk.Revit.DB.Document document) { if (m_FlippedDoors == null) { m_FlippedDoors = new List <Autodesk.Revit.DB.ElementId>(); } else { m_FlippedDoors.Clear(); } return; }
/// <summary> /// This node will retrieve the room that a tag is tagging. /// </summary> /// <param name="roomTag">The room tag to retrieve elements from.</param> /// <returns name="room">The room that is tagged.</returns> /// <search> /// roomtag, rhythm /// </search> public static List <global::Revit.Elements.Element> TaggedRoom(List <global::Revit.Elements.Element> roomTag) { Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument; //convert room tags to internal representations List <global::Autodesk.Revit.DB.Architecture.RoomTag> internalRoomTagList = new List <global::Autodesk.Revit.DB.Architecture.RoomTag>(roomTag.Select(tag => (Autodesk.Revit.DB.Architecture.RoomTag)tag.InternalElement)); //get the tagged rooms List <global::Revit.Elements.Element> taggedRoomList = new List <global::Revit.Elements.Element>(internalRoomTagList.Select(tag => doc.GetElement(tag.TaggedLocalRoomId).ToDSType(true))); return(taggedRoomList); }
internal Document(Autodesk.Revit.DB.Document currentDBDocument) { InternalDocument = currentDBDocument; }