public static Element ByElement(View view, Element element, string tagMode, string tagOrientation, bool addLeader = false) { if (view == null) { throw new ArgumentNullException(nameof(view)); } if (element == null) { throw new ArgumentNullException(nameof(element)); } if (string.IsNullOrWhiteSpace(tagMode)) { throw new ArgumentNullException(nameof(tagMode)); } if (string.IsNullOrWhiteSpace(tagOrientation)) { throw new ArgumentNullException(nameof(tagOrientation)); } var doc = DocumentManager.Instance.CurrentDBDocument; var e = element.InternalElement; var r = new Autodesk.Revit.DB.Reference(e); var v = view.InternalElement; var m = (Autodesk.Revit.DB.TagMode)Enum.Parse(typeof(Autodesk.Revit.DB.TagMode), tagMode); var o = (Autodesk.Revit.DB.TagOrientation)Enum.Parse(typeof(Autodesk.Revit.DB.TagOrientation), tagOrientation); var l = (e.Location as Autodesk.Revit.DB.LocationPoint)?.Point; TransactionManager.Instance.EnsureInTransaction(doc); var tag = Autodesk.Revit.DB.IndependentTag.Create(doc, v.Id, r, addLeader, m, o, l); TransactionManager.Instance.TransactionTaskDone(); return(tag.ToDSType(true)); }
private void InitFamilyInstance(Autodesk.Revit.DB.FamilySymbol fs, Autodesk.Revit.DB.Reference reference, Autodesk.Revit.DB.XYZ location, Autodesk.Revit.DB.XYZ referenceDirection) { //Phase 1 - Check to see if the object exists and should be rebound var oldFam = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.FamilyInstance>(Document); //There was an existing family instance, rebind to that, and adjust its position if (oldFam != null && oldFam.HostFace.ElementId == reference.ElementId) { InternalSetFamilyInstance(oldFam); InternalSetFamilySymbol(fs); InternalSetPosition(location); return; } //Phase 2- There was no existing point, create one TransactionManager.Instance.EnsureInTransaction(Document); //If the symbol is not active, then activate it if (!fs.IsActive) { fs.Activate(); } var fi = Document.IsFamilyDocument ? Document.FamilyCreate.NewFamilyInstance(reference, location, referenceDirection, fs) : Document.Create.NewFamilyInstance(reference, location, referenceDirection, fs); InternalSetFamilyInstance(fi); TransactionManager.Instance.TransactionTaskDone(); ElementBinder.SetElementForTrace(InternalElement); }
private void SelectCurve_Click(object sender, EventArgs e) { try { Autodesk.Revit.DB.Reference eleR = uidoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element); Autodesk.Revit.DB.Element ele = doc.GetElement(eleR); Autodesk.Revit.DB.ModelCurve curve = ele as Autodesk.Revit.DB.ModelCurve; crv = curve.GeometryCurve; CurveID.Text = string.Format("Curve: {0}", curve.Id.ToString()); this.BringToFront(); } catch { TaskDialog.Show("Error", "Must select a model curve"); this.BringToFront(); } }
internal References(Autodesk.Revit.DB.Reference r) { InternalElement = r; }
internal FamilyInstance(Autodesk.Revit.DB.FamilySymbol fs, Autodesk.Revit.DB.Reference reference, Autodesk.Revit.DB.XYZ location, Autodesk.Revit.DB.XYZ referenceDirection) { SafeInit(() => InitFamilyInstance(fs, reference, location, referenceDirection)); }
internal FamilyInstance(Autodesk.Revit.DB.FamilySymbol fs, Autodesk.Revit.DB.Reference reference, Autodesk.Revit.DB.Line pos) { SafeInit(() => InitFamilyInstance(fs, reference, pos)); }
/// <summary> /// Show Element In Document /// https://www.revitapidocs.com/2020/6c40c35b-1b2b-1741-dafa-5ab6b1744634.htm /// </summary> public override void Action() { Autodesk.Revit.DB.Reference pickObject = UIDoc.Selection.PickObject(ObjectType.Element); Autodesk.Revit.DB.Element element = Doc.GetElement(pickObject); UIDoc.ShowElements(element); }
internal ElementPlaneReference(Autodesk.Revit.DB.Reference planeReference) { this.InternalReference = planeReference; }
internal FamilyInstances(Autodesk.Revit.DB.FamilySymbol fs, Autodesk.Revit.DB.XYZ point, Autodesk.Revit.DB.Reference reference, Autodesk.Revit.DB.XYZ referenceDir) { SafeInit(() => InitFamilyInstance(fs, point, reference, referenceDir)); }
private void InitFamilyInstance(Autodesk.Revit.DB.FamilySymbol fs, Autodesk.Revit.DB.XYZ point, Autodesk.Revit.DB.Reference reference, Autodesk.Revit.DB.XYZ referenceDir) { //Phase 1 - Check to see if the object exists and should be rebound var doc = DocumentManager.Instance.CurrentDBDocument; var oldFam = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.FamilyInstance>(doc); //There was a point, rebind to that, and adjust its position if (oldFam != null) { InternalSetFamilyInstance(oldFam); InternalSetFamilySymbol(fs); return; } //Phase 2- There was no existing point, create one TransactionManager.Instance.EnsureInTransaction(doc); //If the symbol is not active, then activate it if (!fs.IsActive) { fs.Activate(); } var fi = doc.Create.NewFamilyInstance(reference, point, referenceDir, fs); InternalSetFamilyInstance(fi); TransactionManager.Instance.TransactionTaskDone(); ElementBinder.SetElementForTrace(InternalElement); }