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

PDMPIVsGetWhereUsedDependencies

Highlighted
Regular Member

PDMPIVsGetWhereUsedDependencies

All,
Does anyone have any code that they could share that uses the API
PDMPIVsGetWhereUsedDependencies? I am having some trouble getting this to
return some PIV's. Thanks.



Patrick Williams
Applications Engineer
Steelcase Inc.
2 REPLIES 2

Re: PDMPIVsGetWhereUsedDependencies

Bob,
Thanks for looking. I guess it is a new function with Intralink 3.3. There
is no example code in the API wizard so I was just fishing for some. Maybe
I'll contact PTC.



Patrick Williams
Applications Engineer
Steelcase Inc.

Re: PDMPIVsGetWhereUsedDependencies

All,
Jim was right, the cursor returned was a cursor of HPDMDEPENDENCY handles.
Here is the code for anyone else who is having trouble.

PTCERROR PDMUtilGetDrawings(PDM_PIV_FSTRUCT **pdm_aPivFStruct, int
*pnPivFStructSize, PTCBOOL pdm_bLocalize) {

char *funcName = "PDMUtilGetDrawings()";
int i = 0;
PTCERROR pdm_error = PDM_SUCCESS;
HPDMOQL pdm_hOql = NULL_HPDMOQL;
HPDMOQLET pdm_hOqlet = NULL_HPDMOQLET;
HPDMWUSRULE pdm_hWUSRule = NULL_HPDMWUSRULE;
HPDMPIV pdm_hPiv = NULL_HPDMPIV,
*pdm_ahPiv = NULL;
HPDMCURSOR pdm_hCursor = NULL_HPDMCURSOR;
HPDMDEPENDENCY pdm_hDep = NULL_HPDMDEPENDENCY;

//Create OQL object
pdm_error = PDMOQLCreate(&pdm_hOql);
PDMUTIL_CALL_REPORT("PDMOQLCreate()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);

//Create OQLet search. Dependency
pdm_error = PDMOQLAddStringOQLet(pdm_hOql, "PDMc_Dependency", ", "piv", ",
&pdm_hOqlet);
PDMUTIL_CALL_REPORT("PDMOQLAddStringOQLet()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);

//Create OQLet search. PIV
pdm_error = PDMOQLAddStringOQLet(pdm_hOql, "PDMc_PIV", ", "branch", ",
&pdm_hOqlet);
PDMUTIL_CALL_REPORT("PDMOQLAddStringOQLet()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);

//Create OQLet search. PI
pdm_error = PDMOQLAddStringOQLet(pdm_hOql, "PDMc_PIBranch", ", "owner", ",
&pdm_hOqlet);
PDMUTIL_CALL_REPORT("PDMOQLAddStringOQLet()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);

//Create OQLet search. PI
pdm_error = PDMOQLAddStringOQLet(pdm_hOql, "PDMc_PI", ", "type_def", ",
&pdm_hOqlet);
PDMUTIL_CALL_REPORT("PDMOQLAddStringOQLet()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);

//Create OQLet search. PITypeDef
pdm_error = PDMOQLAddStringOQLet(pdm_hOql, "PDMc_PITypeDef",
"name='Drawing", NULL, NULL, &pdm_hOqlet);
PDMUTIL_CALL_REPORT("PDMOQLAddStringOQLet()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);

//Create a where used rule
pdm_error = PDMWUSRuleCreate(pdm_hOql,
PDM_WUSRULE_POLICY_ASSTORED_OF_WHEREUSED, NULL_HPDMBASELINE, NULL_HPDMPIV,
&pdm_hWUSRule);
PDMUTIL_CALL_REPORT("PDMWUSRuleCreate()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);

//Create an array of piv handles
pdm_ahPiv = (HPDMPIV*)calloc(sizeof(HPDMPIV), *pnPivFStructSize);
for(i=0;i<*pnPivFStructSize;i++)
pdm_ahPiv[i] = (*pdm_aPivFStruct)[i].PIVHandle;

//Get the where used dependencies
pdm_error = PDMPIVsGetWhereUsedDependencies(pdm_ahPiv, *pnPivFStructSize,
pdm_hWUSRule, &pdm_hCursor);
PDMUtilCallReport("PDMPIVsGetWhereUsedDependencies()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);
if(pdm_error != PDM_SUCCESS) {

free(pdm_ahPiv);

//Delete the where used rule
pdm_error = PDMWUSRuleDelete(pdm_hCursor);
PDMUtilCallReport("PDMWUSRuleDelete()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);

//Delete the OQL object
pdm_error = PDMOQLDelete(pdm_hOql);
PDMUtilCallReport("PDMOQLDelete()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);

return pdm_error;
}

free(pdm_ahPiv);

//Delete the where used rule
pdm_error = PDMWUSRuleDelete(pdm_hWUSRule);
PDMUTIL_CALL_REPORT("PDMWUSRuleDelete()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);

//Delete the OQL object
pdm_error = PDMOQLDelete(pdm_hOql);
PDMUTIL_CALL_REPORT("PDMOQLDelete()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);

//Add all drawings found to the pdm_aPivFStruct
for(PDMCursorGetNext(pdm_hCursor, &pdm_hDep);
!PDM_HANDLE_IS_NULL(pdm_hDep);
PDMCursorGetNext(pdm_hCursor, &pdm_hDep)) {

//Get the parent piv of the dependency edge
pdm_error = PDMDependencyGetParent(pdm_hDep, &pdm_hPiv);
PDMUTIL_CALL_REPORT("PDMDependencyGetParent()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);

//Add this piv to the PDM_PIV_FSTRUCT array
pdm_error = PDMUtilAddPivFStruct(pdm_hPiv, pdm_aPivFStruct,
pnPivFStructSize, pdm_bLocalize);
PDMUtilCallReport("PDMUtilAddPivFStruct()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);
if(pdm_error != PDM_SUCCESS) {

pdm_error = PDMCursorDelete(pdm_hCursor);
PDMUtilCallReport("PDMCursorDelete()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);

return pdm_error;
}
}

//Delete the cursor
pdm_error = PDMCursorDelete(pdm_hCursor);
PDMUtilCallReport("PDMCursorDelete()", funcName, pdm_error,
pdm_error!=PDM_SUCCESS);

return PDM_SUCCESS;
}



Patrick Williams
Applications Engineer
Steelcase Inc.