void ReconstructDirectShapeByPoint ( DB.Document doc, ref DB.Element element, Rhino.Geometry.Point3d point ) { if (!ThrowIfNotValid(nameof(point), point)) { 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); var shape = new DB.Point[] { DB.Point.Create(point.ToXYZ()) }; ds.SetShape(shape); } ReplaceElement(ref element, ds); }
void ReconstructGroupByLocation ( DB.Document doc, ref DB.Group element, [Description("Location where to place the group.")] Rhino.Geometry.Point3d location, DB.GroupType type, Optional <DB.Level> level ) { if (!location.IsValid) { ThrowArgumentException(nameof(location), "Should be a valid point."); } SolveOptionalLevel(doc, location, ref level, out var bbox); ChangeElementTypeId(ref element, type.Id); var newLocation = location.ToXYZ(); if ( element is DB.Group && element.Location is DB.LocationPoint locationPoint && locationPoint.Point.Z == newLocation.Z ) { if (!newLocation.IsAlmostEqualTo(locationPoint.Point)) { element.Pinned = false; locationPoint.Point = newLocation; element.Pinned = true; } }
void ReconstructDirectShapeByPoint ( DB.Document doc, ref DB.Element element, Rhino.Geometry.Point3d point ) { ThrowIfNotValid(nameof(point), point); if (element is DB.DirectShape ds) { } else { ds = DB.DirectShape.CreateElement(doc, new DB.ElementId(DB.BuiltInCategory.OST_GenericModel)); } var shape = new DB.Point[] { DB.Point.Create(point.ToXYZ()) }; ds.SetShape(shape); ReplaceElement(ref element, ds); }