Exemple #1
0
 /// <summary>
 /// Construct a DirectShape from the Revit document.
 /// </summary>
 /// <param name="directShape"></param>
 /// <param name="isRevitOwned"></param>
 /// <returns></returns>
 internal static DirectShape FromExisting(Autodesk.Revit.DB.DirectShape directShape, bool isRevitOwned)
 {
     return(new DirectShape(directShape)
     {
         IsRevitOwned = isRevitOwned
     });
 }
Exemple #2
0
        void ReconstructDirectShapeByMesh
        (
            DB.Document doc,
            ref DB.DirectShape element,

            Rhino.Geometry.Mesh mesh
        )
        {
            if (!ThrowIfNotValid(nameof(mesh), mesh))
            {
                return;
            }

            if (element is DB.DirectShape ds)
            {
            }
            else
            {
                ds = DB.DirectShape.CreateElement(doc, new DB.ElementId(DB.BuiltInCategory.OST_GenericModel));
            }

            using (var ctx = GeometryEncoder.Context.Push(ds))
            {
                ctx.RuntimeMessage = (severity, message, invalidGeometry) =>
                                     AddGeometryConversionError((GH_RuntimeMessageLevel)severity, message, invalidGeometry);

                ds.SetShape(mesh.ToShape().OfType <DB.GeometryObject>().ToList());
            }

            ReplaceElement(ref element, ds);
        }
 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()
     });
        void ReconstructDirectShapeByBrep
        (
            DB.Document doc,
            ref DB.DirectShape element,

            Rhino.Geometry.Brep brep
        )
        {
            ThrowIfNotValid(nameof(brep), brep);

            if (element is DB.DirectShape ds)
            {
            }
            else
            {
                ds = DB.DirectShape.CreateElement(doc, new DB.ElementId(DB.BuiltInCategory.OST_GenericModel));
            }

            var shape = brep.ToShape();

            ds.SetShape(shape);

            ReplaceElement(ref element, ds);
        }
 public DirectShape(DB.DirectShape value) : base(value)
 {
 }
Exemple #6
0
 public static DirectShape Wrap(Autodesk.Revit.DB.DirectShape ele, bool isRevitOwned)
 {
     return(DirectShape.FromExisting(ele, isRevitOwned));
 }
Exemple #7
0
 /// <summary>
 /// SetInternalElement to a DirectShape element
 /// </summary>
 private void InternalSetDirectShape(Autodesk.Revit.DB.DirectShape shape)
 {
     this.InternalDirectShape = shape;
     this.InternalElementId   = shape.Id;
     this.InternalUniqueId    = shape.UniqueId;
 }
Exemple #8
0
 /// <summary>
 /// Initialize a DirectShape element
 /// </summary>
 private void InitDirectShape(Autodesk.Revit.DB.DirectShape shape)
 {
     InternalSetDirectShape(shape);
 }
Exemple #9
0
 /// <summary>
 /// Wrap an existing DirectShape.
 /// </summary>
 /// <param name="shape"></param>
 protected DirectShape(Autodesk.Revit.DB.DirectShape shape)
 {
     SafeInit(() => InitDirectShape(shape));
 }
 private void DirectShapeEqual(DB.DirectShape sourceElem, DB.DirectShape destElem)
 {
     Assert.NotNull(destElem);
     Assert.Equal(sourceElem.Name, destElem.Name);
     Assert.Equal(sourceElem.Category.Name, destElem.Category.Name);
 }