コード例 #1
0
        /// <summary>
        /// Saves a .rfa file to the specified path.
        /// </summary>
        /// <param name="family">The loaded family to be saved</param>
        /// <param name="path">Target file path</param>
        /// <param name="fileName">Target file fame (without .rfa)</param>
        public static bool SaveAs(Revit.Elements.Family family, string path, string fileName)
        {
            var intFam = family.InternalElement as Autodesk.Revit.DB.Family;

            TransactionManager.Instance.ForceCloseTransaction();

            var famDoc = DocumentManager.Instance.CurrentDBDocument.EditFamily(intFam);

            famDoc.SaveAs(Path.Combine(path, fileName + ".rfa"));
            famDoc.Close(false);

            return(true);
        }
コード例 #2
0
ファイル: Document.cs プロジェクト: ziter05/DynamoRevit
        /// <summary>
        /// Saves all of the input families at a given location.
        /// </summary>
        /// <param name="family">The Revit family to save</param>
        /// <param name="directoryPath">Directory to save the family to. If directory does not exist, it will be created.</param>
        /// <returns>File path of saved families</returns>
        public string SaveFamilyToFolder(Revit.Elements.Family family, string directoryPath)
        {
            var dir = new DirectoryInfo(directoryPath);

            if (!dir.Exists)
            {
                Directory.CreateDirectory(directoryPath);
            }

            // Close all transactions
            var trans = TransactionManager.Instance;

            trans.ForceCloseTransaction();

            var    fam            = family.InternalFamily;
            var    familyDocument = this.InternalDocument.EditFamily(fam);
            var    name           = fam.Name + ".rfa";
            string filePath       = Path.Combine(directoryPath, name);

            familyDocument.SaveAs(filePath);
            familyDocument.Close(false);
            return(filePath);
        }
コード例 #3
0
 /// <summary>
 /// Creates a ElementFilter that passes types with the specified family.  The filter should then be passed to a Collector node and the Collector retrieves elements that pass the filter.
 /// </summary>
 /// <param name="family">A dynamo wrapped family</param>
 /// <returns name="ElementFilter">An Element Filter.  The filter should then be passed to a Collector node and the Collector retrieves elements that pass the filter.</returns>
 public static revitDB.ElementFilter FilterFamilyType(DynFamily family)
 {
     return(new revitDB.FamilySymbolFilter(new revitDB.ElementId(family.Id)));
 }
コード例 #4
0
ファイル: FamilySymbol.cs プロジェクト: RobertiF/Dynamo
        /// <summary>
        /// Select a FamilySymbol given it's parent Family and the FamilySymbol's name.
        /// </summary>
        /// <param name="family">The FamilySymbol's parent Family</param>
        /// <param name="name">The name of the FamilySymbol</param>
        /// <returns></returns>
        public static FamilySymbol ByFamilyAndName(Family family, string name)
        {
            if (family == null)
            {
                throw new ArgumentNullException("family");
            }

            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            // obtain the family symbol with the provided name
            var symbol =
                family.InternalFamily.Symbols.Cast<Autodesk.Revit.DB.FamilySymbol>().FirstOrDefault(x => x.Name == name);

            if (symbol == null)
            {
               throw new Exception(String.Format("A FamilySymbol with the specified name, {0}, does not exist in the Family", name));
            }

            return new FamilySymbol(symbol)
            {
                IsRevitOwned = true
            };
        }
コード例 #5
0
 public static Family Wrap(Autodesk.Revit.DB.Family ele, bool isRevitOwned)
 {
     return(Family.FromExisting(ele, isRevitOwned));
 }