Jump to content

only two groups created while more names exists


Guest mantragora

Recommended Posts

Guest mantragora

This topic is a continuation of my previous one.

I want to iterate over each group, take its name, modify it and create new group with this new name. I'm using this code:

	// process groups
	for (GA_GroupTable::iterator<GA_ElementGroup> it = gdp->primitiveGroups().beginTraverse(); !it.atEnd(); ++it) 
	{
		if(progress.wasInterrupted()) break;

		string name = it.name();
		vector<string> splited = SplitString(name, '_');
		RemoveEmptyStrings(splited);

		// create new name
		stringstream text;
		text << splited[0] << "_" << splited[1] << "_" << splited[3];

		string newName = (string)(text.str());
		cout << newName << endl;
	}

plus three custom methods for string manipulation to make it happen. Now if I run this code with 8 groups, it will print 8 new names.

But, if I add this line

gdp->newPrimitiveGroup(newName.c_str());

or

gdp->createElementGroup(GA_ATTRIB_PRIMITIVE, newName.c_str());

on the end of the loop and run this code with the same 8 groups, only two new names/groups are printed/created. So I assume that I'm making some mistake here.

Help !

Edited by mantragora
Link to comment
Share on other sites

Guest mantragora

Actually, since I'm adding groups in the same loop, the count of groups changes and gives wrong output. :) I have to check it but probably that's the problem.

Edited by mantragora
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...