Exemplo n.º 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));
        }
Exemplo n.º 2
0
        public RevitCSLayer CreateCompoundStructureLayer(
            [DefaultArgument("Synthetic.Revit.Document.Current()")] RevitDoc Document)
        {
            RevitCSLayer layer = new RevitCSLayer();

            layer.DeckEmbeddingType =
                (RevitDB.StructDeckEmbeddingType)
                Enum.Parse(
                    typeof(RevitDB.StructDeckEmbeddingType),
                    this.DeckEmbeddingType);

            RevitDB.Element deck = this.DeckProfileId.GetElem(Document);
            if (deck != null)
            {
                layer.DeckProfileId = deck.Id;
            }

            layer.Function =
                (RevitDB.MaterialFunctionAssignment)
                Enum.Parse(
                    typeof(RevitDB.MaterialFunctionAssignment),
                    this.Function);

            layer.LayerCapFlag = this.LayerCapFlag;

            RevitDB.Material mat = (RevitDB.Material) this.MaterialId.GetElem(Document);
            if (mat != null)
            {
                layer.MaterialId = mat.Id;
            }

            layer.Width = this.Width;

            return(layer);
        }
Exemplo n.º 3
0
 public SerialCompoundStructureLayer(RevitCSLayer Layer,
                                     [DefaultArgument("Synthetic.Revit.Document.Current()")] RevitDoc Document)
 {
     this.MaterialId        = new SerialElementId(Layer.MaterialId, Document);
     this.Function          = Layer.Function.ToString();
     this.Width             = Layer.Width;
     this.DeckEmbeddingType = Layer.DeckEmbeddingType.ToString();
     this.DeckProfileId     = new SerialElementId(Layer.DeckProfileId, Document);
     this.LayerCapFlag      = Layer.LayerCapFlag;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Returns the properties of a Autodesk.Revit.DB.CompoundStructureLayer as a dictionary.
        /// </summary>
        /// <param name="layer">Autodesk.Revit.DB.CompoundStructureLayer</param>
        /// <param name="doc">Autodesk.Revit.DB.Document</param>
        /// <returns></returns>
        internal static cg.Dictionary <string, object> _RevitLayerToDictionary(revitCSLayer layer, revitDoc doc)
        {
            double width = layer.Width;

            revitDB.MaterialFunctionAssignment layerFunction = layer.Function;
            revitDB.Material material = (revitDB.Material)doc.GetElement(layer.MaterialId);
            return(new cg.Dictionary <string, object>
            {
                { "Width", width },
                { "Layer Function", layerFunction },
                { "Material", material }
            });
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new layer at the specified index in the CompoundStructure.
        /// </summary>
        /// <param name="compoundStructure">The CompoundStructure to modify.</param>
        /// <param name="layerIndex">Index of the layer to be inserted.</param>
        /// <param name="width">Width of the layer.</param>
        /// <param name="layerFunction">Autodesk.Revit.DB.MaterialFunctionAssignment enumeration of the layer.</param>
        /// <param name="material">Autodesk.Revit.DB.Materials of the layer.  Dynamo wrapped Revit.Material objects will not work.</param>
        /// <returns name="compoundStructure">The modified CompoundStructure.</returns>
        public static CompoundStructure InsertLayerAtIndex(CompoundStructure compoundStructure,
                                                           int layerIndex,
                                                           double width,
                                                           revitDB.MaterialFunctionAssignment layerFunction,
                                                           revitDB.Material material)
        {
            revitCSLayer layer = new revitCSLayer(width, layerFunction, material.Id);

            cg.IList <revitCSLayer> layers = compoundStructure.internalCompoundStructure.GetLayers();
            layers.Insert(layerIndex, layer);

            compoundStructure.internalCompoundStructure.SetLayers(layers);
            return(compoundStructure);
        }
Exemplo n.º 6
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));
        }
        protected override void TrySolveInstance(IGH_DataAccess DA)
        {
            // get input
            Types.DataObject <DB.CompoundStructureLayer> dataObj = default;
            if (!DA.GetData("Compound Structure Layer", ref dataObj))
            {
                return;
            }

            DB.CompoundStructureLayer cslayer = dataObj.Value;

            // Deconstruct the data object into output params
            DA.SetData("Layer Id", cslayer.LayerId);
            DA.SetData("Layer Function", new Types.LayerFunction(cslayer.Function));
            DA.SetData("Layer Width", cslayer.Width);
            DA.SetData("Layer Cap Flag", cslayer.LayerCapFlag);
            DA.SetData("Layer Material", Types.Element.FromElement(dataObj.Document.GetElement(cslayer.MaterialId)));
            DA.SetData("Deck Profile", Types.Element.FromElement(dataObj.Document.GetElement(cslayer.DeckProfileId)));
            DA.SetData("Deck Embedding Type", new Types.DeckEmbeddingType(cslayer.DeckEmbeddingType));
        }
Exemplo n.º 8
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));
        }
Exemplo n.º 9
0
 public static IDictionary CompoundStructureLayerToList(revitCSLayer compoundStructureLayer,
                                                        [DefaultArgument("Synthetic.Revit.Document.Current()")] revitDoc document)
 {
     return(_RevitLayerToDictionary(compoundStructureLayer, document));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Retrives the properties of a Autodesk.Revit.DB.CompoundStructureLayer element.
 /// </summary>
 /// <param name="compoundStructureLayer">A CompoundStructureLayer</param>
 /// <param name="document">An unwrapped document associated with the CompoundStructure.</param>
 /// <returns name="dict">A dictionary element containing the layer properties.  Note that the layers are dictionaries and properties can be retrieved using the keys "Width", "Layer Function", and "Material".</returns>
 public static synthDict CompoundStructureLayerToDictionary(revitCSLayer compoundStructureLayer,
                                                            [DefaultArgument("Synthetic.Revit.Document.Current()")] revitDoc document)
 {
     return(synthDict.Wrap((cg.Dictionary <string, object>)_RevitLayerToDictionary(compoundStructureLayer, document)));
 }