示例#1
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);
        }
示例#2
0
        void ReconstructDirectShapeByMesh
        (
            DB.Document doc,
            ref DB.DirectShape element,

            Rhino.Geometry.Mesh mesh
        )
        {
            ThrowIfNotValid(nameof(mesh), mesh);

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

            var shape = mesh.ToShape();

            ds.SetShape(shape);

            ReplaceElement(ref element, ds);
        }