cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

OID within a selection

jsulak
1-Visitor

OID within a selection

Hello Adepters,



Quick question: Is there an ACL function (or AOM method) that can tell
me if a particular oid is within the current selection? Seems like this
should be built in, but I can't find it.



Thanks,



-James



4 REPLIES 4

I don't think there is such a built in method. But you could use oid_treeloc on selection_start and selection_end and the particular oid you are interested in. Walk down the strings doing compares at each level.

John Dreystadt
Software Development Director
Arbortext - PTC
734-352-2835
-

jsulak
1-Visitor
(To:jsulak)

Thanks, John. I'll take a look at that.

-James

jsulak
1-Visitor
(To:jsulak)

Based on an off-list suggestion from Brandon, I came up with this:


function oid_in_selection(oid) {

if (!selected()) { return 0; }

$o1 = selection_start($p1);
$o2 = selection_end($p2);

$offset_from_start = oid_offset($o1, $p1, $oid, 0);
$offset_from_end = oid_offset($o2, $p2, $oid, 0);

return ($offset_from_start >= 0 && $offset_from_end <= 0);
}


Seems to work based on the limited testing I've done so far.

-James


Cool! Thanks for posting the solution, James.
Announcements

Top Tags