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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Pro/ToolKit reading assembly data

vvladimir
1-Newbie

Pro/ToolKit reading assembly data

Could you please help me with the following problem.

I get geomtry (thesselation) of the part using the following code:

ProError Convert_Part(ProMdl Mdl, ProMatrix Matr)

{

  ProError status = PRO_TK_NO_ERROR;

  ProName WName;

  ProCharName Name;

  ProSurfaceTessellationData data;

  ProSurfaceTessellationData *Output;

  ProVector Vect, CoM;

  ProMassProperty mass;

  Pro_surf_props prop;

  ProMatrix PrevMatrix, IM, _IM;

  int n_obj, i, j, k, clr;

  char *lVerts = (char *)calloc(100000000, sizeof(char));

  char *lFacets = (char *)calloc(100000000, sizeof(char));

  char tmpVert[100];

  char tmpFacet[100];

  int offset = 1;

  status = ProMdlNameGet(Mdl, WName);

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

  for (j = 0; j < 4; j++)

  PrevMatrix[i][j] = AsmMatrix[i][j];

  status = ProSolidMassPropertyGet((ProSolid)Mdl, NULL, &mass);

  fprintf(UcfFile, "  material = %s;\n", GetPartColor().c_str());

  Output = (ProSurfaceTessellationData *)calloc(10, sizeof(ProSurfaceTessellationData));

  status = ProPartTessellate((ProPart)Mdl, 0.01, 0.1, PRO_B_TRUE, &Output);

  status = ProArraySizeGet(Output, &n_obj);

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

  {

       data = (Output[i]);

       for (j = 0; j < data.n_vertices; j++)

       {

            sprintf(tmpVert, "  %lf, %lf, %lf;\n", data.vertices[j][0], data.vertices[j][1], data.vertices[j][2]);

            strcat(lVerts, tmpVert);

       }

      

     for (j = 0; j < data.n_facets; j++)

     {

            sprintf(tmpFacet, "  %d, %d, %d;\n", data.facets[j][0] + offset, data.facets[j][1] + offset, data.facets[j][2] + offset);

            strcat(lFacets, tmpFacet);

     }

     offset += data.n_vertices;

  }

  fprintf(UcfFile, "Vertices = {\n%0s  };\n", lVerts);

  fprintf(UcfFile, "Faces = {\n%0s  };\n", lFacets);

  free(lVerts);

  free(lFacets);

  status = ProPartTessellationFree(&Output);

  return status;

}


I works correct. My next step is to get the same data for all parts in

the assembly. For that I use the following code:

ProError Convert_Assembly(ProMdl Mdl, ProMatrix Matr)

{

  ProError status;

  ProMatrix Prev;

  int i, j;

  status = ProSolidFeatVisit((ProSolid)Mdl, VisitFeat, NULL, NULL);

}

ProError VisitFeat(ProFeature *feat, ProError status, /**ProMatrix/*/ProAppData/**/ AppData)

{

  ProFeattype FeatType = 0;

  ProAsmcomp *AsmComp;

  ProMdl Mdl;

  ProMdlType MdlType;

  ProMatrix Matr;

  ProMatrix PrevM;

  ProMatrix EndM;

  int i, j, k;

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

  for (j = 0; j < 4; j++)

       PrevM[i][j] = AsmMatrix[i][j];

  status = ProFeatureTypeGet(feat, &FeatType);

  if (FeatType == PRO_FEAT_COMPONENT)

  {

       AsmComp = feat;

       status = ProAsmcompMdlGet(AsmComp, &Mdl);

       status = ProMdlTypeGet(Mdl, &MdlType);

       status = ProAsmcompPositionGet(AsmComp, Matr);

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

       {

            for (j = 0; j < 4; j++)

            {

                 EndM[i][j] = 0;

                 for (k = 0; k < 4; k++)

                      EndM[i][j] += Matr[i][k] * PrevM[k][j];

            }

       }

       if (MdlType == PRO_MDL_PART)

       {

            Convert_Part(Mdl, EndM);

       }

      else

       if (MdlType == PRO_MDL_ASSEMBLY)

       {

            Convert_Assembly(Mdl, EndM);

       }

  }

  return PRO_TK_NO_ERROR;

}

When I try to process the assembly from the samples [PROE_PATH\vbapi\vbapi_examples\models\drill_chuck.asm] the

program give me data for two parts of three and Pro/E / Creo closes.

It closes without any errors or warnings. It simply silently closes.

At the same time if works correct again when I create new assembly and

add there same parts from mentioned sample model if I add parts to

assembly from the assembly's folder.

Could you please give me a hint what might lead to such abnormal

program behaviour? Any suggestions and comments would be highly

appreciated.


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.
1 REPLY 1
FV
17-Peridot
17-Peridot
(To:vvladimir)

Hi all,

Vladimir,

You should question the validity of this statement:

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

{

       data = (Output[i]);

       for (j = 0; j < data.n_vertices; j++)

...

HIH.

Top Tags