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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Object toolkit

afloquet-2
1-Newbie

Object toolkit

How to create a sequence of costum elements such a ProArray ?

4 REPLIES 4

Like this:

  ProWstring *w_array;

  status = ProArrayAlloc(0, sizeof(ProWstring), 1, (ProArray*)&w_array);

 

#include <ProArray.h>
ProErrorProArrayAlloc(
int n_objs
/* (In)
The initial number of objects allocated in the array.
*/
int obj_size
/* (In)
The size of each object in the array
*/
int reallocation_size
/* (In)
The minimum number of objects added or deleted if Creo Parametric TOOLKIT resizes the array, e.g. on a call to ProArrayObjectAdd.
*/
ProArray* p_array
/* (Out)
The allocated array
*/
)

After that you can add elements by:

  status = ProArrayObjectAdd(w_array, PRO_VALUE_UNUSED, 1, p_object );

Don't forget to free it at the end of the life cycle.

  status = ProArrayFree((ProArray*)&w_array);

Br,

Eike

Thank for you answer. but I want do the reverse.

How to create a sequence of custom objects of my class  ?

easiest way is to use std. c++ ways like vectors, maps, such kind of stuff : )

If you need it as a "Creo like" way I don't know ^.^ I was never in need of that.

But I think you can use an xanysequence. As alternative you can use xlongsequence and fill it with pointers to the objects you have allocated. So I'm not so sure about the size, if it didn't fit for pointers you could use xrealsequence, cause xreal is defined as a "real C++" double, that should be 8Byte --> 64 Bit and so same size as your pointer.

Br,

Eike

FV
17-Peridot
17-Peridot
(To:Eike_Hauptmann)

Hi all,

Alain,

Eike's answer is the correct one. You are dealing with the usual serialization/deserialization issues when packing your classes into ProArray. The easiest way is to create a c++ std container for your custom class and store pointers to the container elements in ProArray - this is very similar technique as Pro/Toolkit ProNote-Text handling...

Feliks.

Top Tags