Пример #1
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();
            }
        }
Пример #2
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();
                }
            }
        }
Пример #3
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();
                }
            }
        }