Example #1
0
        /// <summary>
        /// Dump properties specific to a decking layer
        /// </summary>
        /// <param name="deck"></param>
        private void DumbDeck(CompoundStructureLayer deck)
        {
            m_displayForm.WriteLine("Dumping Deck");

            if (deck.MaterialId != ElementId.InvalidElementId)
            {
                // get the deck material object. In this sample all we need to display is the
                // name, but other properties are readily available from the material object.
                Autodesk.Revit.DB.Material deckMaterial = m_document.GetElement(deck.MaterialId) as Material;
                m_displayForm.WriteLine("Deck Material = " + deckMaterial.Name);
            }

            if (deck.DeckProfileId != ElementId.InvalidElementId)
            {
                // the deck profile is actually a family symbol from a family of profiles
                Autodesk.Revit.DB.FamilySymbol deckProfile = m_document.GetElement(deck.DeckProfileId) as FamilySymbol;

                // firstly display the full name as the user would see it in the user interface
                // this is done in the format Family.Name and then Symbol.Name
                m_displayForm.WriteLine("Deck Profile = "
                                        + deckProfile.Family.Name + " : " + deckProfile.Name);

                // the symbol object also contains parameters that describe how the deck is
                // specified. From these parameters an external application can generate
                // identical decking for analysis purposes
                DumpParameters(deckProfile);
            }
        }
Example #2
0
        public void GetWallTypeProperties(WallType wallType, out bool isStructural, out string wallMat, out double wallThickness)
        {
            CompoundStructureLayer strLayer =
                (from CompoundStructureLayer layer in wallType.GetCompoundStructure().GetLayers()
                 where layer.Function == MaterialFunctionAssignment.Structure
                 select layer)
                .FirstOrDefault();

            if (strLayer != null)
            {
                isStructural = true;

                if (strLayer.MaterialId != ElementId.InvalidElementId)
                {
                    wallMat = _doc.GetElement(strLayer.MaterialId).Name;
                }
                else
                {
                    wallMat = String.Empty;
                }

                wallThickness = UnitUtils.Convert(
                    strLayer.Width,
                    DisplayUnitType.DUT_DECIMAL_FEET,
                    DisplayUnitType.DUT_CENTIMETERS);
            }
            else
            {
                isStructural  = false;
                wallMat       = String.Empty;
                wallThickness = 0;
            }
        }
Example #3
0
        Stream(ArrayList data, CompoundStructureLayer compStructLayer)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(CompoundStructureLayer)));

            data.Add(new Snoop.Data.String("Function", compStructLayer.Function.ToString()));
            data.Add(new Snoop.Data.Object("MaterialId", GetElementById(compStructLayer.MaterialId)));
            data.Add(new Snoop.Data.Double("Width", compStructLayer.Width));
            data.Add(new Snoop.Data.Object("DeckProfileId", GetElementById(compStructLayer.DeckProfileId)));
            //data.Add(new Snoop.Data.String("Deck usage", compStructLayer.DeckUsage.ToString()));
            //data.Add(new Snoop.Data.Bool("Variable", compStructLayer.));
        }
        CollectEvent(object sender, CollectorEventArgs e)
        {
            // cast the sender object to the SnoopCollector we are expecting
            Collector snoopCollector = sender as Collector;

            if (snoopCollector == null)
            {
                Debug.Assert(false); // why did someone else send us the message?
                return;
            }

            // see if it is a type we are responsible for
            AnalyticalModel aModel = e.ObjToSnoop as AnalyticalModel;

            if (aModel != null)
            {
                Stream(snoopCollector.Data(), aModel);
                return;
            }

            CompoundStructure compStruct = e.ObjToSnoop as CompoundStructure;

            if (compStruct != null)
            {
                Stream(snoopCollector.Data(), compStruct);
                return;
            }

            CompoundStructureLayer compStructLayer = e.ObjToSnoop as CompoundStructureLayer;

            if (compStructLayer != null)
            {
                Stream(snoopCollector.Data(), compStructLayer);
                return;
            }

            AnalyticalModelSupport supportData = e.ObjToSnoop as AnalyticalModelSupport;

            if (supportData != null)
            {
                Stream(snoopCollector.Data(), supportData);
                return;
            }

            RebarInSystem barDesc = e.ObjToSnoop as RebarInSystem;

            if (barDesc != null)
            {
                Stream(snoopCollector.Data(), barDesc);
                return;
            }
        }
Example #5
0
        /// <summary>
        /// for non deck layers this method is called and it displays minimal information
        /// about the layer
        /// </summary>
        /// <param name="layer"></param>
        private void DumpLayer(CompoundStructureLayer layer)
        {
            // Display the name of the material. More detailed material properties can
            // be found form the material object
            m_displayForm.WriteLine("Dumping Layer");
            Autodesk.Revit.DB.Material material = m_document.GetElement(layer.MaterialId) as Material;
            if (material != null)
            {
                m_displayForm.WriteLine("Layer material = " + material.Name);
            }

            // display the thickness of the layer in inches.
            m_displayForm.WriteLine("Layer Thickness = " + layer.Width.ToString());
        }
