Start a new topic

Select All Subfaces

Original Post by: Wed Dec 3 16:29:38 2014


This code below will only select the first nested child of a polygon. What should be changed to select all subfaces together?


static mgbool selectSub (mgrec* db, mgrec* parent, mgrec* rec,mgrec* child, void* selectA)

{

toolrec* toolRec = (toolrec*)selectA;

parent = mgGetCode(rec);

child = mgGetNestedChild(rec);

if (parent == fltPolygon)

{

mgSelectOne(child);

}

return MG_TRUE;

}


Original Post by: Wed Dec 3 17:32:18 2014


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,

Original Post by: SteveThompson Wed Dec 3 17:25:29 2014


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 ;-)

Original Post by: Wed Dec 3 17:21:01 2014


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.

Original Post by: SteveThompson Wed Dec 3 17:18:36 2014


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.

Original Post by: Wed Dec 3 17:05:35 2014


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.

Original Post by: ChrisRogers Wed Dec 3 16:52:54 2014


No worries, that is what this forum is all about. :)

Original Post by: Wed Dec 3 16:51:41 2014


Thank You.. I might ask for more help... please bear with me ;)

Original Post by: ChrisRogers Wed Dec 3 16:41:30 2014


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.

Login to post a comment