Пример #1
0
        public void AdjustColumnTypeName(FamilySymbol colSymbol)
        {
            double colHeight, colWidth, colDiameter;
            string colMat;

            string targetColumnTypeName;

            if (colSymbol.Family.Name.Equals(Default.FAMILY_NAME_RECT_COLUMN))
            {
                GetRectColumnSymbolProperties(colSymbol, out colMat, out colHeight, out colWidth);

                string matSign = RvtMaterial.GetMatSyntaxe(colMat);

                targetColumnTypeName = $"{Default.SYNT_COLUMN}-{matSign}-{colWidth}x{colHeight}";
            }
            else
            {
                GetRondColumnSymbolProperties(colSymbol, out colMat, out colDiameter);

                string matSign = RvtMaterial.GetMatSyntaxe(colMat);

                targetColumnTypeName = $"{Default.SYNT_COLUMN}-{matSign}-D{colDiameter}";
            }

            if (!colSymbol.Name.Equals(targetColumnTypeName))
            {
                Transaction t = new Transaction(_doc);
                t.Start("Change column type name");
                colSymbol.Name = targetColumnTypeName;
                t.Commit();
            }
        }
Пример #2
0
        public void AdjustBeamTypeProperties(FamilySymbol beamSymbol)
        {
            string actualTypeName = beamSymbol.Name;
            string targetSynthaxe = actualTypeName.Before("-");
            string targetBeamSign = BeamType.GetBeamSign(targetSynthaxe);

            string targetMatSign = actualTypeName.Between("-", "-");
            string targetBeamMat = RvtMaterial.GetMatName(targetMatSign);

            string dimensionString = actualTypeName.After("-");
            double targetWidth     = Convert.ToDouble(dimensionString.Before("x"));
            double targetHeight    = Convert.ToDouble(dimensionString.After("x"));

            double beamHeight, beamWidth;
            string beamSign, beamMat;

            GetBeamSymbolProperties(beamSymbol, out beamSign, out beamMat, out beamHeight, out beamWidth);

            if (!beamSign.Equals(targetBeamSign))
            {
                Transaction t = new Transaction(_doc);
                t.Start("Change beam type property");
                SetStringValueTo(beamSymbol,
                                 Default.PARA_NAME_BEAM_TYPE,
                                 targetBeamSign);
                t.Commit();
            }

            if (!beamMat.Equals(targetBeamMat))
            {
                Material targetMaterial = GetMaterialByName(_doc, targetBeamMat);

                Transaction t = new Transaction(_doc);
                t.Start("Change beam material property");
                SetElementIdValueTo(beamSymbol,
                                    Default.PARA_NAME_STR_MATERIAL,
                                    targetMaterial.Id);
                t.Commit();
            }

            if (beamHeight != targetHeight)
            {
                Transaction t = new Transaction(_doc);
                t.Start("Change beam height property");
                SetDoubleValueTo(beamSymbol,
                                 Default.PARA_NAME_DIM_HEIGHT,
                                 UnitUtils.Convert(targetHeight, DisplayUnitType.DUT_CENTIMETERS, DisplayUnitType.DUT_DECIMAL_FEET));
                t.Commit();
            }

            if (beamWidth != targetWidth)
            {
                Transaction t = new Transaction(_doc);
                t.Start("Change beam width property");
                SetDoubleValueTo(beamSymbol,
                                 Default.PARA_NAME_DIM_WIDTH,
                                 UnitUtils.Convert(targetWidth, DisplayUnitType.DUT_CENTIMETERS, DisplayUnitType.DUT_DECIMAL_FEET));
                t.Commit();
            }
        }