Example #6
0
        /// <summary>
        /// SetLayer method
        /// </summary>
        /// <param name="layerNumber">The layerNumber for the number of the layers</param>
        public void SetLayer(int layerNumber)
        {
            // Get each layer.
            // An individual layer can be accessed by Layers property and its thickness and material can then be reported.
            m_slabLayer = m_slabLayerCollection[layerNumber];

            // Get the Thickness property and change to the metric millimeter
            m_thickness = ((m_slabLayer.Width) * ToMetricThickness * ToMillimeter).ToString() + " mm";

            // Get the Material name property
            if (ElementId.InvalidElementId != m_slabLayer.MaterialId)
            {
                Material material = m_document.GetElement(m_slabLayer.MaterialId) as Material;
                m_materialName = material.Name;
            }
            else
            {
                m_materialName = "Null";
            }

            // The Young modulus can be found from the material by using the following generic parameters:
            // PHY_MATERIAL_PARAM_YOUNG_MOD1, PHY_MATERIAL_PARAM_YOUNG_MOD2, PHY_MATERIAL_PARAM_YOUNG_MOD3
            if (ElementId.InvalidElementId != m_slabLayer.MaterialId)
            {
                Material  material             = m_document.GetElement(m_slabLayer.MaterialId) as Material;
                Parameter youngModuleAttribute = null;
                youngModuleAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD1);
                if (null != youngModuleAttribute)
                {
                    m_youngModulusX = (youngModuleAttribute.AsDouble() / ToMetricYoungmodulus).ToString("F2") + " MPa";
                }
                youngModuleAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD2);
                if (null != youngModuleAttribute)
                {
                    m_youngModulusY = (youngModuleAttribute.AsDouble() / ToMetricYoungmodulus).ToString("F2") + " MPa";
                }
                youngModuleAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD3);
                if (null != youngModuleAttribute)
                {
                    m_youngModulusZ = (youngModuleAttribute.AsDouble() / ToMetricYoungmodulus).ToString("F2") + " MPa";
                }
            }
            else
            {
                m_youngModulusX = "Null";
                m_youngModulusY = "Null";
                m_youngModulusZ = "Null";
            }
        }
Example #7
0
        /***************************************************/
        /****              Public methods               ****/
        /***************************************************/

        public static oM.Physical.Constructions.Layer Layer(this CompoundStructureLayer compoundStructureLayer, HostObjAttributes owner, string materialGrade = null, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            if (compoundStructureLayer == null)
            {
                return(null);
            }

            settings = settings.DefaultIfNull();

            oM.Physical.Constructions.Layer layer = new oM.Physical.Constructions.Layer();
            layer.Thickness = compoundStructureLayer.Width.ToSI(UnitType.UT_Length);

            Material revitMaterial = owner.Document.GetElement(compoundStructureLayer.MaterialId) as Material;

            if (revitMaterial == null)
            {
                revitMaterial = owner.Category.Material;
            }

            layer.Material = revitMaterial.MaterialFromRevit(materialGrade, settings, refObjects);
            return(layer);
        }
Example #8
0
        public static List <MaterialLayer> MaterialLayers(this Document document, CompoundStructure compoundStructure)
        {
            if (document == null || compoundStructure == null)
            {
                return(null);
            }

            IEnumerable <CompoundStructureLayer> compoundStructureLayers = compoundStructure.GetLayers();

            if (compoundStructureLayers == null)
            {
                return(null);
            }

            int count = compoundStructureLayers.Count();

            List <MaterialLayer> result = new List <MaterialLayer>();

            for (int i = 0; i < count; i++)
            {
                CompoundStructureLayer compoundStructureLayer = compoundStructureLayers.ElementAt(i);
                if (compoundStructureLayer == null)
                {
                    continue;
                }

                Material material = document.GetElement(compoundStructureLayer.MaterialId) as Material;
                if (material == null)
                {
                    continue;
                }

                double thickness = compoundStructure.GetLayerWidth(i);

                result.Add(new MaterialLayer(material.Name, thickness));
            }

            return(result);
        }
Example #9
0
        /// <summary>
        /// SetLayer method
        /// </summary>
        /// <param name="layerNumber">The layerNumber for the number of the layers</param>
        public void SetLayer(int layerNumber)
        {
            // Get each layer.
            // An individual layer can be accessed by Layers property and its thickness and material can then be reported.
            m_slabLayer = m_slabLayerCollection[layerNumber];

            // Get the Thickness property and change to the metric millimeter
            m_thickness = ((m_slabLayer.Width) * ToMetricThickness * ToMillimeter).ToString() + " mm";

            // Get the Material name property
            if (ElementId.InvalidElementId != m_slabLayer.MaterialId)
            {
                Material material = m_document.get_Element(m_slabLayer.MaterialId) as Material;
                m_materialName = material.Name;
            }
            else
            {
                m_materialName = "Null";
            }

            // The Young modulus can be found from the material by using the following generic parameters:
            // PHY_MATERIAL_PARAM_YOUNG_MOD1, PHY_MATERIAL_PARAM_YOUNG_MOD2, PHY_MATERIAL_PARAM_YOUNG_MOD3
            if (ElementId.InvalidElementId != m_slabLayer.MaterialId)
            {
                Material material = m_document.get_Element(m_slabLayer.MaterialId) as Material;
                Parameter youngModuleAttribute = null;
                youngModuleAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD1);
                if (null != youngModuleAttribute)
                {
                    m_youngModulusX = (youngModuleAttribute.AsDouble() / ToMetricYoungmodulus).ToString("F2") + " MPa";
                }
                youngModuleAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD2);
                if (null != youngModuleAttribute)
                {
                    m_youngModulusY = (youngModuleAttribute.AsDouble() / ToMetricYoungmodulus).ToString("F2") + " MPa";
                }
                youngModuleAttribute = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_YOUNG_MOD3);
                if (null != youngModuleAttribute)
                {
                    m_youngModulusZ = (youngModuleAttribute.AsDouble() / ToMetricYoungmodulus).ToString("F2") + " MPa";
                }
            }
            else
            {
                m_youngModulusX = "Null";
                m_youngModulusY = "Null";
                m_youngModulusZ = "Null";
            }
        }
        private void Stream(ArrayList data, CompoundStructureLayer compStructLayer)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(CompoundStructureLayer)));

             data.Add(new Snoop.Data.String("Function", compStructLayer.Function.ToString()));
             data.Add(new Snoop.Data.Object("MaterialId", GetElementById(compStructLayer.MaterialId)));
             data.Add(new Snoop.Data.Double("Width", compStructLayer.Width));
             data.Add(new Snoop.Data.Object("DeckProfileId", GetElementById(compStructLayer.DeckProfileId)));
             //data.Add(new Snoop.Data.String("Deck usage", compStructLayer.DeckUsage.ToString()));
             //data.Add(new Snoop.Data.Bool("Variable", compStructLayer.));
        }
