Feb 20, 2018, 3:43 PM

Dear all,

I am trying to create a group of atoms that are distributed on several chains into a one SBNodeGroup.
In the following code I added every atom of my document into a SBNodeGroup, however it doesn't work as I cannot "Select group nodes" in the context menu and groupNodesSize is always zero. Am I missing something here?

 SAMSON::beginHolding("adding myModeGroup");

  SBPointer<SBNodeGroup> nodeGroup = new SBNodeGroup();
  nodeGroup->setName("myNodeGroup");

  SBNodeIndexer allNodes;
  SAMSON::getActiveDocument()->getNodes(allNodes);
  nodeGroup->create();

  SB_FOR(SBNode* node, allNodes) {
    if (node->getType() == SBNode::Atom) {
      nodeGroup->addChild(node);
    }
  }
  
  auto groupNodes = nodeGroup->getGroupNodes();;
  
  int allNodesSize = allNodes.size();
  int groupNodesSize = groupNodes->size();
  
  SAMSON::getActiveDocument()->addChild(nodeGroup());

  SAMSON::endHolding();```

Thank you,
Haichao