Exemple #1
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Document      doc   = uidoc.Document;

            FilteredElementCollector collector = new FilteredElementCollector(doc);

            collector.OfCategory(BuiltInCategory.OST_Conduit).WhereElementIsElementType();
            FamilyData fData = new FamilyData();

            fData.Category        = "Conduits";
            fData.FamilyName      = "Leerrohr";
            fData.FamilyTypeDatas = new List <FamilyTypeData>();

            string conduitTypes = String.Empty;

            foreach (ElementType item in collector)
            {
                string paramMountType = string.Empty;
                try
                {
                    //paramMountType = item.LookupParameter("Installationsort").AsString();
                    paramMountType = item.GetParameters("Installationsort")[0].AsString();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                string paramPlacement = string.Empty;
                try
                {
                    paramPlacement = item.LookupParameter("Installationsart").AsString();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                string paramInstallationMedium = string.Empty;
                try
                {
                    paramInstallationMedium = item.LookupParameter("Installations Medium").AsString();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                try
                {
                    conduitTypes += item.Name + " * " + item.Category.Name + " * " + paramInstallationMedium + " * " + paramPlacement + " * " + paramMountType + "\n";
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                string paramDescription   = GetConduitDescription(item.Name); //+ item.GetParameters("Installationsort")[0].AsString();
                string path               = String.Empty;
                string paramDiameter      = String.Empty;
                string paramWidth         = String.Empty;
                string paramHeight        = String.Empty;
                string paramDepth         = String.Empty;
                string param_eBKP_H       = String.Empty;
                string paramBKP           = String.Empty;
                string paramManufacturer  = String.Empty;
                string paramProduct       = String.Empty;
                string paramProductNumber = String.Empty;
                string paramE_Number      = String.Empty;
                string paramRevitCategory = String.Empty;
                string paramOmniClass     = String.Empty;


                FamilyTypeData typeData = new FamilyTypeData
                {
                    Name               = item.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" + item.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
                };
                if (typeData.Name != CategoryName)
                {
                    fData.FamilyTypeDatas.Add(typeData);
                }

                fData.FamilyTypeDatas = fData.FamilyTypeDatas.Distinct().ToList();
            }

            //TaskDialog.Show("Conduits", conduitTypes);

            List <FamilyData> familyData = new List <FamilyData>();

            familyData.Add(fData);

            SetPanelData(commandData, familyData);

            return(Result.Succeeded);
        }
Exemple #2
0
 private void SetProperty(FamilyTypeData instance)
 {
     Properties.Settings.Default.FamilyPath = instance.Path;
     Properties.Settings.Default.FamilyType = instance.Name;
     Properties.Settings.Default.FamilyName = FileNameCut(instance.Path);
 }