Example #11
0
        public static HostObjAttributes ToRevit(this HostPartitionType hostPartitionType, Document document, Core.Revit.ConvertSettings convertSettings)
        {
            if (hostPartitionType == null)
            {
                return(null);
            }

            HostObjAttributes result = null;

            List <HostObjAttributes> hostObjAttributesList = convertSettings?.GetObjects <HostObjAttributes>(hostPartitionType.Guid);

            if (hostObjAttributesList != null)
            {
                if (hostPartitionType is WallType)
                {
                    result = hostObjAttributesList.Find(x => x is Autodesk.Revit.DB.WallType);
                }
                else if (hostPartitionType is FloorType)
                {
                    result = hostObjAttributesList.Find(x => x is Autodesk.Revit.DB.FloorType);
                }
                else if (hostPartitionType is RoofType)
                {
                    result = hostObjAttributesList.Find(x => x is Autodesk.Revit.DB.RoofType);
                }
            }

            if (result != null)
            {
                return(result);
            }

            FilteredElementCollector filteredElementCollector = Query.FilteredElementCollector_New(document, hostPartitionType.GetType())?.OfClass(typeof(HostObjAttributes));

            if (filteredElementCollector == null)
            {
                return(null);
            }

            string familyName_Source = null;
            string typeName_Source   = null;

            if (!Core.Revit.Query.TryGetFamilyNameAndTypeName(hostPartitionType.Name, out familyName_Source, out typeName_Source))
            {
                return(null);
            }

            foreach (HostObjAttributes hostObjAttributes in filteredElementCollector)
            {
                string fullName = Core.Revit.Query.FullName(hostObjAttributes);

                string familyName = null;
                string typeName   = null;
                if (!Core.Revit.Query.TryGetFamilyNameAndTypeName(fullName, out familyName, out typeName))
                {
                    continue;
                }

                if (fullName != null && fullName.Equals(hostPartitionType.Name))
                {
                    result = hostObjAttributes;
                    break;
                }

                if (!string.IsNullOrWhiteSpace(familyName) && !string.IsNullOrWhiteSpace(familyName_Source))
                {
                    continue;
                }


                if (typeName.Equals(typeName_Source))
                {
                    result = hostObjAttributes;
                }
            }

            if (result == null)
            {
                return(result);
            }

            List <Architectural.MaterialLayer> materialLayers = hostPartitionType.MaterialLayers;

            if (materialLayers != null && materialLayers.Count != 0)
            {
                CompoundStructure compoundStructure = result.GetCompoundStructure();
                if (compoundStructure != null)
                {
                    List <Material> materials = new FilteredElementCollector(document).OfClass(typeof(Material)).Cast <Material>().ToList();

                    List <CompoundStructureLayer> compoundStructureLayers = new List <CompoundStructureLayer>();
                    foreach (Architectural.MaterialLayer materialLayer in materialLayers)
                    {
                        Material material = materials.Find(x => x.Name == materialLayer.Name);
                        if (material == null)
                        {
                            continue;
                        }

                        double width = double.NaN;

#if Revit2017 || Revit2018 || Revit2019 || Revit2020
                        width = UnitUtils.ConvertToInternalUnits(materialLayer.Thickness, DisplayUnitType.DUT_METERS);
#else
                        width = UnitUtils.ConvertToInternalUnits(materialLayer.Thickness, UnitTypeId.Meters);
#endif



                        CompoundStructureLayer compoundStructureLayer = new CompoundStructureLayer(width, MaterialFunctionAssignment.Structure, material.Id);
                        if (compoundStructureLayer == null)
                        {
                            continue;
                        }

                        compoundStructureLayers.Add(compoundStructureLayer);
                    }

                    if (compoundStructureLayers != null && compoundStructureLayers.Count != 0)
                    {
                        compoundStructure.SetLayers(compoundStructureLayers);
                        result.SetCompoundStructure(compoundStructure);
                    }
                }
            }

            if (convertSettings.ConvertParameters)
            {
                Core.Revit.Modify.SetValues(result, hostPartitionType);
                Core.Revit.Modify.SetValues(result, hostPartitionType, ActiveSetting.Setting);
            }

            convertSettings?.Add(hostPartitionType.Guid, result);

            return(result);
        }
