コード例 #1
0
ファイル: Lab3Button.cs プロジェクト: tdima1/RevitLab
        public void GetFamilyTypesInFamily(Document familyDoc)
        {
            if (familyDoc.IsFamilyDocument)
            {
                FamilyManager         familyManager   = familyDoc.FamilyManager;
                string                types           = "Family Types: ";
                FamilyTypeSet         familyTypes     = familyManager.Types;
                FamilyTypeSetIterator familyTypesItor = familyTypes.ForwardIterator();
                familyTypesItor.Reset();

                while (familyTypesItor.MoveNext())
                {
                    FamilyType familyType = familyTypesItor.Current as FamilyType;
                    types += "\n" + familyType.Name;
                }
                TaskDialog.Show("Revit", types);
            }
        }
コード例 #2
0
        internal bool ProcessFamily()
        {
            if (!Doc.IsFamilyDocument)
            {
                return(false);
            }

            FamilyManager famMgr = Doc.FamilyManager;

            FamilyTypeSet         famTypes    = famMgr.Types;
            FamilyTypeSetIterator famTypeItor = famTypes.ForwardIterator();

            famTypeItor.Reset();
            while (famTypeItor.MoveNext())
            {
                FamilyType famType = famTypeItor.Current as FamilyType;
                logMsgDbLn2("fam type", famType.Name);
            }

            FamilyParameterSet         famParas    = famMgr.Parameters;
            FamilyParameterSetIterator famParaItor = famParas.ForwardIterator();

            famParaItor.Reset();
            while (famParaItor.MoveNext())
            {
                FamilyParameter famPara = famParaItor.Current as FamilyParameter;
                logMsgDbLn2("fam para", famPara.Definition.Name
                            + "  :: " + famPara.Definition.ParameterGroup.ToString()
                            + "  :: " + famPara.Definition.ParameterType.ToString());
            }

            famMgr.AddParameter("ASI", BuiltInParameterGroup.PG_IDENTITY_DATA, ParameterType.Text, true);

//			using (SubTransaction st = new SubTransaction(_doc))
//			{
//				st.Start();
//				famMgr.AddParameter("ASI", BuiltInParameterGroup.PG_IDENTITY_DATA, ParameterType.Text, true);
//				st.Commit();
//			}

            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Non-working sample code for
        /// http://forums.autodesk.com/t5/revit-api/family-types-amp-shared-parameter-values/m-p/6218767
        /// </summary>
        void SetFamilyParameterValueFails(
            Document doc,
            string paramNameToAmend)
        {
            FamilyManager         mgr         = doc.FamilyManager;
            FamilyTypeSet         familyTypes = mgr.Types;
            FamilyTypeSetIterator familyTypeItor
                = familyTypes.ForwardIterator();

            familyTypeItor.Reset();
            while (familyTypeItor.MoveNext())
            {
                FamilyParameter familyParam
                    = mgr.get_Parameter(paramNameToAmend);

                if (familyParam != null)
                {
                    FamilyType familyType = familyTypeItor.Current as FamilyType;
                    Debug.Print(familyType.Name);
                    mgr.Set(familyParam, 2);
                }
            }
        }
コード例 #4
0
        private List <Material> GetFamilyTypesMaterials(Document doc, Family modifiedFamily)
        {
            List <Material> typesMaterials = new List <Material>();

            Document              familyDoc     = doc.EditFamily(modifiedFamily);
            FamilyManager         familyManager = familyDoc.FamilyManager;
            FamilyTypeSet         familyTypes   = familyManager.Types;
            FamilyTypeSetIterator iterator      = familyTypes.ForwardIterator();

            iterator.Reset();
            string types = string.Empty;

            using (Transaction trans = new Transaction(familyDoc, "MaterialParameter"))
            {
                trans.Start();
                while (iterator.MoveNext())
                {
                    familyManager.CurrentType = iterator.Current as FamilyType;
                    FamilyType type  = familyManager.CurrentType;
                    string     param = string.Empty;
                    foreach (FamilyParameter parameter in familyManager.Parameters)
                    {
                        if (parameter.Definition.Name.Contains("Mat"))
                        {
                            Material material = doc.GetElement(type.AsElementId(parameter)) as Material;
                            if (material != null)
                            {
                                typesMaterials.Add(material);
                            }
                        }
                    }
                }
                trans.Commit();
            }

            return(typesMaterials);
        }
コード例 #5
0
ファイル: UpdateDB.cs プロジェクト: reybev/RevitFamilyManager
        private List <FamilyTypeData> GetTypes(Family family, Document doc, string path)
        {
            Document              familyDoc     = doc.EditFamily(family);
            FamilyManager         familyManager = familyDoc.FamilyManager;
            FamilyTypeSet         familyTypes   = familyManager.Types;
            FamilyTypeSetIterator iterator      = familyTypes.ForwardIterator();

            iterator.Reset();

            List <FamilyTypeData> types = new List <FamilyTypeData>();

            while (iterator.MoveNext())
            {
                using (Transaction trans = new Transaction(familyDoc, "Getting Parameter"))
                {
                    trans.Start();
                    familyManager.CurrentType = iterator.Current as FamilyType;
                    FamilyType type = familyManager.CurrentType;

                    string paramDescription = string.Empty;
                    //FamilyParameter paramDescription;
                    try
                    {
                        paramDescription = type.AsString(familyManager.get_Parameter("Description"));
                        if (string.IsNullOrEmpty(paramDescription))
                        {
                            try
                            {
                                paramDescription = type.AsString(familyManager.get_Parameter("Beschreibung"));
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string paramMountType = string.Empty;
                    try
                    {
                        paramMountType = type.AsString(familyManager.get_Parameter("Installationsart"));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string paramPlacement = string.Empty;
                    try
                    {
                        paramPlacement = type.AsString(familyManager.get_Parameter("Installationsort"));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string paramInstallationMedium = string.Empty;
                    try
                    {
                        paramInstallationMedium = type.AsString(familyManager.get_Parameter("Installations Medium"));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string paramDiameter = string.Empty;
                    try
                    {
                        paramDiameter = type.AsString(familyManager.get_Parameter("E_Durchmesser"));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string paramWidth = string.Empty;
                    try
                    {
                        paramWidth = type.AsString(familyManager.get_Parameter("E_Breite"));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string paramHeight = string.Empty;
                    try
                    {
                        paramHeight = type.AsString(familyManager.get_Parameter("E_Hohe"));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string paramDepth = string.Empty;
                    try
                    {
                        paramDepth = type.AsString(familyManager.get_Parameter("E_Tiefe"));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string param_eBKP_H = string.Empty;
                    try
                    {
                        param_eBKP_H = type.AsString(familyManager.get_Parameter("eBKP-H"));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string paramBKP = string.Empty;
                    try
                    {
                        paramBKP = type.AsString(familyManager.get_Parameter("BKP"));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string paramManufacturer = string.Empty;
                    try
                    {
                        paramManufacturer = type.AsString(familyManager.get_Parameter("Fabrikat"));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string paramProduct = string.Empty;
                    try
                    {
                        paramProduct = type.AsString(familyManager.get_Parameter("Produkt"));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string paramProductNumber = string.Empty;
                    try
                    {
                        paramProductNumber = type.AsString(familyManager.get_Parameter("Produkte-Nr."));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string paramE_Number = string.Empty;
                    try
                    {
                        paramE_Number = type.AsString(familyManager.get_Parameter("E-Nummer"));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string paramRevitCategory = String.Empty;
                    try
                    {
                        paramRevitCategory = type.AsString(familyManager.get_Parameter("Revit Kategorie"));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    string paramOmniClass = string.Empty;
                    try
                    {
                        paramOmniClass = type.AsString(familyManager.get_Parameter("OmniClass-Nummer"));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    if (true /*type != null && paramMountType!= null && paramPlacement!= null && paramInstallationMedium!=null*/)
                    {
                        FamilyTypeData typeData = new FamilyTypeData
                        {
                            Name               = type.Name,
                            Description        = string.IsNullOrEmpty(paramDescription)? emptyParameter: paramDescription,
                            MountType          = string.IsNullOrEmpty(paramMountType)? emptyParameter: paramMountType,
                            Placement          = string.IsNullOrEmpty(paramPlacement)? emptyParameter :paramPlacement,
                            InstallationMedium = string.IsNullOrEmpty(paramInstallationMedium) ? emptyParameter : paramInstallationMedium,
                            Path               = path,
                            CombinedTypeData   = paramDescription + "\n" + type.Name,
                            Diameter           = string.IsNullOrEmpty(paramDiameter)? emptyParameter: paramDiameter,
                            Width              = string.IsNullOrEmpty(paramWidth) ? emptyParameter : paramWidth,
                            Hight              = string.IsNullOrEmpty(paramHeight) ? emptyParameter : paramHeight,
                            Depth              = string.IsNullOrEmpty(paramDepth) ? emptyParameter : paramDepth,
                            eBKP_H             = string.IsNullOrEmpty(param_eBKP_H) ? emptyParameter : param_eBKP_H,
                            BKP           = string.IsNullOrEmpty(paramBKP) ? emptyParameter : paramBKP,
                            Manufacturer  = string.IsNullOrEmpty(paramManufacturer) ? emptyParameter : paramManufacturer,
                            Product       = string.IsNullOrEmpty(paramProduct) ? emptyParameter : paramProduct,
                            ProductNumber = string.IsNullOrEmpty(paramProductNumber) ? emptyParameter : paramProductNumber,
                            E_Number      = string.IsNullOrEmpty(paramE_Number) ? emptyParameter : paramE_Number,
                            RevitCategory = string.IsNullOrEmpty(paramRevitCategory) ? emptyParameter : paramRevitCategory,
                            OmniClass     = string.IsNullOrEmpty(paramOmniClass) ? emptyParameter : paramOmniClass
                        };
                        types.Add(typeData);
                    }

                    //TaskDialog.Show("Params", paramDescription.Definition.Name + " * " + type.AsString(paramDescription));
                    //TaskDialog.Show("Params", paramMountType.Definition.Name + " * " + type.AsString(paramMountType));
                    //TaskDialog.Show("Params", paramPlacement.Definition.Name + " * " + type.AsString(paramPlacement));
                    //TaskDialog.Show("Params", paramInstallationMedium.Definition.Name + " * " + type.AsString(paramInstallationMedium));
                    trans.Commit();
                }
            }

            return(types);
        }