Skip to main content
1-Visitor
February 7, 2017
Question

Object toolkit

  • February 7, 2017
  • 1 reply
  • 2343 views

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

1 reply

15-Moonstone
February 7, 2017

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

1-Visitor
February 7, 2017

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

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

15-Moonstone
February 7, 2017

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