Example #12
0
        /// <summary>
        /// Create vertical CompoundStructure for wall: new layers, split new region, new sweep and new reveal.
        /// </summary>
        /// <param name="wall">The wall applying the new CompoundStructure.</param>
        public void CreateCSforWall(Wall wall)
        {
            // Get CompoundStructure


            WallType wallType = wall.WallType;
            //wallType.Name = wallType.Name + "_WithNewCompoundStructure";
            CompoundStructure wallCS = wallType.GetCompoundStructure();
            // Get material for CompoundStructureLayer

            Material masonry_Brick = CreateSampleBrickMaterial();
            Material concrete      = CreateSampleConcreteMaterial();

            // Create CompoundStructureLayers and add the materials created above to them.
            List <CompoundStructureLayer> csLayers       = new List <CompoundStructureLayer>();
            CompoundStructureLayer        finish1Layer   = new CompoundStructureLayer(0.2, MaterialFunctionAssignment.Finish1, masonry_Brick.Id);
            CompoundStructureLayer        substrateLayer = new CompoundStructureLayer(0.1, MaterialFunctionAssignment.Substrate, ElementId.InvalidElementId);
            CompoundStructureLayer        structureLayer = new CompoundStructureLayer(0.5, MaterialFunctionAssignment.Structure, concrete.Id);
            CompoundStructureLayer        membraneLayer  = new CompoundStructureLayer(0, MaterialFunctionAssignment.Membrane, ElementId.InvalidElementId);
            CompoundStructureLayer        finish2Layer   = new CompoundStructureLayer(0.2, MaterialFunctionAssignment.Finish2, concrete.Id);

            csLayers.Add(finish1Layer);
            csLayers.Add(substrateLayer);
            csLayers.Add(structureLayer);
            csLayers.Add(membraneLayer);
            csLayers.Add(finish2Layer);

            // Set the created layers to CompoundStructureLayer
            wallCS.SetLayers(csLayers);


            //Set which layer is used for structural analysis
            wallCS.StructuralMaterialIndex = 2;

            // Set shell layers and wrapping.
            wallCS.SetNumberOfShellLayers(ShellLayerType.Interior, 2);
            wallCS.SetNumberOfShellLayers(ShellLayerType.Exterior, 1);
            wallCS.SetParticipatesInWrapping(0, false);

            // Points for adding wall sweep and reveal.
            UV sweepPoint  = UV.Zero;
            UV revealPoint = UV.Zero;

            // split the region containing segment 0.
            int segId = wallCS.GetSegmentIds()[0];

            foreach (int regionId in wallCS.GetAdjacentRegions(segId))
            {
                // Get the end points of segment 0.
                UV endPoint1 = UV.Zero;
                UV endPoint2 = UV.Zero;
                wallCS.GetSegmentEndPoints(segId, regionId, out endPoint1, out endPoint2);

                // Split a new region in split point and orientation.
                RectangularGridSegmentOrientation splitOrientation = (RectangularGridSegmentOrientation)(((int)(wallCS.GetSegmentOrientation(segId)) + 1) % 2);
                UV   splitUV         = (endPoint1 + endPoint2) / 2.0;
                int  newRegionId     = wallCS.SplitRegion(splitUV, splitOrientation);
                bool isValidRegionId = wallCS.IsValidRegionId(newRegionId);

                // Find the enclosing region and the two segments intersected by a line through the split point
                int segId1;
                int segId2;
                int findRegionId = wallCS.FindEnclosingRegionAndSegments(splitUV, splitOrientation, out segId1, out segId2);

                // Get the end points of finding segment 1 and compute the wall sweep point.
                UV eP1 = UV.Zero;
                UV eP2 = UV.Zero;
                wallCS.GetSegmentEndPoints(segId1, findRegionId, out eP1, out eP2);
                sweepPoint = (eP1 + eP2) / 4.0;

                // Get the end points of finding segment 2 and compute the wall reveal point.
                UV ep3 = UV.Zero;
                UV ep4 = UV.Zero;
                wallCS.GetSegmentEndPoints(segId2, findRegionId, out ep3, out ep4);
                revealPoint = (ep3 + ep4) / 2.0;
            }

            // Create a WallSweepInfo for wall sweep
            WallSweepInfo sweepInfo = new WallSweepInfo(true, WallSweepType.Sweep);

            PrepareWallSweepInfo(sweepInfo, sweepPoint.V);
            // Set sweep profile: Sill-Precast : 8" Wide
            sweepInfo.ProfileId = GetProfile("8\" Wide").Id;
            sweepInfo.Id        = 101;
            wallCS.AddWallSweep(sweepInfo);

            // Create a WallSweepInfo for wall reveal
            WallSweepInfo revealInfo = new WallSweepInfo(true, WallSweepType.Reveal);

            PrepareWallSweepInfo(revealInfo, revealPoint.U);
            revealInfo.Id = 102;
            wallCS.AddWallSweep(revealInfo);

            // Set the new wall CompoundStructure to the type of wall.
            wallType.SetCompoundStructure(wallCS);
        }
