Example #1
0
        /// <summary>
        /// Retrieves the Autodesk.Revit.DB.Material of the layer at the specified index.
        /// </summary>
        /// <param name="compoundStructure">A CompoundStructure</param>
        /// <param name="layerIndex">Index of the layer</param>
        /// <returns name="material">The material of the layer as a Autodesk.Revit.DB.Material, not a Dynamo wrapped Revit.Material.</returns>
        public static revitDB.Material GetLayerMaterial(CompoundStructure compoundStructure, int layerIndex)
        {
            revitDoc doc = compoundStructure.internalDocument;

            revitDB.ElementId materialId = compoundStructure.internalCompoundStructure.GetMaterialId(layerIndex);
            return((revitDB.Material)doc.GetElement(materialId));
        }
Example #2
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));
        }
Example #3
0
 /// <summary>
 /// Sets the Autodesk.Revit.DB.MaterialFunctionAssignment of the layer at the specified index.
 /// </summary>
 /// <param name="compoundStructure">A CompoundStructure</param>
 /// <param name="layerIndex">Index of the layer</param>
 /// <param name="layerFunction">The material function of the layer</param>
 /// <returns name="compoundStructure">The modifed CompoundStructure</returns>
 public static CompoundStructure SetLayerFunction(CompoundStructure compoundStructure,
                                                  int layerIndex,
                                                  revitDB.MaterialFunctionAssignment layerFunction)
 {
     compoundStructure.internalCompoundStructure.SetLayerFunction(layerIndex, layerFunction);
     return(compoundStructure);
 }
Example #4
0
 /// <summary>
 /// Sets the number of layers that will be exterior of the core.
 /// </summary>
 /// <param name="compoundStructure">A CompoundStructure</param>
 /// <param name="numLayers">Number of interior layers</param>
 /// <returns name="compoundStructure">The modifed CompoundStructure</returns>
 public static CompoundStructure SetNumberOfInteriorLayers(CompoundStructure compoundStructure, int numLayers)
 {
     using (Autodesk.Revit.DB.Transaction trans = new Autodesk.Revit.DB.Transaction(compoundStructure.internalDocument))
     {
         compoundStructure.internalLastCoreLayerIndex = numLayers;
     }
     return(compoundStructure);
 }
Example #5
0
 /// <summary>
 /// Sets the properties of a 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 modified.</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 SetLayer(CompoundStructure compoundStructure,
                                          int layerIndex,
                                          double width,
                                          revitDB.MaterialFunctionAssignment layerFunction,
                                          revitDB.Material material)
 {
     CompoundStructure.SetLayerWidth(compoundStructure, layerIndex, width);
     CompoundStructure.SetLayerFunction(compoundStructure, layerIndex, layerFunction);
     CompoundStructure.SetLayerMaterial(compoundStructure, layerIndex, material);
     return(compoundStructure);
 }
Example #6
0
        /// <summary>
        /// Removes a layer at the specified index in the CompoudStructure.
        /// </summary>
        /// <param name="compoundStructure">The CompoundStructure to modify.</param>
        /// <param name="layerIndex">Index of the layer to be deleted.</param>
        /// <returns name="compoundStructure">The modified CompoundStructure.</returns>
        public static CompoundStructure DeleteLayer(CompoundStructure compoundStructure, int layerIndex)
        {
            bool result = compoundStructure.internalCompoundStructure.DeleteLayer(layerIndex);

            if (result == true)
            {
                return(compoundStructure);
            }
            else
            {
                return(null);
            }
        }
Example #7
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);
        }
Example #8
0
        /// <summary>
        /// Replaces a Wall Type's compound structure with the given one.  Please note that the compound structure's materials and the wall type must be in the same document or unexpected results may occur.
        /// </summary>
        /// <param name="WallType">The wall type to be modified.</param>
        /// <param name="compoundStructure">A compound structure</param>
        /// <returns name="WallType">The modified wall type.</returns>
        public static dynaWallType SetCompoundStructure(dynaWallType WallType, CompoundStructure compoundStructure)
        {
            revitDB.WallType revitWallType = (revitDB.WallType)WallType.InternalElement;
            revitDoc         document      = compoundStructure.internalDocument;

            if (document.IsModifiable)
            {
                TransactionManager.Instance.EnsureInTransaction(document);
                revitWallType.SetCompoundStructure(compoundStructure.internalCompoundStructure);
                TransactionManager.Instance.TransactionTaskDone();
            }
            else
            {
                using (Autodesk.Revit.DB.Transaction trans = new Autodesk.Revit.DB.Transaction(document))
                {
                    trans.Start("Apply Structure to Wall Type");
                    revitWallType.SetCompoundStructure(compoundStructure.internalCompoundStructure);
                    trans.Commit();
                }
            }
            return(WallType);
        }
