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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Pro/toolkit : ProAssemblyAutointerchange() function?

StefanoTaverna
1-Newbie

Pro/toolkit : ProAssemblyAutointerchange() function?

Hello All

I'm trying to use the ProAssemblyAutointerchange() function to replace a family table istance in an assembly model but I get a PRO_TK_GENERAL error.

Has someone used this function?

thanks in advance.

here my code :

ProAssembly _parentasm; /* root assembly */

ProMdl _component; // component under root assembly

ProFeature feat; // component feature (old component)

int *ids; // component identifiers from the assembly

ProName istname; // new istance name

ProFamtable ftab; // family table

ProFaminstance fist; // new family table istance

ProMdl newmdl; // new model

ProError err;

ProName tmpname;

int i,psize;

...

// retrieve new component from family table

err=ProFamtableInit(_component,&ftab);

if ( err!=PRO_TK_NO_ERROR) ....

err=ProFaminstanceInit(istname,&ftab,&fist);

if ( err!=PRO_TK_NO_ERROR) ....

err=ProFaminstanceRetrieve(&fist,&newmdl);

if ( err!=PRO_TK_NO_ERROR) ....

// debug info

ProMdlNameGet(_parentasm,tmpname);

printf("Assembly = %ls\n",tmpname);

ProMdlNameGet(_component,tmpname);

printf("Old Model = %ls\n",tmpname);

ProMdlNameGet(newmdl,tmpname);

printf("New Model = %ls\n",tmpname);

// component id array

err = ProArrayAlloc (0, sizeof(int), 1, (ProArray*)&ids);

if ( err!=PRO_TK_NO_ERROR) ....

err = ProArrayObjectAdd((ProArray*)&ids,PRO_VALUE_UNUSED,1,&(feat.id) );

if ( err!=PRO_TK_NO_ERROR) ....

// debug component id info, (it displays the right internal feature id)

err = ProArraySizeGet((ProArray)ids,&psize);

if ( err!=PRO_TK_NO_ERROR) ....

for ( i=0 ; i<psize ; i++ )

printf("id = %d\n",ids[i]);

// replace the componente (HERE I GET THE ERROR!)

err = ProAssemblyAutointerchange( _parentasm , ids , newmdl );

if ( err!=PRO_TK_NO_ERROR) ....

// free resource

ProArrayFree((ProArray*)&ids);

...


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
2 REPLIES 2

Hi,

Your code works fine , just ensure you add valid and correct feature Id in API

ProArrayObjectAdd((ProArray*)&ids,PRO_VALUE_UNUSED,1,&(feat.id) )

It appears feature object is not initialized , so feature Id will be a garbage value.

Thanks

Hi

I find out the issue: the model had regeneration problems, I fixed the errors moving the cursor under the component feature, after that it works fine.

Thanks

Top Tags