Example #13
0
        public Result setup_wall_struct(Document doc)
        {
            WallType wallType = null;

            // FIXME : replace with the material approach?
            FilteredElementCollector wallTypes
                = new FilteredElementCollector(doc)
                  .OfClass(typeof(WallType));

            foreach (WallType wt in wallTypes)
            {
                if (wt.Name.Equals("Generic - 8\""))
                {
                    wallType = wt;
                    break;
                }
            }

            Material concrete = new FilteredElementCollector(doc)
                                .OfClass(typeof(Material))
                                .Cast <Material>().FirstOrDefault(q
                                                                  => q.Name == "Concrete, Cast-in-Place gray");

            Material insulation = new FilteredElementCollector(doc)
                                  .OfClass(typeof(Material))
                                  .Cast <Material>().FirstOrDefault(q
                                                                    => q.Name == "EIFS, Exterior Insulation");

            Material lumber = new FilteredElementCollector(doc)
                              .OfClass(typeof(Material))
                              .Cast <Material>().FirstOrDefault(q
                                                                => q.Name == "Softwood, Lumber");

            Material gypsum = new FilteredElementCollector(doc)
                              .OfClass(typeof(Material))
                              .Cast <Material>().FirstOrDefault(q
                                                                => q.Name == "Gypsum Wall Board");

            WallType newWallType = null;

            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("Basement exterior wall");

                newWallType = wallType.Duplicate("Basement") as WallType;
                // FIXME : this layer should have the "structural material" parameter set
                CompoundStructureLayer l1        = new CompoundStructureLayer(8.0 / 12, MaterialFunctionAssignment.Structure, concrete.Id);
                CompoundStructureLayer newLayer  = new CompoundStructureLayer(3.0 / 12, MaterialFunctionAssignment.Insulation, insulation.Id);
                CompoundStructureLayer newLayer2 = new CompoundStructureLayer(3.5 / 12, MaterialFunctionAssignment.Finish1, lumber.Id);
                CompoundStructureLayer newLayer3 = new CompoundStructureLayer(.5 / 12, MaterialFunctionAssignment.Finish2, gypsum.Id);

                CompoundStructure structure = newWallType.GetCompoundStructure();

                IList <CompoundStructureLayer> layers = structure.GetLayers();

                layers.Add(l1);
                layers.Add(newLayer);
                layers.Add(newLayer2);
                layers.Add(newLayer3);
                structure.SetLayers(layers);

                structure.DeleteLayer(0);

                structure.SetNumberOfShellLayers(ShellLayerType.Interior, 3);

                newWallType.SetCompoundStructure(structure);

                tx.Commit();
            }

            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("2x4 + Gypsum wall");

                newWallType = wallType.Duplicate("2x4 + Gypsum") as WallType;
                CompoundStructureLayer l1 = new CompoundStructureLayer(3.5 / 12, MaterialFunctionAssignment.Structure, lumber.Id);
                CompoundStructureLayer l2 = new CompoundStructureLayer(0.5 / 12, MaterialFunctionAssignment.Finish1, gypsum.Id);

                CompoundStructure structure = newWallType.GetCompoundStructure();

                IList <CompoundStructureLayer> layers = structure.GetLayers();

                layers.Add(l2);
                layers.Add(l1);
                layers.Add(l2);
                structure.SetLayers(layers);

                structure.DeleteLayer(0);
                structure.SetNumberOfShellLayers(ShellLayerType.Exterior, 1);
                structure.SetNumberOfShellLayers(ShellLayerType.Interior, 1);

                newWallType.SetCompoundStructure(structure);

                tx.Commit();
            }

            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("2x4 + Gypsum wall with Exterior");

                newWallType = wallType.Duplicate("2x4 + Gypsum wall with Exterior") as WallType;
                CompoundStructureLayer l1 = new CompoundStructureLayer(3.5 / 12, MaterialFunctionAssignment.Structure, lumber.Id);
                CompoundStructureLayer l2 = new CompoundStructureLayer(0.5 / 12, MaterialFunctionAssignment.Finish1, gypsum.Id);

                CompoundStructure structure = newWallType.GetCompoundStructure();

                IList <CompoundStructureLayer> layers = structure.GetLayers();

                layers.Add(l2);
                layers.Add(l1);
                layers.Add(l2);
                structure.SetLayers(layers);

                structure.DeleteLayer(0);
                structure.SetNumberOfShellLayers(ShellLayerType.Exterior, 1);
                structure.SetNumberOfShellLayers(ShellLayerType.Interior, 1);


                ElementType wallSweepType = new FilteredElementCollector(doc)
                                            .OfCategory(BuiltInCategory.OST_Cornices)
                                            .WhereElementIsElementType()
                                            .Cast <ElementType>().FirstOrDefault();

                if (wallSweepType != null)
                {
                    var wallSweepInfo = new WallSweepInfo(WallSweepType.Sweep, false);
                    wallSweepInfo.Distance = 2;

                    List <WallSweepInfo> ModSW = new List <WallSweepInfo>();
                    // structure.AddWallSweep(wallSweepInfo);
                }


                newWallType.SetCompoundStructure(structure);

                tx.Commit();
            }

            return(Result.Succeeded);
        }
Example #14
0
        /// <summary>
        /// for non deck layers this method is called and it displays minimal information
        /// about the layer
        /// </summary>
        /// <param name="layer"></param>
        private void DumpLayer(CompoundStructureLayer layer)
        {
            // Display the name of the material. More detailed material properties can
            // be found form the material object
            m_displayForm.WriteLine("Dumping Layer");
            Autodesk.Revit.DB.Material material = m_document.get_Element(layer.MaterialId) as Material;
            if (material != null)
            {
                m_displayForm.WriteLine("Layer material = " + material.Name);
            }

            // display the thickness of the layer in inches.
            m_displayForm.WriteLine("Layer Thickness = " + layer.Width.ToString());
        }
