void ReconstructGroupByLocation ( DB.Document doc, ref DB.Group element, [Description("Location where to place the group. Point or plane is accepted.")] Rhino.Geometry.Point3d location, DB.GroupType type, Optional <DB.Level> level ) { var scaleFactor = 1.0 / Revit.ModelUnits; location = location.ChangeUnits(scaleFactor); if (!location.IsValid) { ThrowArgumentException(nameof(location), "Should be a valid point."); } SolveOptionalLevel(doc, location, ref level, out var bbox); ChangeElementTypeId(ref element, type.Id); if ( element is DB.Group && element.Location is DB.LocationPoint locationPoint && locationPoint.Point.Z == location.Z ) { var newOrigin = location.ToHost(); if (!newOrigin.IsAlmostEqualTo(locationPoint.Point)) { element.Pinned = false; locationPoint.Point = newOrigin; element.Pinned = true; } }
void CommitInstance ( Document doc, IGH_DataAccess DA, int Iteration, Rhino.Geometry.Point3d point ) { var element = PreviousElement(doc, Iteration); try { if (!point.IsValid) { throw new Exception(string.Format("Parameter '{0}' must be valid Point.", Params.Input[0].Name)); } var scaleFactor = 1.0 / Revit.ModelUnits; if (scaleFactor != 1.0) { point = point.Scale(scaleFactor); } var shape = new List <GeometryObject> { Point.Create(point.ToHost()) }; var ds = element as DirectShape ?? CopyParametersFrom(DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_GenericModel)), element); ds.SetShape(shape); element = ds; ReplaceElement(doc, DA, Iteration, element); } catch (Exception e) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message); ReplaceElement(doc, DA, Iteration, null); } }