Skip to main content
1-Visitor
Dec 9, 2016 7:22 AM UTC
Solved

How to create proselection object programatically?

I am trying to select 3D point this way.

    TomasLounAnswer
    1-Visitor
    Dec 12, 2016 8:58 AM UTC

    In Pro/Toolkit you can use ProSelectionAlloc. The second parameter is Promodelitem - your 3D point.

    14 replies

    15-Moonstone
    Dec 9, 2016 1:18 PM UTC

    Which language / API ?

    Translate
    lgangwar1-VisitorAuthor
    1-Visitor
    Dec 12, 2016 5:25 AM UTC

    I want to use PROTK API for making this happen. It is based on C language structure.

    Translate
    TomasLoun1-VisitorAnswer
    1-Visitor
    Dec 12, 2016 8:58 AM UTC

    In Pro/Toolkit you can use ProSelectionAlloc. The second parameter is Promodelitem - your 3D point.

    Translate
    lgangwar1-VisitorAuthor
    1-Visitor
    Dec 12, 2016 10:17 AM UTC

    I want to use ProNoteAttachAddend() API for making leader line to my note. For this Proselection object is required. I am able to create ProSelection object but not able to set selected id and type correctly to my proselection object.

    Translate
    1-Visitor
    Dec 12, 2016 9:02 AM UTC

    ProSelction object can be created by using the item name and item type.

    Make ProModelItem object first (using 'ProModelitemByNameInit'), and then create ProSelection object (using 'ProSelectionAlloc').

    Translate
    lgangwar1-VisitorAuthor
    1-Visitor
    Dec 12, 2016 1:49 PM UTC

    I am making a point programatically (so don't have name or id of this point) and select it as a proselection() object programatically.

    Translate
    1-Visitor
    Dec 12, 2016 2:03 PM UTC

    How do you create the point programmatically? Could you post here a piece of code? It should be a modelitem, so you should be able to use it directly in ProSelectionAlloc..

    Translate
    lgangwar1-VisitorAuthor
    1-Visitor
    Dec 14, 2016 6:36 AM UTC

    All suggested methods are good and to the point. But in my case i got one API ProGeometryAtPointFind() works really well. This API should be used when you are certain that your 3D point will be on the part surface somewhere.

    Translate
    1-Visitor
    Dec 14, 2016 1:16 PM UTC

    This method will tell you surfaces or edges where the point lays on. I probably do not understand what are you exactly going to do...

    Translate
    lgangwar1-VisitorAuthor
    1-Visitor
    Dec 15, 2016 5:11 AM UTC

    See i need model item to fill proselection object and i already know that the co-ordinates which i have they are on part. So by using this API "ProGeometryAtPointFind" i get the proselection object at that point directly. It creates proselection object on that part with appropriate data structure.

    extern ProError ProGeometryAtPointFind ( ProPart part,

                                 Pro3dPnt point,

                                 ProSelection** p_sel_arr,

                                 int* p_count);

    /*

       Purpose:     Determines the surfaces or edges on which the specified

                    point is located.  If a point lies on an edge, the function

                    does not return the neighboring surfaces.

       Input Arguments:

          part      -  The part handle.

          point     -  A three-dimensional point, in the coordinates of the part.

     

       Output Arguments:

          p_sel_arr - An array of <I>ProSelection</I>, which has information

                      about surfaces or edges on which the point is located.

                      The function allocates space for this array; free it

              using ProSelectionarrayFree().

          p_count   - The number of items on which the point lies.

      Return Values:

          PRO_TK_NO_ERROR    - The function successfully evaluated the point.

          PRO_TK_BAD_INPUTS  - One or more of the input arguments are invalid.

          PRO_TK_E_NOT_FOUND - The surface or edge was not found.

    */

    Translate