Example #15
0
        /// <summary>
        /// Dump properties specific to a decking layer
        /// </summary>
        /// <param name="deck"></param>
        private void DumbDeck(CompoundStructureLayer deck)
        {
            m_displayForm.WriteLine("Dumping Deck");

            if (deck.MaterialId != ElementId.InvalidElementId)
            {
                // get the deck material object. In this sample all we need to display is the
                // name, but other properties are readily available from the material object.
                Autodesk.Revit.DB.Material deckMaterial = m_document.get_Element(deck.MaterialId) as Material;
                m_displayForm.WriteLine("Deck Material = " + deckMaterial.Name);
            }

            if (deck.DeckProfileId != ElementId.InvalidElementId)
            {
                // the deck profile is actually a family symbol from a family of profiles
                Autodesk.Revit.DB.FamilySymbol deckProfile = m_document.get_Element(deck.DeckProfileId) as FamilySymbol;

                // firstly display the full name as the user would see it in the user interface
                // this is done in the format Family.Name and then Symbol.Name
                m_displayForm.WriteLine("Deck Profile = "
                    + deckProfile.Family.Name + " : " + deckProfile.Name);

                // the symbol object also contains parameters that describe how the deck is
                // specified. From these parameters an external application can generate
                // identical decking for analysis purposes
                DumpParameters(deckProfile);
            }
        }
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication app = commandData.Application;
            Document      doc = app.ActiveUIDocument.Document;

#if _2011
            //
            // code for the Revit 2011 API:
            //
            Debug.Assert(false,
                         "Currently, no new wall layer can be created, because"
                         + "there is no creation method available for it.");

            foreach (WallType wallType in doc.WallTypes)
            {
                if (0 < wallType.CompoundStructure.Layers.Size)
                {
                    CompoundStructureLayer oldLayer
                        = wallType.CompoundStructure.Layers.get_Item(0);

                    WallType newWallType
                        = wallType.Duplicate("NewWallType") as WallType;

                    CompoundStructure structure
                        = newWallType.CompoundStructure;

                    CompoundStructureLayerArray layers
                        = structure.Layers;


                    // from here on, nothing works, as expected:
                    // in the Revir 2010 API, we could call the constructor
                    // even though it is for internal use only.
                    // in 2011, it is not possible to call it either.

                    CompoundStructureLayer newLayer = null;
                    //  = new CompoundStructureLayer(); // for internal use only

                    newLayer.DeckProfile = oldLayer.DeckProfile;
                    //newLayer.DeckUsage = oldLayer.DeckUsage; // read-only
                    //newLayer.Function = oldLayer.Function; // read-only
                    newLayer.Material  = oldLayer.Material;
                    newLayer.Thickness = oldLayer.Thickness;
                    newLayer.Variable  = oldLayer.Variable;
                    layers.Append(newLayer);
                }
            }
#endif // _2011

            //WallTypeSet wallTypes = doc.WallTypes; // 2013

            FilteredElementCollector wallTypes
                = new FilteredElementCollector(doc)
                  .OfClass(typeof(WallType)); // 2014

            foreach (WallType wallType in wallTypes)
            {
                if (0 < wallType.GetCompoundStructure().GetLayers().Count)
                {
                    CompoundStructureLayer oldLayer
                        = wallType.GetCompoundStructure().GetLayers()[0];

                    WallType newWallType
                        = wallType.Duplicate("NewWallType") as WallType;

                    CompoundStructure structure
                        = newWallType.GetCompoundStructure();

                    IList <CompoundStructureLayer> layers
                        = structure.GetLayers();

                    // in Revit 2012, we can create a new layer:

                    double width = 0.1;
                    MaterialFunctionAssignment function = oldLayer.Function;
                    ElementId materialId = oldLayer.MaterialId;

                    CompoundStructureLayer newLayer
                        = new CompoundStructureLayer(width, function, materialId);

                    layers.Add(newLayer);
                    structure.SetLayers(layers);
                    newWallType.SetCompoundStructure(structure);
                }
            }
            return(Result.Succeeded);
        }