Пример #3
0
        public FamilySymbol GetBeamFamilyTypeOrCreateNew(string beamSign, string beamMat, double beamHeight, double beamWidth)
        {
            string synthaxe = BeamType.GetSyntaxe(beamSign);
            string matSign  = RvtMaterial.GetMatSyntaxe(beamMat);

            string targetBeamTypeName = $"{synthaxe}-{matSign}-{beamWidth}x{beamHeight}";

            // find the family type for beam creation
            FamilySymbol beamSymbol = GetFamilySymbolByName(_doc, BuiltInCategory.OST_StructuralFraming, targetBeamTypeName);

            // if family type exists, adjust its properties
            if (beamSymbol != null)
            {
                AdjustBeamTypeProperties(beamSymbol);
            }
            // if family type doesn't exist in the project, create a new one
            else
            {
                if (null != _family)
                {
                    System.Diagnostics.Debug.Print("Family name={0}", _family.Name);

                    FamilySymbol s = null;
                    foreach (ElementId id in _family.GetFamilySymbolIds())
                    {
                        s = _doc.GetElement(id) as FamilySymbol;
                        break;
                    }
                    System.Diagnostics.Debug.Assert(null != s,
                                                    "expected at least one symbol"
                                                    + " to be defined in family");
                    Transaction t = new Transaction(_doc);
                    t.Start("Create new family type");

                    beamSymbol = s.Duplicate("InitialName") as FamilySymbol;

                    SetDoubleValueTo(
                        beamSymbol, Default.PARA_NAME_DIM_HEIGHT,
                        UnitUtils.Convert(beamHeight, DisplayUnitType.DUT_CENTIMETERS, DisplayUnitType.DUT_DECIMAL_FEET));

                    SetDoubleValueTo(
                        beamSymbol, Default.PARA_NAME_DIM_WIDTH,
                        UnitUtils.Convert(beamWidth, DisplayUnitType.DUT_CENTIMETERS, DisplayUnitType.DUT_DECIMAL_FEET));

                    SetStringValueTo(beamSymbol, Default.PARA_NAME_BEAM_TYPE, beamSign);

                    Material targetMaterial = GetMaterialByName(_doc, beamMat);

                    SetElementIdValueTo(beamSymbol, Default.PARA_NAME_STR_MATERIAL, targetMaterial.Id);

                    beamSymbol.Name = targetBeamTypeName;
                    t.Commit();

                    BeamTypesList.Add(beamSymbol);
                }
            }

            return(beamSymbol);
        }
Пример #4
0
        public void AdjustWallTypeProperties(WallType wallType)
        {
            string actualTypeName = wallType.Name;

            string targetMatSign = actualTypeName.Between("-", "-");
            string targetWallMat = RvtMaterial.GetMatName(targetMatSign);

            double targetThickness = Convert.ToDouble(actualTypeName.After("EP"));

            double wallThickness;
            string wallMat;
            bool   isStructural;

            GetWallTypeProperties(wallType, out isStructural, out wallMat, out wallThickness);

            if (isStructural)
            {
                if (!wallMat.Equals(targetWallMat))
                {
                    Material targetMaterial = GetMaterialByName(_doc, targetWallMat);

                    Transaction t = new Transaction(_doc);
                    t.Start("Change the material of the structural layer of the wall type");
                    foreach (CompoundStructureLayer layer in wallType.GetCompoundStructure().GetLayers())
                    {
                        if (layer.Function == MaterialFunctionAssignment.Structure)
                        {
                            layer.MaterialId = targetMaterial.Id;
                        }
                    }
                    t.Commit();
                }

                if (wallThickness != targetThickness)
                {
                    TaskDialog.Show("Revit", $"{isStructural}, {targetThickness}, {wallThickness}");
                    Transaction t = new Transaction(_doc);
                    t.Start("Change the structural layer thickness of the wall type property");
                    foreach (CompoundStructureLayer layer in wallType.GetCompoundStructure().GetLayers())
                    {
                        if (layer.Function == MaterialFunctionAssignment.Structure)
                        {
                            layer.Width = UnitUtils.Convert(targetThickness, DisplayUnitType.DUT_CENTIMETERS, DisplayUnitType.DUT_DECIMAL_FEET);
                        }
                    }
                    t.Commit();
                }
            }
        }
Пример #5
0
        public void AdjustBeamTypeName(FamilySymbol beamSymbol)
        {
            double beamHeight, beamWidth;
            string beamSign, beamMat;

            GetBeamSymbolProperties(beamSymbol, out beamSign, out beamMat, out beamHeight, out beamWidth);

            string synthaxe = BeamType.GetSyntaxe(beamSign);
            string matSign  = RvtMaterial.GetMatSyntaxe(beamMat);

            string targetBeamTypeName = $"{synthaxe}-{matSign}-{beamWidth}x{beamHeight}";

            if (!beamSymbol.Name.Equals(targetBeamTypeName))
            {
                Transaction t = new Transaction(_doc);
                t.Start("Change beam type name");
                beamSymbol.Name = targetBeamTypeName;
                t.Commit();
            }
        }
