Transform a Group of RhinoObject with some hidden objects in RhinoCommon

Hi,

I have a plugin that handles the user input with groups of RhinoObject.
Each group has some of the RhinoObject hidden, and I’m trying to avoid the use of the hide-show of the layers to decouple the complexity of the user from the layer list.

The only part that I’m missing is that a group of RhinoObject with a part of them hidden is translated as expected from Rhino.Geometry.GeometryBase.Transform (with RhinoObjects.CommitChanges() afterwards and optional show of the hidden objects in the call stack); if instead the user translates the group from the Rhinoceros viewport, in a certain sequence the hidden objects of the group are not moved.

With the solution attached and the sequence obtained from executing
1- the commands of step1.txt
2- move from viewport with mouse of the group of rhnoobject as reported in a move from Rhinoceros UI after step1.txt.png
3- the commands of step2.txt
4- move from viewport as reported in b move from Rhinoceros UI after 'step2.txt'.png
5- the commands of step3.txt
6- I obtain the pieces with the position as in the print screen c result of 'step3.txt'.PNG
even if the group is made as in print screen group with 20 lines created from 'valueExpectedAsGroupWithPartialHidden.txt'.PNG



c result of 'step3.txt'
group with 20 lines created from 'valueExpectedAsGroupWithPartialHidden.txt'
Solution.7z (61.0 KB)
step1.txt (45 Bytes)
step2.txt (21 Bytes)
step3.txt (51 Bytes)
valueExpectedAsGroupWithPartialHidden.txt (52 Bytes)

Hi @cavalli.stefano,

Rather than using CommitChanges, make a copy of the geometry, transform it, and then call ObjectTable.Replace and pass a true value for the ignoreModes parameter.

– Dale

Hi @Dale,

I still have the problem, even If I have replaced the GeometryBase.Transform call with the override of RhinoDoc.Objects.Replace you mentioned.

Have you fixed the solution I have attached in the previous post? In this case could you please pass the changed version? I don’t remember if the RhinoCommon.dll is in a custom nuget package or in the nuget.org server, however the dll is the same.

(in my actual problem, at the beginning of the malfunction, I have the hidden objects that do not show the start position grayed out during the move preview, as replicated in the print screen of step 4-. I’m assuming that the fix is related to the feature of showing hidden objects of moving selection by mouse that is not working anymore after a GeometryBase.Transform. However my real problem is that the hidden objects are not translated in the same manner as reported also in this sample, maybe the grayed out preview is a hint of the core problem?)

Thanks

Hi @cavalli.stefano,

This seems to work:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  var group = doc.Groups.FindName(m_group_name);
  if (null == group)
  {
    RhinoApp.WriteLine("Group \"{0}\" not found.", m_group_name);
    return Result.Nothing;
  }

  var rhinoObjects = doc.Objects.FindByGroup(group.Index);
  if (null == rhinoObjects || 0 == rhinoObjects.Length)
  {
    RhinoApp.WriteLine("Group \"{0}\" contains 0 objects.", m_group_name);
    return Result.Nothing;
  }

  var xform = Transform.Translation(Vector3d.XAxis * 10.0);
  foreach (var rhObject in rhinoObjects)
  {
    var geometry = rhObject.Geometry.Duplicate();
    if (null != geometry && geometry.Transform(xform))
      doc.Objects.Replace(rhObject.Id, geometry, true);
  }

  return Result.Success;
}

– Dale

Hi @Dale,

The last code you posted solved the problem.

I had a show/hide of hidden objects in the stack from the GeometryBase.Transform()+RhinoObject.CommitChanges() version that caused the mentioned shift.
However the state of group selected should be kept on each component not considering if it is hidden, in my opinion.

Thanks