Example #9
0
 /// <summary>
 /// Sets the material of the layer at the specified index.
 /// </summary>
 /// <param name="compoundStructure">A CompoundStructure</param>
 /// <param name="layerIndex">Index of the layer</param>
 /// <param name="materialId">The Element ID of the material of the layer.</param>
 /// <returns name="compoundStructure">The modifed CompoundStructure</returns>
 public static CompoundStructure SetLayerMaterialId(CompoundStructure compoundStructure, int layerIndex, int materialId)
 {
     compoundStructure.internalCompoundStructure.SetMaterialId(layerIndex, new revitDB.ElementId(materialId));
     return(compoundStructure);
 }
Example #10
0
 /// <summary>
 /// Sets the material of the layer at the specified index.
 /// </summary>
 /// <param name="compoundStructure">A CompoundStructure</param>
 /// <param name="layerIndex">Index of the layer</param>
 /// <param name="material">A Autodesk.Revit.DB.Material element for the layer.  A Dynamo wrapped Revit.Material element will not work.</param>
 /// <returns name="compoundStructure">The modifed CompoundStructure</returns>
 public static CompoundStructure SetLayerMaterial(CompoundStructure compoundStructure, int layerIndex, revitDB.Material material)
 {
     compoundStructure.internalCompoundStructure.SetMaterialId(layerIndex, material.Id);
     return(compoundStructure);
 }
Example #11
0
 /// <summary>
 /// Sets the width of the layer at the specified index.
 /// </summary>
 /// <param name="compoundStructure">A CompoundStructure</param>
 /// <param name="layerIndex">Index of the layer</param>
 /// <param name="width">Width of the layer</param>
 /// <returns name="compoundStructure">The modifed CompoundStructure</returns>
 public static CompoundStructure SetLayerWidth(CompoundStructure compoundStructure, int layerIndex, double width)
 {
     compoundStructure.internalCompoundStructure.SetLayerWidth(layerIndex, width);
     return(compoundStructure);
 }
Example #12
0
 /// <summary>
 /// Retrieves the index value of the most interior core layer.
 /// </summary>
 /// <param name="compoundStructure">A CompoundStructure</param>
 /// <returns name="index">List index</returns>
 public static int GetLastCoreLayerIndex(CompoundStructure compoundStructure)
 {
     return(compoundStructure.internalLastCoreLayerIndex);
 }
Example #13
0
 /// <summary>
 /// Sets the layers for the CompoundStructure with a list of Autodesk.Revit.DB.CompoundStructureLayer elements from the CompoundStructure.  For use with python or other methods for using the Revit API directly.
 /// </summary>
 /// <param name="compoundStructure">A CompoundStructure</param>
 /// <param name="compoundStructureLayers">A list of Autodesk.Revit.DB.CompoundStructureLayer elements</param>
 /// <returns name="compoundStructure">The modified CompoundStructure</returns>
 public static CompoundStructure SetCompoundStructureLayers(CompoundStructure compoundStructure, cg.IList <revitCSLayer> compoundStructureLayers)
 {
     compoundStructure.internalCompoundStructure.SetLayers(compoundStructureLayers);
     return(compoundStructure);
 }
Example #14
0
 /// <summary>
 /// Retrieves the Autodesk.Revit.DB.MaterialFunctionAssignment of the layer at the specified index.
 /// </summary>
 /// <param name="compoundStructure">A CompoundStructure</param>
 /// <param name="layerIndex">Index of the layer</param>
 /// <returns name="layerFunction">The material function of the layer</returns>
 public static revitDB.MaterialFunctionAssignment GetLayerFunction(CompoundStructure compoundStructure,
                                                                   int layerIndex)
 {
     return(compoundStructure.internalCompoundStructure.GetLayerFunction(layerIndex));
 }
