Code:
#include <prointlnk.h>
#include <stdlib.h>int main(int argc, char *argv[])
{
PTCERROR err;
HPDMPDM pdm = NULL_HPDMPDM;
HPDMPI pi = NULL_HPDMPI;
HPDMBRANCH mainBranch = NULL_HPDMBRANCH;
HPDMPIV latestPiv = NULL_HPDMPIV;
PTCBOOL hasInstance;
HPDMCURSOR clusterList = NULL_HPDMCURSOR;
HPDMPLCLUSTER cluster = NULL_HPDMPLCLUSTER;
HPDMCURSOR pivList = NULL_HPDMCURSOR;
HPDMPIV piv = NULL_HPDMPIV;
PTCSTRING pivName = NULL;
printf("Pro/INTRALINK 3.4 FindInstances\n\n");
PDMConnectToPDM("INTRALINK", "INTRALINK", &pdm);
PDMPIGetByName(argv[1], &pi);
PDMPIGetMainBranch(pi, &mainBranch);
PDMBranchGetLatestPIV(mainBranch, &latestPiv);
PDMPIVHasInstances(latestPiv, &hasInstance);
if (!hasInstance)
{
printf("Model is not a generic object.\n");
return EXIT_SUCCESS;
}
PDMPIVsGetLOVs(1, &latestPiv, &clusterList);
if (!PDM_HANDLE_IS_NULL(clusterList))
{
PDMCursorGetNext(clusterList, &cluster);
PDMPLClusterGetPIVs(cluster, &pivList);
if (!PDM_HANDLE_IS_NULL(pivList))
{
for (PDMCursorGetNext(pivList, &piv); !PDM_HANDLE_IS_NULL(pivList); PDMCursorGetNext(pivList, &piv))
{
PDMPIVGetName(piv, &pivName);
printf("%s\n", pivName);
}
PDMCursorDelete(pivList);
}
}
PDMReleaseLicense();
return EXIT_SUCCESS;
}