Пример #1
0
        /// <summary>
        /// Creates Synthetic.Revit.CompoundStructure in a destination document by changing the material ids to correspond to materials in the destination document.  Materials not in the destination document are copied into the document.
        /// </summary>
        /// <param name="compoundStructure">A Synthetic.Revit.CompoundStructure from the source document</param>
        /// <param name="destinationDoc">The document to copy the CompoundStructure into.</param>
        /// <returns name="compoundStructure">A Synthetic.Revit.CompoundStructure in the destination document.</returns>
        internal static CompoundStructure _CopyToDocument(CompoundStructure compoundStructure, revitDoc destinationDoc)
        {
            revitDoc doc = compoundStructure.internalDocument;

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

            foreach (revitCSLayer sourceLayer in compoundStructure.internalCompoundStructure.GetLayers())
            {
                revitCSLayer destintationLayer = sourceLayer;

                revitDB.Material sourceMaterial      = (revitDB.Material)doc.GetElement(sourceLayer.MaterialId);
                revitDB.Material destinationMaterial = Select.GetMaterialByName(Select.AllMaterials(destinationDoc), sourceMaterial.Name);

                if (destinationMaterial == null)
                {
                    cg.List <int> sourceMaterialIds = new cg.List <int>();
                    sourceMaterialIds.Add(sourceMaterial.Id.IntegerValue);
                    cg.List <revitDB.ElementId> destinationElemIds = Elements.CopyElements(compoundStructure.internalDocument, sourceMaterialIds, destinationDoc);
                    //destinationMaterial = Select.GetMaterialByName(Select.AllMaterials(destinationDoc), sourceMaterial.Name);
                    destintationLayer.MaterialId = destinationElemIds[0];
                }
                else
                {
                    destintationLayer.MaterialId = destinationMaterial.Id;
                }

                destinationLayers.Add(destintationLayer);
            }

            return(new CompoundStructure(destinationLayers, destinationDoc));
        }
Пример #2
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));
        }
Пример #3
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));
        }
Пример #4
0
 /// <summary>
 /// Creates a Autodesk.Revit.DB.CompoundStructure given a list of Autodesk.Revit.DB.CompoundStructureLayer elements
 /// </summary>
 /// <param name="layers">A list of CompoundStructureLayer elements</param>
 /// <param name="doc">Autodesk.Revit.DB.Document</param>
 /// <returns name="RevitCompoundStructure">A Autodesk.Revit.DB.CompoundStructure</returns>
 internal CompoundStructure(cg.List <revitCSLayer> layers, revitDoc doc)
 {
     internalCompoundStructure = revitCS.CreateSimpleCompoundStructure(layers);
     internalDocument          = doc;
 }
Пример #5
0
 /// <summary>
 /// Creates a CompoundStructure from a list of Autodesk.Revit.DB.CompoundStructureLayer elements.
 /// </summary>
 /// <param name="layers">A list of Autodesk.Revit.DB.CompoundStructureLayer elements.</param>
 /// <param name="document">An unwrapped document associated with the CompoundStructure.</param>
 /// <returns name="compoundStructure">A Compound Structure.</returns>
 public static CompoundStructure ByCompoundStructureLayers(cg.List <revitCSLayer> layers,
                                                           [DefaultArgument("Synthetic.Revit.Document.Current()")] revitDoc document)
 {
     //return new CompoundStructure(revitCS.CreateSimpleCompoundStructure(layers), document);
     return(new CompoundStructure(layers, document));
 }