コード例 #1
0
        //class FailuresPreprocessor : DB.IFailuresPreprocessor
        //{
        //  public DB.FailureProcessingResult PreprocessFailures(DB.FailuresAccessor failuresAccessor) => DB.FailureProcessingResult.Continue;
        //}

        void ReconstructTopographyByPoints
        (
            DB.Document doc,
            ref DB.Architecture.TopographySurface element,

            IList <Point3d> points,
            [Optional] IList <Curve> regions
        )
        {
            var xyz = points.ConvertAll(GeometryEncoder.ToXYZ);

            //if (element is DB.Architecture.TopographySurface topography)
            //{
            //  using (var scope = new DB.Architecture.TopographyEditScope(topography.Document, NickName))
            //  {
            //    scope.Start(topography.Id);

            //    var boundaryPoints = topography.GetBoundaryPoints();
            //    var bbox = new BoundingBox(boundaryPoints.Convert(GeometryDecoder.ToPoint3d));
            //    bbox.Inflate(Revit.VertexTolerance * Revit.ModelUnits * 10.0);
            //    var bboxCorners = bbox.GetCorners().Take(4).Convert(GeometryEncoder.ToXYZ).ToArray();

            //    using (var tx = new DB.Transaction(topography.Document, NickName))
            //    {
            //      tx.Start();

            //      topography.AddPoints(bboxCorners);
            //      topography.DeletePoints(topography.GetPoints());

            //      tx.Commit();
            //    }

            //    using (var tx = new DB.Transaction(topography.Document, NickName))
            //    {
            //      tx.Start();

            //      topography.AddPoints(xyz);
            //      topography.DeletePoints(bboxCorners);

            //      tx.Commit();
            //    }

            //    scope.Commit(new FailuresPreprocessor());
            //  }
            //}
            //else
            {
                ReplaceElement(ref element, DB.Architecture.TopographySurface.Create(doc, xyz));
            }

            if (element is object && regions?.Count > 0)
            {
                var curveLoops = regions.Select(region => region.ToCurveLoop());
                DB.Architecture.SiteSubRegion.Create(doc, curveLoops.ToList(), element.Id);
            }
        }
コード例 #2
0
 public bool CanConvertToSpeckle(object @object)
 {
     return(@object
            switch
     {
         DB.DetailCurve _ => true,
         DB.DirectShape _ => true,
         DB.FamilyInstance _ => true,
         DB.Floor _ => true,
         DB.Level _ => true,
         DB.View _ => true,
         DB.ModelCurve _ => true,
         DB.Opening _ => true,
         DB.RoofBase _ => true,
         DB.Area _ => true,
         DB.Architecture.Room _ => true,
         DB.Architecture.TopographySurface _ => true,
         DB.Wall _ => true,
         DB.Mechanical.Duct _ => true,
         DB.Mechanical.Space _ => true,
         DB.Plumbing.Pipe _ => true,
         DB.Electrical.Wire _ => true,
         DB.CurtainGridLine _ => true, //these should be handled by curtain walls
         DB.Architecture.BuildingPad _ => true,
         DB.Architecture.Stairs _ => true,
         DB.Architecture.StairsRun _ => true,
         DB.Architecture.StairsLanding _ => true,
         DB.Architecture.Railing _ => true,
         DB.Architecture.TopRail _ => true,
         DB.Ceiling _ => true,
         DB.PointCloudInstance _ => true,
         DB.Group _ => true,
         DB.ProjectInfo _ => true,
         DB.ElementType _ => true,
         DB.Grid _ => true,
         DB.ReferencePoint _ => true,
         DB.Structure.AnalyticalModelStick _ => true,
         DB.Structure.AnalyticalModelSurface _ => true,
         DB.Structure.BoundaryConditions _ => true,
         _ => (@object as Element).IsElementSupported()
     });
コード例 #3
0
        void ReconstructTopographyByPoints
        (
            DB.Document doc,
            ref DB.Architecture.TopographySurface element,

            IList <Point3d> points,
            [Optional] IList <Curve> regions
        )
        {
            var xyz = points.ConvertAll(GeometryEncoder.ToXYZ);

            //if (element is DB.Architecture.TopographySurface topography)
            //{
            //  using (var editScope = new DB.Architecture.TopographyEditScope(doc, GetType().Name))
            //  {
            //    editScope.Start(element.Id);
            //    topography.DeletePoints(topography.GetPoints());
            //    topography.AddPoints(xyz);

            //    foreach (var subRegionId in topography.GetHostedSubRegionIds())
            //      doc.Delete(subRegionId);

            //    editScope.Commit(this);
            //  }
            //}
            //else
            {
                ReplaceElement(ref element, DB.Architecture.TopographySurface.Create(doc, xyz));
            }

            if (element is object && regions?.Count > 0)
            {
                var curveLoops = regions.Select(region => region.ToCurveLoop());
                DB.Architecture.SiteSubRegion.Create(doc, curveLoops.ToList(), element.Id);
            }
        }
コード例 #4
0
 public static Topography Wrap(Autodesk.Revit.DB.Architecture.TopographySurface topoSurface, bool isRevitOwned)
 {
     return(Topography.FromExisting(topoSurface, isRevitOwned));
 }
コード例 #5
0
        void ReconstructTopographyByMesh
        (
            DB.Document doc,
            ref DB.Architecture.TopographySurface element,

            Mesh mesh,
            [Optional] IList <Curve> regions
        )
        {
            mesh = mesh.InHostUnits();
            while (mesh.CollapseFacesByEdgeLength(false, Revit.VertexTolerance) > 0)
            {
                ;
            }
            mesh.Vertices.CombineIdentical(true, true);
            mesh.Vertices.CullUnused();

            var xyz    = mesh.Vertices.ConvertAll(RawEncoder.AsXYZ);
            var facets = new List <DB.PolymeshFacet>(mesh.Faces.Count);

            var faceCount = mesh.Faces.Count;

            for (int f = 0; f < faceCount; ++f)
            {
                var face = mesh.Faces[f];

                facets.Add(new DB.PolymeshFacet(face.A, face.B, face.C));
                if (face.IsQuad)
                {
                    facets.Add(new DB.PolymeshFacet(face.C, face.D, face.A));
                }
            }

            //if (element is DB.Architecture.TopographySurface topography)
            //{
            //  using (var editScope = new DB.Architecture.TopographyEditScope(doc, GetType().Name))
            //  {
            //    editScope.Start(element.Id);
            //    topography.DeletePoints(topography.GetPoints());
            //    topography.AddPoints(xyz);

            //    foreach (var subRegionId in topography.GetHostedSubRegionIds())
            //      doc.Delete(subRegionId);

            //    editScope.Commit(this);
            //  }
            //}
            //else
            {
                if (!DB.Architecture.TopographySurface.ArePointsDistinct(xyz))
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"At least two vertices have coincident XY values");
                }
                else if (!DB.Architecture.TopographySurface.IsValidFaceSet(facets, xyz))
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"At least one face is not valid for {typeof(DB.Architecture.TopographySurface).Name}");
                }
                else
                {
                    ReplaceElement(ref element, DB.Architecture.TopographySurface.Create(doc, xyz, facets));
                }
            }

            if (element is object && regions?.Count > 0)
            {
                var curveLoops = regions.Select(region => region.ToCurveLoop());
                DB.Architecture.SiteSubRegion.Create(doc, curveLoops.ToList(), element.Id);
            }
        }