Example #17
0
        /// <summary>
        /// Create vertical CompoundStructure for wall: new layers, split new region, new sweep and new reveal.
        /// </summary>
        /// <param name="wall">The wall applying the new CompoundStructure.</param>
        public void CreateCSforWall(Wall wall)
        {
            // Get CompoundStructure
            CompoundStructure wallCS = wall.WallType.GetCompoundStructure();

            // Get material for CompoundStructureLayer
            Material masonry_Brick = GetMaterial("Masonry - Brick");
            Material concrete = GetMaterial("Concrete");

            // Create CompoundStructureLayers
            List<CompoundStructureLayer> csLayers = new List<CompoundStructureLayer>();
            CompoundStructureLayer finish1Layer = new CompoundStructureLayer(0.2, MaterialFunctionAssignment.Finish1, masonry_Brick.Id);
            CompoundStructureLayer substrateLayer = new CompoundStructureLayer(0.1, MaterialFunctionAssignment.Substrate, ElementId.InvalidElementId);
            CompoundStructureLayer structureLayer = new CompoundStructureLayer(0.5, MaterialFunctionAssignment.Structure, concrete.Id);
            CompoundStructureLayer membraneLayer = new CompoundStructureLayer(0, MaterialFunctionAssignment.Membrane, ElementId.InvalidElementId);
            CompoundStructureLayer finish2Layer = new CompoundStructureLayer(0.2, MaterialFunctionAssignment.Finish2, masonry_Brick.Id);
            csLayers.Add(finish1Layer);
            csLayers.Add(substrateLayer);
            csLayers.Add(structureLayer);
            csLayers.Add(membraneLayer);
            csLayers.Add(finish2Layer);

            // Set the created layers to CompoundStructureLayer
            wallCS.SetLayers(csLayers);

            // Set shell layers and wrapping.
            wallCS.SetNumberOfShellLayers(ShellLayerType.Interior, 2);
            wallCS.SetNumberOfShellLayers(ShellLayerType.Exterior, 1);
            wallCS.SetParticipatesInWrapping(0, false);

            // Points for adding wall sweep and reveal.
            UV sweepPoint = UV.Zero;
            UV revealPoint = UV.Zero;

            // split the region containing segment 0.
            int segId = wallCS.GetSegmentIds()[0];
            foreach (int regionId in wallCS.GetAdjacentRegions(segId))
            {
                // Get the end points of segment 0.
                UV endPoint1 = UV.Zero;
                UV endPoint2 = UV.Zero;
                wallCS.GetSegmentEndPoints(segId, regionId, out endPoint1, out endPoint2);

                // Split a new region in splited point and orientation.
                RectangularGridSegmentOrientation splitOrientation = (RectangularGridSegmentOrientation)(((int)(wallCS.GetSegmentOrientation(segId)) + 1) % 2);
                UV splitUV = (endPoint1 + endPoint2) / 2.0;
                int newRegionId = wallCS.SplitRegion(splitUV, splitOrientation);
                bool isValidRegionId = wallCS.IsValidRegionId(newRegionId);

                // Find the enclosing region and the two segments intersected by a line through the split point
                int segId1;
                int segId2;
                int findRegionId = wallCS.FindEnclosingRegionAndSegments(splitUV, splitOrientation, out segId1, out segId2);

                // Get the end points of finding segment 1 and compute the wall sweep point.
                UV eP1 = UV.Zero;
                UV eP2 = UV.Zero;
                wallCS.GetSegmentEndPoints(segId1, findRegionId, out eP1, out eP2);
                sweepPoint = (eP1 + eP2) / 4.0;

                // Get the end points of finding segment 2 and compute the wall reveal point.
                UV ep3 = UV.Zero;
                UV ep4 = UV.Zero;
                wallCS.GetSegmentEndPoints(segId2, findRegionId, out ep3, out ep4);
                revealPoint = (ep3 + ep4) / 2.0;
            }

            // Create a WallSweepInfo for wall sweep
            WallSweepInfo sweepInfo = new WallSweepInfo(true, WallSweepType.Sweep);
            PrepareWallSweepInfo(sweepInfo, sweepPoint.V);
            // Set sweep profile: Sill-Precast : 8" Wide
            sweepInfo.ProfileId = GetProfile("8\" Wide").Id;
            sweepInfo.Id = 101;
            wallCS.AddWallSweep(sweepInfo);

            // Create a WallSweepInfo for wall reveal
            WallSweepInfo revealInfo = new WallSweepInfo(true, WallSweepType.Reveal);
            PrepareWallSweepInfo(revealInfo, revealPoint.U);
            revealInfo.Id = 102;
            wallCS.AddWallSweep(revealInfo);

            // Set the new wall CompoundStructure to the type of wall.
            wall.WallType.SetCompoundStructure(wallCS);
        }
