コード例 #1
0
        /// <summary>
        /// Creates a compound structure from a list of dictionary layer properties.
        /// </summary>
        /// <param name="layers">A list of dictionary objects with layer properties.</param>
        /// <param name="document">An unwrapped document associated with the CompoundStructure.</param>
        /// <returns name="compoundStructure">A Compound Structure.</returns>
        public static CompoundStructure ByLayerDictionary(cg.IList <cg.Dictionary <string, object> > layers,
                                                          [DefaultArgument("Synthetic.Revit.Document.Current()")] revitDoc document)
        {
            cg.List <revitCSLayer> layerList = new cg.List <revitCSLayer>();

            foreach (cg.Dictionary <string, object> layerDict in layers)
            {
                revitDB.Material material = (revitDB.Material)layerDict["Material"];
                revitCSLayer     layer    = new revitCSLayer((double)layerDict["Width"], (revitDB.MaterialFunctionAssignment)layerDict["Layer Function"], material.Id);
                layerList.Add(layer);
            }

            //return new CompoundStructure(revitCS.CreateSimpleCompoundStructure(layerList), document);
            return(new CompoundStructure(layerList, document));
        }
コード例 #2
0
        /// <summary>
        /// Creates a Synthetic.Revit.CompoundStructure given lists of layer properties.  Please note that layers will only be made with the shortest number of complete layer properties.  For example if five widths and layer functions are provided but only four materials, only four layers will be created.
        /// </summary>
        /// <param name="width">List with the width of each layer.</param>
        /// <param name="layerFunction">List with the Autodesk.Revit.DB.MaterialFunctionAssignment enumerations for each layer.</param>
        /// <param name="material">List of Autodesk.Revit.DB.Materials for each layer.  Dynamo wrapped Revit.Material objects will not work.</param>
        /// <param name="document">An unwrapped document associated with the CompoundStructure.</param>
        /// <returns name="compoundStructure">A Compound Structure.</returns>
        public static CompoundStructure ByLayerProperties(cg.IList <double> width,
                                                          cg.IList <revitDB.MaterialFunctionAssignment> layerFunction,
                                                          cg.IList <revitDB.Material> material,
                                                          [DefaultArgument("Synthetic.Revit.Document.Current()")] revitDoc document)
        {
            cg.List <int> lenList = new cg.List <int>();
            lenList.Add(layerFunction.Count);
            lenList.Add(width.Count);
            lenList.Add(material.Count);

            int l = lenList.Min();

            cg.List <revitCSLayer> layerList = new cg.List <revitCSLayer>();

            for (int i = 0; i < l; i++)
            {
                revitCSLayer layer = new revitCSLayer(width[i], layerFunction[i], material[i].Id);
                layerList.Add(layer);
            }

            //return new CompoundStructure(revitCS.CreateSimpleCompoundStructure(layerList), document);
            return(new CompoundStructure(layerList, document));
        }