SilverScreen Solid Modeler

near_entity2

near_entity2

Previous topic Next topic  

near_entity2

Previous topic Next topic JavaScript is required for the print function  

 

SilverScreenAPI

 

int near_entity2( int e_type, int x, int y );

 

int e_type;    // An integer entity flag

int x;         // An integer x-coordinate

int y;         // An integer y-coordinate

 

 




Synopsis

#include "silver.h"

 

The near_entity2 function works like near_entity1 with two exceptions. First, near_entity2 will only pick entities from the current q-group. Second, near_entity2 will only consider entities that are currently visible and in the current window.

 

 

Parameters

e_type is a bos-level bits1 flag value whose meaning is as follows:

 

Value

Meaning

BITS_OBJECT

Only object entities are tested for nearness to x,y

BITS_BLOCK

Only block entities are tested for nearness to x,y

BITS_SYMBOL

Only symbol entities are tested for nearness to x,y

BITS_TEXT

Only text-line entities are tested for nearness to x,y

BITS_DETAIL

Only detail entities are tested for nearness to x,y

 

x is the x-coordinate of the 2D point used to select entities

y is the y-coordinate of the 2D point used to select entities

 

 

Return Value

near_entity2 returns zero if there is no q-group defined, otherwise it returns the number of items in the q-group that satisfied the selection conditions.

 

 

Remarks

near_entity2 can be used to limit a user's options when picking, by forcing their selection to come from the current q-group. It can also be used to disambiguate among entities returned via near_entity1.

 

 

See Also

near_entity1, get_group_item, pick_entity

 

 

Example

The following code changes the edge and surface color of the best candidate objects that have a prefix of "claw":

C / C++ Code

 

 #include "silver.h"

 #include "ssnodes.h"

 #include "sskeys.h"

 

 void main(void)

    {

    int xpos, ypos, key;

 

    // Obtain the position where the users left-clicks the mouse

 

    do

      {

      key = inchar();

      }

    while ( key != M_LUP );

 

    pointer_position(&xpos, &ypos);

 

 

    // Create a q-group of objects with a prefix of claw using wildcards

 

    ss_command("q-group object !claw*");

 

    if ( near_entity2(BITS_OBJECT, xpos, ypos) > 0 )

       {

       ss_command("redraw [q-group] color light-red");

       ss_command("surface [q-group] fill-color light-red");

       }

    }