Example #18
0
        public void createWall()
        {
            try
            {
                //Wall.Create(Document document, Curve curve, ElementId wallTypeId, ElementId levelId, double wallHeight, double wallOffset, bool flip, bool structural)
                WallType yeniWallType = null;
                bool     bulundu      = false;
                FilteredElementCollector wallTypes = new FilteredElementCollector(doc).OfClass(typeof(WallType));
                ElementId defaultElementTypeId     = doc.GetDefaultElementTypeId(ElementTypeGroup.WallType);
                #region Informatik isimli duvar tipini ara, yoksa yarat
                foreach (WallType wt in wallTypes)
                {
                    if (wt.Name == "Informatik")
                    {
                        informatikWallId = wt.Id;
                        bulundu          = true;
                        break;
                    }
                }
                if (bulundu == false)
                {
                    foreach (WallType wt in wallTypes)
                    {
                        if (wt.Id == defaultElementTypeId)
                        {
                            using (Transaction transaction = new Transaction(doc, "DuplicateWallType"))
                            {
                                transaction.Start();
                                yeniWallType = wt.Duplicate("Informatik") as WallType;
                                CompoundStructure cs                   = yeniWallType.GetCompoundStructure();
                                ElementId         materialId           = new ElementId(539);
                                IList <CompoundStructureLayer> cslList = new List <CompoundStructureLayer>();
                                CompoundStructureLayer         csl     = new CompoundStructureLayer(20 * mmToFeet, MaterialFunctionAssignment.Finish1, materialId);
                                cslList.Add(csl);
                                csl = new CompoundStructureLayer(160 * mmToFeet, MaterialFunctionAssignment.Structure, materialId);
                                cslList.Add(csl);
                                csl = new CompoundStructureLayer(20 * mmToFeet, MaterialFunctionAssignment.Finish2, materialId);
                                cslList.Add(csl);
                                CompoundStructure yeniStructure = CompoundStructure.CreateSimpleCompoundStructure(cslList);
                                yeniWallType.SetCompoundStructure(yeniStructure);
                                doc.SetDefaultElementTypeId(ElementTypeGroup.WallType, yeniWallType.Id);
                                transaction.Commit();
                                informatikWallId = yeniWallType.Id;
                            }
                            break;
                        }
                    }
                }
                #endregion
                #region levelId bul
                List <Level>             levels = new List <Level>();
                FilteredElementCollector filteredLevelCollector = new FilteredElementCollector(doc);
                filteredLevelCollector.OfClass(typeof(Level));
                levels = filteredLevelCollector.Cast <Level>().ToList();
                ElementId levelId = null;
                foreach (Level l in levels)
                {
                    if (l.Name == "Level 0")
                    {
                        levelId = l.Id;
                        break;
                    }
                }
                #endregion
                #region cizgileri seçtirt
                uiApp.ActiveUIDocument.Selection.GetElementIds().Clear();
                ISelectionFilter selFilter = new ModelLineSelectionFilter();
                this.Hide();
                IList <Reference> curves = uiApp.ActiveUIDocument.Selection.PickObjects(ObjectType.Element, selFilter, "Select path Curve(s) for partition wall");
                this.Show();
                #endregion
                #region set computing options
                Options opt = new Options();
                opt.ComputeReferences        = true;
                opt.IncludeNonVisibleObjects = true;
                opt.View = doc.ActiveView;

                #endregion
                #region duvar yüksekliği ve offsetini belirle
                double wallHeight = 3000 * mmToFeet;
                double wallOffset = 0;
                #endregion
                List <Wall> yeniDuvarlar = new List <Wall>();
                if (curves.Count > 0)
                {
                    #region döngü
                    for (int i = 0; i < curves.Count; i++)
                    {
                        XYZ  globalPoint;
                        Wall yeniDuvar = null;
                        globalPoint = curves[i].GlobalPoint;
                        Element tempCurve = doc.GetElement(curves[i]) as Element;
                        Curve   curve     = null;
                        if (tempCurve != null)
                        {
                            #region element geometrisinden Curve bulunabiliyor mu
                            foreach (var geoObj in tempCurve.get_Geometry(opt))
                            {
                                Curve cv = geoObj as Curve;
                                if (cv != null)
                                {
                                    curve = cv;
                                    break;
                                }
                            }
                            #endregion
                            #region duvar üret
                            if (curve != null)
                            {
                                using (Transaction wallCreate = new Transaction(doc, "Duvar Yarat"))
                                {
                                    wallCreate.Start();
                                    yeniDuvar = Wall.Create(doc, curve, informatikWallId, levelId, wallHeight, wallOffset, false, false);
                                    if (yeniDuvar != null)
                                    {
                                        yeniDuvarlar.Add(yeniDuvar);
                                    }
                                    wallCreate.Commit();
                                }
                            }
                            #endregion
                        }
                    }
                    #endregion
                    //BuiltInParameter myParameter = BuiltInParameter.DIVIDED_SURFACE_DISPLAY_ORIGINAL_SURFACE;
                    //Element myElement = yeniDuvar as Element;
                    //myElement.get_Parameter(myParameter).Set();
                    #region parametreleri kontrol et
                    if (yeniDuvarlar.Count > 0)
                    {
                        Wall yeniDuvar = yeniDuvarlar[0];

                        string s = string.Empty;
                        foreach (Parameter p in yeniDuvar.Parameters)
                        {
                            s += "Name=" + p.Definition.Name + " StorageType=" + p.StorageType.ToString() + "\r\n";
                        }
                        MessageBox.Show(s);
                    }
                    #endregion
                }
                if (curves.Count < 1)
                {
                    TaskDialog.Show("Seçilmedi", "En az bir çizgi seçmelisiniz");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication app = commandData.Application;
              Document doc = app.ActiveUIDocument.Document;

            #if _2011
              //
              // code for the Revit 2011 API:
              //
              Debug.Assert( false,
            "Currently, no new wall layer can be created, because"
            + "there is no creation method available for it." );

              foreach( WallType wallType in doc.WallTypes )
              {
            if( 0 < wallType.CompoundStructure.Layers.Size )
            {
              CompoundStructureLayer oldLayer
            = wallType.CompoundStructure.Layers.get_Item( 0 );

              WallType newWallType
            = wallType.Duplicate( "NewWallType" ) as WallType;

              CompoundStructure structure
            = newWallType.CompoundStructure;

              CompoundStructureLayerArray layers
            = structure.Layers;

              // from here on, nothing works, as expected:
              // in the Revir 2010 API, we could call the constructor
              // even though it is for internal use only.
              // in 2011, it is not possible to call it either.

              CompoundStructureLayer newLayer = null;
              //  = new CompoundStructureLayer(); // for internal use only

              newLayer.DeckProfile = oldLayer.DeckProfile;
              //newLayer.DeckUsage = oldLayer.DeckUsage; // read-only
              //newLayer.Function = oldLayer.Function; // read-only
              newLayer.Material = oldLayer.Material;
              newLayer.Thickness = oldLayer.Thickness;
              newLayer.Variable = oldLayer.Variable;
              layers.Append( newLayer );

            }
              }
            #endif // _2011

              using ( Transaction t = new Transaction( doc ) )
              {
            t.Start( "Create New Wall Layer" );

            //WallTypeSet wallTypes = doc.WallTypes; // 2013

            FilteredElementCollector wallTypes
              = new FilteredElementCollector( doc )
            .OfClass( typeof( WallType ) ); // 2014

            foreach ( WallType wallType in wallTypes )
            {
              if ( 0 < wallType.GetCompoundStructure().GetLayers().Count )
              {
            CompoundStructureLayer oldLayer
              = wallType.GetCompoundStructure().GetLayers()[0];

            WallType newWallType
              = wallType.Duplicate( "NewWallType" ) as WallType;

            CompoundStructure structure
              = newWallType.GetCompoundStructure();

            IList<CompoundStructureLayer> layers
              = structure.GetLayers();

            // in Revit 2012, we can create a new layer:

            double width = 0.1;
            MaterialFunctionAssignment function = oldLayer.Function;
            ElementId materialId = oldLayer.MaterialId;

            CompoundStructureLayer newLayer
              = new CompoundStructureLayer( width, function, materialId );

            layers.Add( newLayer );
            structure.SetLayers( layers );
            newWallType.SetCompoundStructure( structure );
              }
            }
            t.Commit();
              }
              return Result.Succeeded;
        }