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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

How to create proselection object programatically?

lgangwar
4-Participant

How to create proselection object programatically?

I am trying to select 3D point this way.

1 ACCEPTED SOLUTION

Accepted Solutions
TomasLoun
4-Participant
(To:lgangwar)

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

View solution in original post

14 REPLIES 14

Which language / API ?

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

TomasLoun
4-Participant
(To:lgangwar)

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

lgangwar
4-Participant
(To:TomasLoun)

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.

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').

lgangwar
4-Participant
(To:skadam-5)

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

TomasLoun
4-Participant
(To:lgangwar)

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..

lgangwar
4-Participant
(To:TomasLoun)

It is not model item. Can you help me to make a point model item. I want to code it like this.

       ProPoint3d pPnt;

       pPnt[0]=62.21;

    pPnt[1]=-59.42;

    pPnt[2]=-1.74;


than use this point to make proselection object.


You can't create a point like this. If you want it selectable than it need to be a model item and this need to be inside Creo Features. The Only war I know is to create it as a feature.

Another way could be a mapkey. Thats no nice solution ... but sometimes the easiest way.

Br,

Eike

hi I have no Code for a point atm, but in this Thread is some code for a Datum Plane:

"ProElemtreeElementAdd" does not work!

The creation is nearly same, just look wich element tree nodes you need. You could find them inside the API Documentation.

Br,

Eike

lgangwar
4-Participant
(To:lgangwar)

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.

TomasLoun
4-Participant
(To:lgangwar)

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...

lgangwar
4-Participant
(To:TomasLoun)

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.

*/

TomasLoun
4-Participant
(To:lgangwar)

Yes, but ProSelection of surface or edge(s). I thought you need ProSeleciton of point. But it does not matter, if this is what you need, it is fine.

Top Tags