Skip to main content
15-Moonstone
April 7, 2021
Solved

ProSelection Array without user interaction

  • April 7, 2021
  • 1 reply
  • 4690 views

My program intent tis to create a Shrinkwrap of the current assembly.    

I am using ProSolidShrinkwrapMdlnameCreate to create the SW.  And setting options prior to the function call as shown in the examples.  Export is working, but I need the Shrinkwrap to include a specific Csys.   The csys is a specific name.

 

So to my actual issue -  there are functions to set the options of the Shrinkwrap, and one is for including datum references - perfect!

 ProShrinkwrapoptionsDatumrefsSet  takes for the second argument a ProSelection *   an array of Proselections.  

 

Does anyone have an example where they have generated an array of ProSelection,  using a selection in which they generated from a geomitem?     (there are utilities in the Protk folder to find the csys by name and convert to sel)  I have that.  

 

Thanks for any Help!

Best answer by RPN

This is pseudo code not compiled and tested, but should help

 

Spoiler

ProSelection                 selection;

ProModelitem               modelitem;

ProSelection                 *p_sel_arr;

ProMdl                                     model;
iint                                                         id,type;

ProCsys                        csyshandle;

 

 

            // alloc array

            tk_status =  ProArrayAlloc (0, sizeof (ProSelection), 1,        (ProArray*)&p_sel_arr);

 

            // this is a model item as well

            tk_status = ProCsysInit(model,geom_id,&csyshandle);

 

                        or

 

            // by geom id most of the time feat id +1

            tk_status = ProModelitemInit (model, geom_id, PRO_CSYS,&modelitem);

 

                        or

 

            // if a feature was selected

            tk_status = ProModelitemInit (model, feat_id, PRO_FEATURE,&modelitem);

 

 

            // get the valid selection

            tk_status = ProSelectionAlloc(NULL,&modelitem,&selection);

 

 

            // add to array

            tk_status = ProArrayObjectAdd((ProArray*)&p_sel_arr, PRO_VALUE_UNUSED, 1,&selection);

 

1 reply

18-Opal
April 7, 2021

extern ProError ProGeomitemToCsys ( ProGeomitem *p_geom_item,
ProCsys *r_csys_handle);
/*
Purpose: Converts a coordinate system <I>ProGeomitem</I> handle to a
<I>ProCsys</I> handle.

Input Arguments:
p_geom_item - The coordinate system geometry item handle

Output Arguments:
r_csys_handle - The coordinate system handle initialized, based on the
input geometry item handle

Return Values:
PRO_TK_NO_ERROR - The function successfully converted the
geometry item handle to a coordinate system handle.
PRO_TK_BAD_INPUTS - The input geometry item handle is invalid, or does not
refer to a coordinate system.
*/

 

with this you can build the model item used in the selection, in an assembly you may need to add the comp path as well.

 

 

msteffke15-MoonstoneAuthor
15-Moonstone
April 8, 2021

Thanks Aquamarine.  You last statement, "with this you can build the model item used in the selection, in an assembly you may need to add the comp path as well."  This is what I am looking for an example to do this, to create an array of ProSelection.   The csys I am finding is a feature in an assembly.   So does that mean I need to do the component path?

RPN18-OpalAnswer
18-Opal
April 9, 2021

This is pseudo code not compiled and tested, but should help

 

Spoiler

ProSelection                 selection;

ProModelitem               modelitem;

ProSelection                 *p_sel_arr;

ProMdl                                     model;
iint                                                         id,type;

ProCsys                        csyshandle;

 

 

            // alloc array

            tk_status =  ProArrayAlloc (0, sizeof (ProSelection), 1,        (ProArray*)&p_sel_arr);

 

            // this is a model item as well

            tk_status = ProCsysInit(model,geom_id,&csyshandle);

 

                        or

 

            // by geom id most of the time feat id +1

            tk_status = ProModelitemInit (model, geom_id, PRO_CSYS,&modelitem);

 

                        or

 

            // if a feature was selected

            tk_status = ProModelitemInit (model, feat_id, PRO_FEATURE,&modelitem);

 

 

            // get the valid selection

            tk_status = ProSelectionAlloc(NULL,&modelitem,&selection);

 

 

            // add to array

            tk_status = ProArrayObjectAdd((ProArray*)&p_sel_arr, PRO_VALUE_UNUSED, 1,&selection);