You are just missing the loop logic. You just need to loop over every child using mgGetNext() Here some source code showing how this can be accomplished:
Python:
def selectSub (db, parent, rec, data):
if (mgGetCode(rec) == fltPolygon):
child = mgGetNestedChild(rec)
while (child):
mgSelectOne(child)
child = mgGetNext(child)
return MG_TRUE;
db = mgGetCurrentDb ()mgWalk (db, selectSub, None, None, MWALK_ON)
C:
static mgbool selectSub (mgrec* db, mgrec* parent, mgrec* rec, void* selectA)
{
toolrec* toolRec = (toolrec*)selectA;
if (mgGetCode(rec)== fltPolygon){
child = mgGetNestedChild(rec);
while (child)
{
mgSelectOne(child);
child = mgGetNext(child)
}
}
return MG_TRUE;}
Please note, that I modified your function parameters to fit the form of one that can be passed to mgWalk. I'm not sure that is who was intended to call this function, but I suspect it to be the case. If so, you can modify what members your toolrec has, but not the function signature.
Thank You.. I might ask for more help... please bear with me ;)
No worries, that is what this forum is all about. :)
If a polygon is missing comment and some of its subfaced polygons also missing comment, is it possible to select both of them. Like in attribute search if we search all polygons will get selected. I have a button in plugin to select all polygons which has missing comments but it wont select nested polygons if nested parent also has missing comment.
If a polygon is missing comment and some of its subfaced polygons also missing comment, is it possible to select both of them.
When I responded to this same question in an earlier post here:
support/discussions/topics/2182
I did not think to mention a special "selection" function in the API that does allow recursive select.
Instead of calling mgSelectOne, you can use mgSelectOneEx. You pass some flags to this "special" selection function, one of which allows you to select recursively. Sorry I did not think of this earlier for you.
mgSelectOneEx (rec, MSEL_ALLOWRECURSIVE);
This function must be used with care because recursive selection is a bit dangerous.Not all tools in Creator are written to handle items selected recursively. Just beware.
If a polygon is missing comment and some of its subfaced polygons also missing comment, is it possible to select both of them.
When I responded to this same question in an earlier post here:
support/discussions/topics/2182
I did not think to mention a special "selection" function in the API that does allow recursive select.
Instead of calling mgSelectOne, you can use mgSelectOneEx. You pass some flags to this "special" selection function, one of which allows you to select recursively. Sorry I did not think of this earlier for you.
mgSelectOneEx (rec, MSEL_ALLOWRECURSIVE);
This function must be used with care because recursive selection is a bit dangerous.Not all tools in Creator are written to handle items selected recursively. Just beware.
Yeah sorry Steve, I was wondering then how attribute search works. Sorry for the repeated question. and thanks for the info.
Yeah sorry Steve, I was wondering then how attribute search works. Sorry for the repeated question. and thanks for the info.
I am glad you made me think about Attribute Search. When I looked at its code, I remembered this function.
Note, however, that just because something can be done by SOME tool in Creator does not mean that ANY plug-in can do it. Not every tool in Creator is a plug-in. Some "native" tools in Creator may be able to access "internal" capabilities that plug-ins may not be able to. We try to make everything "public" through the API but you will inevitably find some things that internal Creator tools can do that a plug-in just can't.
When enough customers grumble about missing such functionality, we can consider making it publicly available ;-)
Yeah. Now I can understand all these stuffs better than before with your guidance. I'm really thankful for these support. As i told earlier these repeated questions and all comes out from me is just because I am a beginner.
And this
mgSelectOneEx(rec,MSEL_ALLOWRECURSIVE);
really served my selection purpose. thanks,
Craig
This code below will only select the first nested child of a polygon. What should be changed to select all subfaces together?