/// <summary> /// Create a ElementType from a user selected Element. /// </summary> /// <param name="elementType"></param> /// <param name="isRevitOwned"></param> /// <returns></returns> internal static ElementType FromExisting(Autodesk.Revit.DB.ElementType elementType, bool isRevitOwned) { return(new ElementType(elementType) { IsRevitOwned = isRevitOwned }); }
void ReconstructElementTypeDuplicate ( DB.Document doc, ref DB.ElementType elementType, DB.ElementType type, string name ) { if ( elementType is DB.ElementType && elementType.Category.Id == type.Category.Id && elementType.FamilyName == type.FamilyName && elementType.GetType() == type.GetType() ) { if (elementType.Name != name) { elementType.Name = name; } if (elementType is DB.HostObjAttributes hostElementType && type is DB.HostObjAttributes hostType) { hostElementType.SetCompoundStructure(hostType.GetCompoundStructure()); } elementType.CopyParametersFrom(type); } else { elementType = type.Duplicate(name); } }
protected override void SolveInstance(IGH_DataAccess DA) { Autodesk.Revit.DB.ElementType elementType = null; if (!DA.GetData("Type", ref elementType)) { return; } DA.SetDataList("Types", elementType?.GetSimilarTypes()); }
void ReconstructElementTypeDuplicate ( DB.Document doc, ref DB.ElementType elementType, DB.ElementType type, string name ) { ReplaceElement(ref elementType, type.Duplicate(name)); }
void ReconstructElementTypeDuplicate ( Document doc, ref Autodesk.Revit.DB.ElementType elementType, Autodesk.Revit.DB.ElementType type, string name ) { ReplaceElement(ref elementType, type.Duplicate(name)); }
private RevitElementType ElementTypeToSpeckle(DB.ElementType revitType) { var speckleType = new RevitElementType { type = revitType.Name, family = revitType.FamilyName, category = revitType.Category.Name }; return(speckleType); }
protected override void SolveInstance(IGH_DataAccess DA) { Autodesk.Revit.DB.ElementType elementType = null; if (!DA.GetData("Type", ref elementType)) { return; } DA.SetData("Category", elementType?.Category); DA.SetData("FamilyName", elementType?.FamilyName); DA.SetData("Name", elementType?.Name); }
private void AddTypeParams(Autodesk.Revit.DB.ElementType et) { foreach (Parameter p in et.Parameters) { if (p.StorageType == StorageType.None) { continue; } AddDropDownItem(p); } }
private void AddElementParams(Element e) { foreach (Parameter p in e.Parameters) { if (!(p.StorageType == StorageType.None)) { AddDropDownItem(p); } } // if element can have type assigned it's safe to assume that it's an instance // and add type parameters to the list if (e.CanHaveTypeAssigned()) { Autodesk.Revit.DB.ElementType et = DocumentManager.Instance.CurrentDBDocument.GetElement(e.GetTypeId()) as Autodesk.Revit.DB.ElementType; if (et != null) { AddTypeParams(et); } } }
public bool CanConvertToSpeckle(object @object) { return(@object switch { DB.DetailCurve _ => true, DB.DirectShape _ => true, DB.FamilyInstance _ => true, DB.Floor _ => true, DB.Level _ => true, DB.View _ => true, DB.ModelCurve _ => true, DB.Opening _ => true, DB.RoofBase _ => true, DB.Area _ => true, DB.Architecture.Room _ => true, DB.Architecture.TopographySurface _ => true, DB.Wall _ => true, DB.Mechanical.Duct _ => true, DB.Mechanical.Space _ => true, DB.Plumbing.Pipe _ => true, DB.Electrical.Wire _ => true, DB.CurtainGridLine _ => true, //these should be handled by curtain walls DB.Architecture.BuildingPad _ => true, DB.Architecture.Stairs _ => true, DB.Architecture.StairsRun _ => true, DB.Architecture.StairsLanding _ => true, DB.Architecture.Railing _ => true, DB.Architecture.TopRail _ => true, DB.Ceiling _ => true, DB.PointCloudInstance _ => true, DB.Group _ => true, DB.ProjectInfo _ => true, DB.ElementType _ => true, DB.Grid _ => true, DB.ReferencePoint _ => true, DB.Structure.AnalyticalModelStick _ => true, DB.Structure.AnalyticalModelSurface _ => true, DB.Structure.BoundaryConditions _ => true, _ => (@object as Element).IsElementSupported() });
private View GetViewByName(string name) { FilteredElementCollector docFilter = new FilteredElementCollector(uidoc.Document); if (docFilter != null) { FilteredElementIterator viewsIterator = docFilter.OfClass(typeof(Autodesk.Revit.DB.View)).GetElementIterator(); while (viewsIterator.MoveNext()) { Autodesk.Revit.DB.View curView = viewsIterator.Current as Autodesk.Revit.DB.View; string curViewTypeName = curView.GetType().Name; if ((curViewTypeName == "ViewDrafting") || (curViewTypeName == "ViewPlan")) { Autodesk.Revit.DB.ElementId curElementId = curView.GetTypeId(); Autodesk.Revit.DB.ElementType curElementType = uidoc.Document.GetElement(curElementId) as ElementType; if (curElementType != null) { if (curElementType.GetType().Name == "ViewFamilyType") { Autodesk.Revit.DB.ViewFamilyType curViewFamilyType = (ViewFamilyType)curElementType; if (curViewFamilyType != null) { string curViewName = curViewFamilyType.Name + ": " + curView.Name; if (curViewName == name) { return(curView); } } } } } } } return(null); }
private List <string> GetDraftAndPlanViewsNames(Document vdoc) { List <string> names = new List <string>(); FilteredElementCollector viewFilter = new FilteredElementCollector(vdoc); if (viewFilter != null) { FilteredElementIterator viewsIterator = viewFilter.OfClass(typeof(Autodesk.Revit.DB.View)).GetElementIterator(); while (viewsIterator.MoveNext()) { Autodesk.Revit.DB.View curView = viewsIterator.Current as Autodesk.Revit.DB.View; string curViewTypeName = curView.GetType().Name; if ((curViewTypeName == "ViewDrafting") || (curViewTypeName == "ViewPlan") || (curViewTypeName == "ViewSchedule")) { Autodesk.Revit.DB.ElementId curElementId = curView.GetTypeId(); Autodesk.Revit.DB.ElementType curElementType = vdoc.GetElement(curElementId) as ElementType; if (curElementType != null) { if (curElementType.GetType().Name == "ViewFamilyType") { Autodesk.Revit.DB.ViewFamilyType curViewFamilyType = (ViewFamilyType)curElementType; if (curViewFamilyType != null) { string curName = curViewFamilyType.Name + ": " + curView.Name; names.Add(curName); } } } } } } names.Sort(); return(names); }
/// <summary> /// Initialize a ElementType element /// and sets the ElementType property, element id, and unique id. /// </summary> /// <param name="elementType"></param> private void InitElementType(Autodesk.Revit.DB.ElementType elementType) { this.InternalElementType = elementType; this.InternalElementId = elementType.Id; this.InternalUniqueId = elementType.UniqueId; }
/// <summary> /// Protected constructor for the Element. /// </summary> /// <param name="elementType"></param> protected ElementType(Autodesk.Revit.DB.ElementType elementType) { SafeInit(() => InitElementType(elementType)); }
public static ElementType Wrap(Autodesk.Revit.DB.ElementType elementType, bool isRevitOwned) { return(ElementType.FromExisting(elementType, isRevitOwned)); }
public ElementType(DB.ElementType elementType) : base(elementType) { }
public static IDictionary MergeElementTypes(DynaElem FromType, DynaElem ToType) { // Name of Transaction string transactionName = "Merge Element Type"; // Get the Revit elements from the Dynamo Elements RevitDB.ElementType rFromType = (RevitDB.ElementType)FromType.InternalElement; RevitDB.ElementType rToType = (RevitDB.ElementType)ToType.InternalElement; RevitDoc document = rToType.Document; // Collect all instances of FromType RevitDB.FilteredElementCollector collector = new RevitDB.FilteredElementCollector(document); RevitDB.BuiltInParameter parameterId = RevitDB.BuiltInParameter.ELEM_TYPE_PARAM; RevitDB.FilterNumericEquals filterNumberRule = new RevitDB.FilterNumericEquals(); RevitDB.ParameterValueProvider provider = new RevitDB.ParameterValueProvider(new RevitDB.ElementId(parameterId)); RevitDB.FilterRule filterRule = new RevitDB.FilterElementIdRule(provider, filterNumberRule, rFromType.Id); RevitDB.ElementFilter filterParameter = new RevitDB.ElementParameterFilter(filterRule, false); Type instanceType = Select.InstanceClassFromTypeClass(rFromType.GetType()); if (instanceType != null) { collector.OfClass(instanceType); } IEnumerable <RevitDB.Element> instances = collector .WhereElementIsNotElementType() .WherePasses(filterParameter) .ToElements(); // Intialize list for elements that are successfully merged and failed to merge. List <DynaElem> elements = new List <DynaElem>(); List <DynaElem> elementsFailed = new List <DynaElem>(); // Define Function to change instances types. Action <IEnumerable <RevitDB.Element> > _SetType = (isntances) => { foreach (RevitDB.Element elem in instances) { // If Element is in a group, put the element in the failed list int groupId = elem.GroupId.IntegerValue; if (groupId == -1) { //elem.TextNoteType = rToType; RevitDB.Parameter param = elem.get_Parameter(RevitDB.BuiltInParameter.ELEM_TYPE_PARAM); param.Set(rToType.Id); DynaElem dElem = elem.ToDSType(true); elements.Add(dElem); } else { DynaElem dElem = elem.ToDSType(true); elementsFailed.Add(dElem); } } // Check if there are any instances of FromType left int count = collector.Count(); if (count == 0) { document.Delete(rFromType.Id); } }; if (document.IsModifiable) { TransactionManager.Instance.EnsureInTransaction(document); _SetType(instances); TransactionManager.Instance.TransactionTaskDone(); } else { using (Autodesk.Revit.DB.Transaction trans = new Autodesk.Revit.DB.Transaction(document)) { trans.Start(transactionName); _SetType(instances); trans.Commit(); } } return(new Dictionary <string, object> { { "Merged", elements }, { "Failed", elementsFailed } }); }
public ElementType(Autodesk.Revit.DB.ElementType elementType) : base(elementType) { }
private List <string> getOpenPlanViewsTitles() { List <string> planViewsTitles = new List <string>(); if (this.uidoc != null) { Document doc = this.uidoc.Document; if (doc != null) { IList <UIView> uiviews = this.uidoc.GetOpenUIViews(); IList <UIView> cluiviews = new List <UIView>(); for (int i = 0; i < uiviews.Count; i++) { UIView curUIView = uiviews[i]; ElementId curViewId = curUIView.ViewId; if (curViewId != null) { Element curElement = doc.GetElement(curViewId); if (curElement != null) { string curElementTypeName = curElement.GetType().Name; if (curElementTypeName == "ViewPlan") { ViewPlan curViewPlan = curElement as ViewPlan; if (curViewPlan != null) { Autodesk.Revit.DB.ElementId curElementId = curViewPlan.GetTypeId(); Autodesk.Revit.DB.ElementType curElementType = doc.GetElement(curElementId) as ElementType; if (curElementType != null) { if (curElementType.GetType().Name == "ViewFamilyType") { Autodesk.Revit.DB.ViewFamilyType curViewFamilyType = (ViewFamilyType)curElementType; if (curViewFamilyType != null) { string curTitle = curViewFamilyType.Name + ": " + curViewPlan.Name; planViewsTitles.Add(curTitle); } } } } } else { cluiviews.Add(curUIView); } } } } if (cluiviews.Count > 1) { while (cluiviews.Count > 0) { try { UIView curUIView = cluiviews.ElementAt(0); cluiviews.RemoveAt(0); if (curUIView != null) { try { if (cluiviews.Count > 1) { curUIView.Close(); curUIView.Dispose(); } } catch (Exception exA) { } } } catch (Exception exB) { } } } } } return(planViewsTitles); }