/// <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)); }
/// <summary> /// Returns a list of dictionaries with Autodesk.Revit.DB.CompoundStructureLayer properties. /// </summary> /// <param name="cs">Autodesk.Revit.DB.CompoundStructure</param> /// <param name="doc">Autodesk.Revit.DB.Document</param> /// <returns></returns> internal static cg.IList <cg.Dictionary <string, object> > _GetLayers(revitCS cs, revitDoc doc) { cg.IList <cg.Dictionary <string, object> > layers = new cg.List <cg.Dictionary <string, object> >(); foreach (revitCSLayer layer in cs.GetLayers()) { layers.Add(_RevitLayerToDictionary(layer, doc)); } return(layers); }