Example #15
0
 /// <summary>
 /// Retrieves the width of a layer at the specified index.
 /// </summary>
 /// <param name="compoundStructure">A CompoundStructure</param>
 /// <param name="layerIndex">Index of the layer</param>
 /// <returns name="Width">Width of the layer</returns>
 public static double GetLayerWidth(CompoundStructure compoundStructure, int layerIndex)
 {
     return(compoundStructure.internalCompoundStructure.GetLayerWidth(layerIndex));
 }
Example #16
0
 /// <summary>
 /// Retrieves a list of the properties of the layers in the CompoundStructure.
 /// </summary>
 /// <param name="compoundStructure">A CompoundStructure</param>
 /// <returns name="layers">A list of properties for each layer.  Note that the layers are dictionaries and properties can be retrieved using the keys "Width", "Layer Function", and "Material".</returns>
 public static cg.IList <cg.Dictionary <string, object> > GetLayers(CompoundStructure compoundStructure)
 {
     return(compoundStructure.internalLayers);
 }
Example #17
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="destinationDocument">The document to copy the CompoundStructure into.</param>
 /// <returns name="compoundStructure">A Synthetic.Revit.CompoundStructure in the destination document.</returns>
 public static CompoundStructure CopyToDocument(CompoundStructure compoundStructure, revitDoc destinationDocument)
 {
     return(_CopyToDocument(compoundStructure, destinationDocument));
 }
Example #18
0
 /// <summary>
 /// Retrieves the Autodesk.Revit.DB.CompoundStructureLayer elements from the CompoundStructure.  For use with python or other methods for using the Revit API directly.
 /// </summary>
 /// <param name="compoundStructure">A CompoundStructure</param>
 /// <returns name="CompoundStructureLayers">A list of CompoundStructureLayer elements</returns>
 public static cg.IList <revitCSLayer> GetCompoundStructureLayers(CompoundStructure compoundStructure)
 {
     return(compoundStructure.internalCompoundStructure.GetLayers());
 }
Example #19
0
 /// <summary>
 /// Retrieves the Autodesk.Revit.DB.CompoundStructure from a Synthetic.Revit.CompoundStructure object.  This is useful for using CompoundStructures in python scripts or other methods of accessing the Revit API directly.
 /// </summary>
 /// <param name="compoundStructure">An Synthetic.Revit.CompoundStructure</param>
 /// <returns name="Unwrapped">Autodesk.Revit.DB.CompoundStructure</returns>
 public static revitCS UnwrapCompoundStructure(CompoundStructure compoundStructure)
 {
     return(compoundStructure.internalCompoundStructure);
 }
Example #20
0
 /// <summary>
 /// Retrieves the material ID of the material for the layer at the specified index.
 /// </summary>
 /// <param name="compoundStructure">A CompoundStructure</param>
 /// <param name="layerIndex">Index of the layer</param>
 /// <returns name="materialId">The Element ID of the material for the layer.</returns>
 public static int GetLayerMaterialId(CompoundStructure compoundStructure, int layerIndex)
 {
     return(compoundStructure.internalCompoundStructure.GetMaterialId(layerIndex).IntegerValue);
 }
Example #21
0
        /// <summary>
        /// Replaces a Wall Type's compound structure with the given one.  Please note that the compound structure's materials and the wall type must be in the same document or unexpected results may occur.
        /// </summary>
        /// <param name="WallType">The wall type to be modified.</param>
        /// <param name="compoundStructure">A compound structure</param>
        /// <returns name="wallType">The modified wall type.</returns>
        public static dynamoElements.WallType ToWallType(dynamoElements.WallType WallType, CompoundStructure compoundStructure)
        {
            revitDB.WallType revitWallType = (revitDB.WallType)WallType.InternalElement;

            using (Autodesk.Revit.DB.Transaction trans = new Autodesk.Revit.DB.Transaction(compoundStructure.internalDocument))
            {
                try
                {
                    trans.Start("Apply Structure to Wall Type");
                    revitWallType.SetCompoundStructure(compoundStructure.internalCompoundStructure);
                    trans.Commit();
                }
                catch
                {
                    revitWallType.SetCompoundStructure(compoundStructure.internalCompoundStructure);
                }
            }
            return(WallType);
        }