Пример #6
0
        public void AdjustWallTypeName(WallType wallType)
        {
            double wallThickness;
            string wallMat;
            bool   isStructural;

            GetWallTypeProperties(wallType, out isStructural, out wallMat, out wallThickness);
            if (isStructural)
            {
                string matSign = RvtMaterial.GetMatSyntaxe(wallMat);

                string targetWallTypeName = $"{Default.SYNT_WALL}-{matSign}-EP{wallThickness}";

                if (!wallType.Name.Equals(targetWallTypeName))
                {
                    Transaction t = new Transaction(_doc);
                    t.Start("Change wall type name");
                    wallType.Name = targetWallTypeName;
                    t.Commit();
                }
            }
        }
Пример #7
0
        public void AdjustColumnTypeProperties(FamilySymbol colSymbol)
        {
            string actualTypeName = colSymbol.Name;

            string targetMatSign = actualTypeName.Between("-", "-");
            string targetColMat  = RvtMaterial.GetMatName(targetMatSign);

            double targetWidth, targetHeight, targetDiameter;

            string dimensionString = actualTypeName.After("-");

            double colHeight, colWidth, colDiameter;
            string colMat;

            if (colSymbol.Family.Name.Equals(Default.FAMILY_NAME_RECT_COLUMN))
            {
                targetWidth  = Convert.ToDouble(dimensionString.Before("x"));
                targetHeight = Convert.ToDouble(dimensionString.After("x"));

                GetRectColumnSymbolProperties(colSymbol, out colMat, out colHeight, out colWidth);

                if (!colMat.Equals(targetColMat))
                {
                    Material targetMaterial = GetMaterialByName(_doc, targetColMat);

                    Transaction t = new Transaction(_doc);
                    t.Start("Change column material property");
                    SetElementIdValueTo(colSymbol,
                                        Default.PARA_NAME_STR_MATERIAL,
                                        targetMaterial.Id);
                    t.Commit();
                }

                if (colHeight != targetHeight)
                {
                    Transaction t = new Transaction(_doc);
                    t.Start("Change column height property");
                    SetDoubleValueTo(colSymbol,
                                     Default.PARA_NAME_DIM_HEIGHT,
                                     UnitUtils.Convert(targetHeight, DisplayUnitType.DUT_CENTIMETERS, DisplayUnitType.DUT_DECIMAL_FEET));
                    t.Commit();
                }

                if (colWidth != targetWidth)
                {
                    Transaction t = new Transaction(_doc);
                    t.Start("Change column width property");
                    SetDoubleValueTo(colSymbol,
                                     Default.PARA_NAME_DIM_WIDTH,
                                     UnitUtils.Convert(targetWidth, DisplayUnitType.DUT_CENTIMETERS, DisplayUnitType.DUT_DECIMAL_FEET));
                    t.Commit();
                }
            }
            else
            {
                targetDiameter = Convert.ToDouble(dimensionString.After(Default.KEYWORD_ROND_COLUMN_DIM));

                GetRondColumnSymbolProperties(colSymbol, out colMat, out colDiameter);

                if (!colMat.Equals(targetColMat))
                {
                    Material targetMaterial = GetMaterialByName(_doc, targetColMat);

                    Transaction t = new Transaction(_doc);
                    t.Start("Change column material property");
                    SetElementIdValueTo(colSymbol,
                                        Default.PARA_NAME_STR_MATERIAL,
                                        targetMaterial.Id);
                    t.Commit();
                }

                if (colDiameter != targetDiameter)
                {
                    Transaction t = new Transaction(_doc);
                    t.Start("Change column diameter property");
                    SetDoubleValueTo(colSymbol,
                                     Default.PARA_NAME_DIM_HEIGHT,
                                     UnitUtils.Convert(colDiameter, DisplayUnitType.DUT_CENTIMETERS, DisplayUnitType.DUT_DECIMAL_FEET));
                    t.Commit();
                }
            }
        }