Sample Ipaper
Transcript of Sample Ipaper
global solutions
innovation
collaboration
© 2000 PTC
Pro/INTRALINK Toolkit SIG
Training
Pro/INTRALINK Toolkit SIG
Training
Andrey Knourenko
Manager R&D
Pro/USER 00
Andrey Knourenko
Manager R&D
Pro/USER 00
© 2000 PTC 2
AgendaAgenda
Introduction to Pro/INTRALINK Toolkit (50min) Custom Applications
Pro/INTRALINK APIs
Pro/INTRALINK Objects
Object Types
Break (15 min)
Advanced User Topics (50 min) Triggers
Transactions
Configuration Objects
Clusters
Introduction to Pro/INTRALINK Toolkit (50min) Custom Applications
Pro/INTRALINK APIs
Pro/INTRALINK Objects
Object Types
Break (15 min)
Advanced User Topics (50 min) Triggers
Transactions
Configuration Objects
Clusters
© 2000 PTC 3
What Is the Pro/INTRALINK Toolkit?What Is the Pro/INTRALINK Toolkit?
Development toolkit for Pro/INTRALINK Create custom applications that complement
Pro/INTRALINK C Programming Language Access to a library of Pro/INTRALINK C functions used by
the Pro/INTRALINK client Applications created with this tookit allow access to
Pro/INTRALINK information in a safe, controlled manner
Development toolkit for Pro/INTRALINK Create custom applications that complement
Pro/INTRALINK C Programming Language Access to a library of Pro/INTRALINK C functions used by
the Pro/INTRALINK client Applications created with this tookit allow access to
Pro/INTRALINK information in a safe, controlled manner
© 2000 PTC 4
AgendaAgenda
Introduction to Pro/INTRALINK Toolkit (50min) Custom Applications
License Requirements Types of Custom Applications Examples
Pro/INTRALINK APIs
Pro/INTRALINK Object
Object Types
Introduction to Pro/INTRALINK Toolkit (50min) Custom Applications
License Requirements Types of Custom Applications Examples
Pro/INTRALINK APIs
Pro/INTRALINK Object
Object Types
© 2000 PTC 5
Developing Custom ApplicationsDeveloping Custom Applications
To automate set of tasks required for Pro/INTRALINK users, you will need:
Purchase one Application Programming Module per site to produce custom applications.
After developed, applications that access the data server will need a run-time license (which license depends upon the type of application created).
Run time licenses (not interchangeable): Pro/INTRALINK Client (Triggered)
Pro/INTRALINK Toolkit Access License (Stand Alone) Both run-time licenses are:
Floating
Served from FlexLM server
To automate set of tasks required for Pro/INTRALINK users, you will need:
Purchase one Application Programming Module per site to produce custom applications.
After developed, applications that access the data server will need a run-time license (which license depends upon the type of application created).
Run time licenses (not interchangeable): Pro/INTRALINK Client (Triggered)
Pro/INTRALINK Toolkit Access License (Stand Alone) Both run-time licenses are:
Floating
Served from FlexLM server
© 2000 PTC 6
Types of Custom ApplicationsTypes of Custom Applications
Stand Alone Access Workspace
Uses: Modify versioned system and user-defined object attributes
inside of a workspace Create new objects in the workspace Can be run before/after Pro/E save with a mixed toolkit
application No run time license required (provided do not need to
connect to data server) Userguide Examples:
Modifying Attributes Listing Workspace(next slide) Modifying Library Objects Mixed TK application Creating new objects, etc.
Stand Alone Access Workspace
Uses: Modify versioned system and user-defined object attributes
inside of a workspace Create new objects in the workspace Can be run before/after Pro/E save with a mixed toolkit
application No run time license required (provided do not need to
connect to data server) Userguide Examples:
Modifying Attributes Listing Workspace(next slide) Modifying Library Objects Mixed TK application Creating new objects, etc.
© 2000 PTC 7
Workspace Stand Alone Application - Listing Contents of WorkspaceWorkspace Stand Alone Application - Listing Contents of Workspace/*==============================================================*\
FILE : TestListWS.c
PURPOSE : Lists the workspace objects.
\*=============================================================*/
#include <prointlnk.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "UsGuidType.h"
#include "PDMTestError.h"
/*--------------------------------------------------------------*\
Function declarations
\*--------------------------------------------------------------*/
static void PDMTestWSContentsPrint( HPDMWORKSPACE ws );
/*--------------------------------------------------------------*\
Global workspace
\*--------------------------------------------------------------*/
static HPDMWORKSPACE WS;
/*==============================================================*\
Function: main
Purpose: Prints the contents of the workspace. It requires
the workspace name as input.
\*==============================================================*/
int main(int argc, const char* argv[])
{
HPDMPDM pdm;
HPDMLDB ldb;
PTCERROR err;
PTCSTRING wsname;
ilhw_main();
PDMTestErrlogOpen( "report.log" );
WS = NULL_HPDMWORKSPACE; /* Initialize the static. */
/*--------------------------------------------------------------*\
Check the command-line arguments.
\*--------------------------------------------------------------*/
if (argc != 2)
{
printf("Usage: %s <workspace name>\n", argv[0]);
exit(1);
}
wsname = argv[1];
/*--------------------------------------------------------------*\
Take a license and connect to Pro/INTRALINK.
\*--------------------------------------------------------------*/
err = PDMTakeLicense();
if(err)
{
printf("\t\tCould not take a license to connect to PDM\n");
exit(1);
}
err = PDMConnectToPDM("INTRALINK", "INTRALINK", &pdm);
if(err)
{
printf("Could not connect to PDM\n");
PDMReleaseLicense();
exit(1);
}
/*--------------------------------------------------------------*\
Connect to the LDB. The LDB path is ./PROI-EXAMPLE-LDB, so
the LDB must have a name PROI-EXAMPLE-LDB and must exist in this
directory so the application can connect to it.
\*--------------------------------------------------------------*/
err = PDMLDBConnect (".|PROI-EXAMPLE-LDB", &ldb);
if(err)
{
printf ("Could not connect to the database\n");
PDMReleaseLicense();
exit(1);
}
PDMLDBStartTransaction(ldb);
/*--------------------------------------------------------------*\
Get the workspace.
\*--------------------------------------------------------------*/
err = PDMLDBGetWorkspaceByName(ldb, wsname, &WS);
if(err)
{
printf("Could not find the workspace\n");
PDMReleaseLicense();
exit(1);
}
/*--------------------------------------------------------------*\
Print the investigated contents of the workspace.
\*--------------------------------------------------------------*/
PDMTestWSContentsPrint(WS);
err = PDMLDBCommitTransaction(ldb);
PDMReleaseLicense();
return( 0 );
}
/*==============================================================*\
Function: PDMTestWSContentsPrint
Purpose: Gets the WSPIs in the workspace, finds the current
WSPIV for each WSPI, and lists the WSPIVs and the
dependencies.
\*==============================================================*/
static void PDMTestWSContentsPrint (HPDMWORKSPACE ws)
{
HPDMWSPI wspi;
HPDMWSDEPENDENCY wsdep;
HPDMCURSOR wspi_cursor, dep_cursor;
PTCSTRING part_name, revision, brnch, child_name,
*attr_names=NULL;
PTCINTEGER version, ctr, first_time, attrcount, ii, kk;
PDM_ATTR_VALUE attr_value;
PTCERROR err;
char er_chname[20];
/*--------------------------------------------------------------*\
Get the WSPIs.
\*--------------------------------------------------------------*/
err = PDMWorkspaceGetWSPIs(ws, &wspi_cursor);
if (!PDM_HANDLE_IS_NULL(wspi_cursor))
{
printf("The Workspace has following items\n\n" );
printf("Part Name Rev Ver Branch\n\n");
for (PDMCursorGetNext(wspi_cursor, &wspi);
!PDM_HANDLE_IS_NULL(wspi);
PDMCursorGetNext(wspi_cursor, &wspi))
{
/*--------------------------------------------------------------*\
Get additional information such as Name, Revision, and
Attributes.
\*--------------------------------------------------------------*/
err = PDMWSPIGetName(wspi, &part_name);
err = PDMWSPIGetCurrWSPIVSourceRevision( wspi, &revision );
err = PDMWSPIGetCurrWSPIVSourceVersion( wspi, &version );
err = PDMWSPIGetCurrWSPIVSourceBranchName( wspi, &brnch );
printf( "%-15s %-1s %3d %-7s\n",
part_name, revision, version, brnch );
err = PDMWSPIGetCurrWSPIVAttributeNames( wspi, &attrcount,
attr_names );
attr_names = (PTCSTRING *)calloc(1, attrcount);
for(kk = 0; kk<attrcount; kk++)
attr_names[kk] = (PTCSTRING)calloc(1, 80);
err = PDMWSPIGetCurrWSPIVAttributeNames( wspi, &attrcount,
attr_names );
if (attrcount) printf( "\tAttributes: " );
for (ii = 0; ii < attrcount; ii++)
{
if (ii > 0)
{
printf( ", " );
}
err = PDMWSPIGetCurrWSPIVAttribute (wspi, attr_names[ii],
&attr_value );
/*--------------------------------------------------------------*\
Print the attribute name and its value.
\*--------------------------------------------------------------*/
printf( "%s - ", attr_names[ii] );
if (attr_value.m_type == PDM_ATTR_TYPE_STRING)
{
printf( "%s", attr_value.m_value.m_string );
}
else if (attr_value.m_type == PDM_ATTR_TYPE_REAL)
{
printf( "%g", attr_value.m_value.m_real );
}
else if (attr_value.m_type == PDM_ATTR_TYPE_INTEGER)
{
printf( "%d", attr_value.m_value.m_integer );
}
else if (attr_value.m_type == PDM_ATTR_TYPE_BOOL)
{
printf( "%d", attr_value.m_value.m_bool );
}
}
for(kk = 0; kk<attrcount; kk++)
free ((void *)attr_names[kk]);
free ((void *)attr_names);
attr_names = NULL;
if (attrcount) printf( "\n" );
err = PDMWSPIGetCurrWSPIVDependencies( wspi, &dep_cursor );
ctr = 1;
first_time = TRUE;
/*--------------------------------------------------------------*\
Initialize the variable er_chname.
\*--------------------------------------------------------------*/
memset( er_chname, '\0', 20 );
/*--------------------------------------------------------------*\
Print the dependency child name and the number of dependencies
with that child.
\*--------------------------------------------------------------*/
for (PDMCursorGetNext(dep_cursor, &wsdep);
!PDM_HANDLE_IS_NULL(wsdep);
PDMCursorGetNext(dep_cursor, &wsdep))
{
if (first_time) printf( "\tDependencies: " );
err = PDMWSDependencyGetChildName( wsdep, &child_name );
if (!strcmp( er_chname, child_name ))
{
ctr = ctr + 1;
}
else
{
if (!first_time)
{
printf( "%s(%d), ", er_chname, ctr );
ctr = 1;
}
}
strcpy( er_chname, child_name );
first_time = FALSE;
}
if (!first_time)
{
printf( "%s(%d)\n\n", er_chname, ctr );
}
else
{
printf( "\n" );
}
err = PDMCursorDelete(dep_cursor);
}
err = PDMCursorDelete(wspi_cursor);
}
else
{
printf( "The workspace is empty\n" );
}
}
/* End of listws *\
/*==============================================================*\
FILE : TestListWS.c
PURPOSE : Lists the workspace objects.
\*=============================================================*/
#include <prointlnk.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "UsGuidType.h"
#include "PDMTestError.h"
/*--------------------------------------------------------------*\
Function declarations
\*--------------------------------------------------------------*/
static void PDMTestWSContentsPrint( HPDMWORKSPACE ws );
/*--------------------------------------------------------------*\
Global workspace
\*--------------------------------------------------------------*/
static HPDMWORKSPACE WS;
/*==============================================================*\
Function: main
Purpose: Prints the contents of the workspace. It requires
the workspace name as input.
\*==============================================================*/
int main(int argc, const char* argv[])
{
HPDMPDM pdm;
HPDMLDB ldb;
PTCERROR err;
PTCSTRING wsname;
ilhw_main();
PDMTestErrlogOpen( "report.log" );
WS = NULL_HPDMWORKSPACE; /* Initialize the static. */
/*--------------------------------------------------------------*\
Check the command-line arguments.
\*--------------------------------------------------------------*/
if (argc != 2)
{
printf("Usage: %s <workspace name>\n", argv[0]);
exit(1);
}
wsname = argv[1];
/*--------------------------------------------------------------*\
Take a license and connect to Pro/INTRALINK.
\*--------------------------------------------------------------*/
err = PDMTakeLicense();
if(err)
{
printf("\t\tCould not take a license to connect to PDM\n");
exit(1);
}
err = PDMConnectToPDM("INTRALINK", "INTRALINK", &pdm);
if(err)
{
printf("Could not connect to PDM\n");
PDMReleaseLicense();
exit(1);
}
/*--------------------------------------------------------------*\
Connect to the LDB. The LDB path is ./PROI-EXAMPLE-LDB, so
the LDB must have a name PROI-EXAMPLE-LDB and must exist in this
directory so the application can connect to it.
\*--------------------------------------------------------------*/
err = PDMLDBConnect (".|PROI-EXAMPLE-LDB", &ldb);
if(err)
{
printf ("Could not connect to the database\n");
PDMReleaseLicense();
exit(1);
}
PDMLDBStartTransaction(ldb);
/*--------------------------------------------------------------*\
Get the workspace.
\*--------------------------------------------------------------*/
err = PDMLDBGetWorkspaceByName(ldb, wsname, &WS);
if(err)
{
printf("Could not find the workspace\n");
PDMReleaseLicense();
exit(1);
}
/*--------------------------------------------------------------*\
Print the investigated contents of the workspace.
\*--------------------------------------------------------------*/
PDMTestWSContentsPrint(WS);
err = PDMLDBCommitTransaction(ldb);
PDMReleaseLicense();
return( 0 );
}
/*==============================================================*\
Function: PDMTestWSContentsPrint
Purpose: Gets the WSPIs in the workspace, finds the current
WSPIV for each WSPI, and lists the WSPIVs and the
dependencies.
\*==============================================================*/
static void PDMTestWSContentsPrint (HPDMWORKSPACE ws)
{
HPDMWSPI wspi;
HPDMWSDEPENDENCY wsdep;
HPDMCURSOR wspi_cursor, dep_cursor;
PTCSTRING part_name, revision, brnch, child_name,
*attr_names=NULL;
PTCINTEGER version, ctr, first_time, attrcount, ii, kk;
PDM_ATTR_VALUE attr_value;
PTCERROR err;
char er_chname[20];
/*--------------------------------------------------------------*\
Get the WSPIs.
\*--------------------------------------------------------------*/
err = PDMWorkspaceGetWSPIs(ws, &wspi_cursor);
if (!PDM_HANDLE_IS_NULL(wspi_cursor))
{
printf("The Workspace has following items\n\n" );
printf("Part Name Rev Ver Branch\n\n");
for (PDMCursorGetNext(wspi_cursor, &wspi);
!PDM_HANDLE_IS_NULL(wspi);
PDMCursorGetNext(wspi_cursor, &wspi))
{
/*--------------------------------------------------------------*\
Get additional information such as Name, Revision, and
Attributes.
\*--------------------------------------------------------------*/
err = PDMWSPIGetName(wspi, &part_name);
err = PDMWSPIGetCurrWSPIVSourceRevision( wspi, &revision );
err = PDMWSPIGetCurrWSPIVSourceVersion( wspi, &version );
err = PDMWSPIGetCurrWSPIVSourceBranchName( wspi, &brnch );
printf( "%-15s %-1s %3d %-7s\n",
part_name, revision, version, brnch );
err = PDMWSPIGetCurrWSPIVAttributeNames( wspi, &attrcount,
attr_names );
attr_names = (PTCSTRING *)calloc(1, attrcount);
for(kk = 0; kk<attrcount; kk++)
attr_names[kk] = (PTCSTRING)calloc(1, 80);
err = PDMWSPIGetCurrWSPIVAttributeNames( wspi, &attrcount,
attr_names );
if (attrcount) printf( "\tAttributes: " );
for (ii = 0; ii < attrcount; ii++)
{
if (ii > 0)
{
printf( ", " );
}
err = PDMWSPIGetCurrWSPIVAttribute (wspi, attr_names[ii],
&attr_value );
/*--------------------------------------------------------------*\
Print the attribute name and its value.
\*--------------------------------------------------------------*/
printf( "%s - ", attr_names[ii] );
if (attr_value.m_type == PDM_ATTR_TYPE_STRING)
{
printf( "%s", attr_value.m_value.m_string );
}
else if (attr_value.m_type == PDM_ATTR_TYPE_REAL)
{
printf( "%g", attr_value.m_value.m_real );
}
else if (attr_value.m_type == PDM_ATTR_TYPE_INTEGER)
{
printf( "%d", attr_value.m_value.m_integer );
}
else if (attr_value.m_type == PDM_ATTR_TYPE_BOOL)
{
printf( "%d", attr_value.m_value.m_bool );
}
}
for(kk = 0; kk<attrcount; kk++)
free ((void *)attr_names[kk]);
free ((void *)attr_names);
attr_names = NULL;
if (attrcount) printf( "\n" );
err = PDMWSPIGetCurrWSPIVDependencies( wspi, &dep_cursor );
ctr = 1;
first_time = TRUE;
/*--------------------------------------------------------------*\
Initialize the variable er_chname.
\*--------------------------------------------------------------*/
memset( er_chname, '\0', 20 );
/*--------------------------------------------------------------*\
Print the dependency child name and the number of dependencies
with that child.
\*--------------------------------------------------------------*/
for (PDMCursorGetNext(dep_cursor, &wsdep);
!PDM_HANDLE_IS_NULL(wsdep);
PDMCursorGetNext(dep_cursor, &wsdep))
{
if (first_time) printf( "\tDependencies: " );
err = PDMWSDependencyGetChildName( wsdep, &child_name );
if (!strcmp( er_chname, child_name ))
{
ctr = ctr + 1;
}
else
{
if (!first_time)
{
printf( "%s(%d), ", er_chname, ctr );
ctr = 1;
}
}
strcpy( er_chname, child_name );
first_time = FALSE;
}
if (!first_time)
{
printf( "%s(%d)\n\n", er_chname, ctr );
}
else
{
printf( "\n" );
}
err = PDMCursorDelete(dep_cursor);
}
err = PDMCursorDelete(wspi_cursor);
}
else
{
printf( "The workspace is empty\n" );
}
}
/* End of listws *\
© 2000 PTC 8
Types of Custom ApplicationsTypes of Custom Applications
Stand Alone Applications Con’t Access Commonspace Data Server
Uses: Perform Queries Check Out Objects Check In Objects Modify Non-versioned system and user-defined attributes (e.g.
Rename, Promote, Demote, Modify Life Cycle Attributes) Requires the run-time license, Toolkit Access Userguide examples: Create a BOM (next slide), Finding an
object, Finding dependencies based on configuration, Check Out any object, etc.
Import/Export to/from Workspace Use new 3.0 APIs to exchange Pro/ENGINEER files with the
Workspace Requires the run-time license, Toolkit Access
Stand Alone Applications Con’t Access Commonspace Data Server
Uses: Perform Queries Check Out Objects Check In Objects Modify Non-versioned system and user-defined attributes (e.g.
Rename, Promote, Demote, Modify Life Cycle Attributes) Requires the run-time license, Toolkit Access Userguide examples: Create a BOM (next slide), Finding an
object, Finding dependencies based on configuration, Check Out any object, etc.
Import/Export to/from Workspace Use new 3.0 APIs to exchange Pro/ENGINEER files with the
Workspace Requires the run-time license, Toolkit Access
© 2000 PTC 9
Standalone Data Server Application - BOM ExampleStandalone Data Server Application - BOM Example
/*=============================================================*\
FILE : TestShowBom.c
PURPOSE : Creates a bill of materials (BOM).
\*=============================================================*/
#include <prointlnk.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <UsGuidType.h>
#include <PDMTestError.h>
static PTCINTEGER BOMPartCount = 0;
static BOMPartInfo BOMParts[BOM_MAX_PARTS];
static BOMPartInfo* BOMPartList[BOM_MAX_PARTS];
/*-------------------------------------------------------------*\
Function declarations
\*-------------------------------------------------------------*/
static void PDMTestBOMCompute(PTCSTRING part_name, PTCSTRING revision);
static void PDMTestDepGraphWalk(HPDMDEPENDENCYGRAPH depgraph,
HPDMPIV piv);
static void PDMTestBOMAddPIV(HPDMPIV piv);
static void PDMTestBOMPrint();
static int PDMTestBOMCompareParts(const void* p1, const void* p2);
static HPDMPIV PDMTestLatestPIVFind(PTCSTRING part_name,
PTCSTRING revision);
/*=============================================================*\
Function: main
Purpose: Output a BOM list for the specified part name and
revision.
\*=============================================================*/
int main(int argc, const char* argv[])
{
HPDMPDM pdm;
PTCSTRING part_name, revision;
PTCERROR err;
ilhw_main();
PDMTestErrlogOpen("report.log");
if (argc < 2 || argc > 3)
{
printf("Usage: %s <part name> [<revision>]\n", argv[0]);
exit(1);
}
part_name = argv[1];
revision = (argc == 3) ? argv[2] : NULL;
/*--------------------------------------------------------------*\
Take a license.
\*-------------------------------------------------------------*/
err = PDMTakeLicense();
if (err != PDM_SUCCESS)
{
printf("Failed to take a license.\n");
exit(1);
}
/*-------------------------------------------------------------*\
Connect to the database.
\*-------------------------------------------------------------*/
printf("Connecting to PDM...\n");
err = PDMConnectToPDM("INTRALINK", "INTRALINK", &pdm);
if (err != PDM_SUCCESS)
{
printf("Failed to connect.\n");
PDMReleaseLicense();
exit(1);
}
printf("Connected.\n\n");
/*-------------------------------------------------------------*\
Compute the BOM for the part part_name with a given
revision.
\*-------------------------------------------------------------*/
PDMTestBOMCompute(part_name, revision);
/*-------------------------------------------------------------*\
Print the BOM.
\*-------------------------------------------------------------*/
PDMTestBOMPrint();
err = PDMReleaseLicense();
return(0);
}
© 2000 PTC 10
•Types of Custom Applications Con’t•Types of Custom Applications Con’t
Triggers Invoked automatically by the Pro/INTRALINK client based
upon an action in the client
Timing may be Pre (before) or Post (after) the event
Required Pre triggers abort the user invoked action if they fail
May have more than one trigger for the same event and timing. (Order executed is random)
Cannot modify objects in CS from within a trigger
Requires that the client session that invoked the trigger still has a Client License
Userguide examples: Trigger Administration, Trigger sample for different events and timing.
Consulting example of launching another application from a trigger (see next page).
Triggers Invoked automatically by the Pro/INTRALINK client based
upon an action in the client
Timing may be Pre (before) or Post (after) the event
Required Pre triggers abort the user invoked action if they fail
May have more than one trigger for the same event and timing. (Order executed is random)
Cannot modify objects in CS from within a trigger
Requires that the client session that invoked the trigger still has a Client License
Userguide examples: Trigger Administration, Trigger sample for different events and timing.
Consulting example of launching another application from a trigger (see next page).
© 2000 PTC 11
Trigger Calling External App ExampleTrigger Calling External App Example
Exercise 14
Write a program to handle Post Promotion Trigger. Create the trigger manually in Pro/INTRALINK Admin section. Register the trigger in the DLL. Upon the execution, collect the defined set of attribute values for the object/objects. Write a text file indicating the object name and its attribute values.
Launch a separate application from the trigger. Read a configuration file and login to the Intralink database. Upon checking the permissions for the user and the object, end the application.
Exercise 14
Write a program to handle Post Promotion Trigger. Create the trigger manually in Pro/INTRALINK Admin section. Register the trigger in the DLL. Upon the execution, collect the defined set of attribute values for the object/objects. Write a text file indicating the object name and its attribute values.
Launch a separate application from the trigger. Read a configuration file and login to the Intralink database. Upon checking the permissions for the user and the object, end the application.
/*==================================================================*\Function : createNewTrigger()Purpose : To create trigger for revision change and registering its
dll funtion definition library.\*==================================================================*/int createNewTrigger(){
HPDMTRIGGER trigger = NULL_HPDMTRIGGER;int err = 0;
err = PDMTriggerCreate("RevisionChange", PDM_ET_PIV_RLCHANGE,PDM_TT_PRE, "", 1, 0, &trigger);
err = PDMTriggerSetDLLInfo(trigger, "releasechange", "changeRevision", "");
return err;}/*==================================================================*\Function : PDMDLLInit()Purpose : To register the trigger.\*==================================================================*/#if OSS_OS == OSS_WIN32__declspec( dllexport ) int PDMDLLInit()#elseint PDMDLLInit()#endif{
int err = 0;
err = PDMTriggerRegister("modifyRecord", modifyRecord);
return err;}/*==================================================================*\Function : modifyRecord()Purpose : Post trigger for Release level change.\*==================================================================*/int modifyRecord(int argc, void **argv){
HPDMPI piHandle = NULL_HDPMPI;HPDMPIV piv = NULL_HPDMPIV;int loop = 0, err = 0, id = 0;PTCSTRING piName;char **argvSpawn = NULL;int argcSpawn = 2;HPDMPARTICIPANT partyHandle = NULL_HPDMPARTICIPANT;HPDMRELEASELEVEL sourceRL = NULL_HPDMRELEASELEVEL,
targetRL = NULL_HPDMRELEASELEVEL;PTCSTRING sourceRLName, targetRLName,
desc,creator,modifName;PTCINTEGER seqNum = 0;PTCDATETIME createdateTime, modDateTime;HPDMRELEASESCHEME relSchema = NULL_HPDMRELEASESCHEME;
argvSpawn = (char**)calloc(sizeof(char*),argc+2);for(loop = 0;loop < (argc+2); loop++)
argvSpawn[loop] = (char*)calloc(sizeof(char), PRO_NAME_SIZE);
strcpy(argvSpawn[0], ".\\proitriggers\\attributes.exe");
for(loop = 0;loop < argc; loop++){
partyHandle = *((HPDMPARTICIPANT *)argv[loop]);err = PDMParticipantGetPIV(partyHandle,&piv);
PDMPIVGetPI(piv, &piHandle);
err=PDMPIGetName(piHandle, &piName);
if(checkIfDrawing(piHandle)){
/*-----------------------------------------------------*\Get Target level andtarget release level info
\*----------------------------------------------------*/
err = PDMParticipantGetTargetRL(partyHandle,&targetRL);
err = PDMReleaseLevelGetInfo(targetRL,&targetRLName, &desc,&seqNum, &relSchema,&createdateTime, &creator, &modDateTime,&modifName);
err = PDMPIVGetReleaseLevel(piv, &sourceRL);
err = PDMReleaseLevelGetInfo(sourceRL,&sourceRLName, &desc,&seqNum, &relSchema,&createdateTime, &creator, &modDateTime,&modifName);
if((!strcmp(sourceRLName, "APPROVE"))&& (!strcmp(targetRLName, "RELEASE")))//err == RELEASE)
{strcpy(argvSpawn[1], "RELEASE");/*Add PIName to the list.*/strcpy(argvSpawn[argcSpawn], piName);argcSpawn ++;
}
}/*if it is drawing*/}//for loop
argvSpawn[argcSpawn] = NULL;if(argcSpawn > 2)/* if there is any PI with RELEASE release level*/{
/* Spawn new process to increase revisions for each of the PI*/#if OSS_OS == OSS_WIN32err = _spawnvp(_P_NOWAIT , argvSpawn[0], argvSpawn);#elseid = fork();if(id > 0)
_execvp(argvSpawn[0], argvSpawn);#endif
}for(loop = 0;loop < (argc+2); loop++)
free(argvSpawn[loop]);free(argvSpawn);
return (0);}/*==================================================================*\Function : checkIfDrawing()Purpose : Check if the given PI is a drawing or not.\*==================================================================*/int checkIfDrawing(HPDMPI pi){
HPDMPITYPEDEF type_def = NULL_HPDMPITYPEDEF;PTCSTRING type_name;char out[256];int err = 0;
// Identify object type. err = PDMPIGetTypeDef(pi, &type_def);
if (PDM_HANDLE_IS_NULL(type_def)) { sprintf(out, "TypeDef handle is null.\n"); }
err = PDMPITypeDefGetName(type_def, &type_name);
if(!strcmp(type_name, "Drawing") )return 1;
else return 0;
}
© 2000 PTC 12
AgendaAgenda
Introduction to Pro/INTRALINK Toolkit (50min) Custom Applications
Pro/INTRALINK APIs API Background API Naming Conventions
Pro/INTRALINK Objects
Object Types
Introduction to Pro/INTRALINK Toolkit (50min) Custom Applications
Pro/INTRALINK APIs API Background API Naming Conventions
Pro/INTRALINK Objects
Object Types
© 2000 PTC 13
Pro/INTRALINK APIsPro/INTRALINK APIs
Same APIs as used to create Pro/INTRALINK client C functions available through these libraries:
proilcspace
proilwspace
proilbase
proicommon Structured as object oriented functions
(i.e. functions based on the object, and a different function to do appropriate actions on the object)
APIs are named with this format: PDM<object_type><action><what_acted_upon>
PDMPIVDelete or PDMPIVGetDependencies
Action names are listed in Userguide on p1-6 thru 1-8
Object names (next slide)
Same APIs as used to create Pro/INTRALINK client C functions available through these libraries:
proilcspace
proilwspace
proilbase
proicommon Structured as object oriented functions
(i.e. functions based on the object, and a different function to do appropriate actions on the object)
APIs are named with this format: PDM<object_type><action><what_acted_upon>
PDMPIVDelete or PDMPIVGetDependencies
Action names are listed in Userguide on p1-6 thru 1-8
Object names (next slide)
© 2000 PTC 14
AgendaAgenda
Introduction to Pro/INTRALINK Toolkit (50min) Custom Applications
Pro/INTRALINK APIs
Pro/INTRALINK Objects Commonspace Objects
PI, PIV, Branch, etc. LO, LOV, GIR, etc. Pro/ADMIN Objects (FileSpace, UserGroup, etc.)
Workspace Objects Object Types
Introduction to Pro/INTRALINK Toolkit (50min) Custom Applications
Pro/INTRALINK APIs
Pro/INTRALINK Objects Commonspace Objects
PI, PIV, Branch, etc. LO, LOV, GIR, etc. Pro/ADMIN Objects (FileSpace, UserGroup, etc.)
Workspace Objects Object Types
© 2000 PTC 15
Pro/INTRALINK ObjectsPro/INTRALINK Objects
Objects Stored In Commonspace Attribute Branch (see next slide) Baseline Configuration (discussed later in 2nd half of the class) Folder GIR - Generic Instance Relationship (see LO slide) LO - Library Object (see slide after PI) LOV - Library Object Version (see slide after PI) OQL - Object Query PI - Product Item (see next slide) PIV - Product Item Version (see next slide) PromotionForm Release Level ReleaseScheme SubmissionForm
Objects Stored In Commonspace Attribute Branch (see next slide) Baseline Configuration (discussed later in 2nd half of the class) Folder GIR - Generic Instance Relationship (see LO slide) LO - Library Object (see slide after PI) LOV - Library Object Version (see slide after PI) OQL - Object Query PI - Product Item (see next slide) PIV - Product Item Version (see next slide) PromotionForm Release Level ReleaseScheme SubmissionForm
© 2000 PTC 16
PI StructurePI Structure
PI (Product Item) Created on CheckIn ONLY
Contains Name, TypeDef, Folder, AttrClass, Description, etc.
Structure
PI (Product Item) Created on CheckIn ONLY
Contains Name, TypeDef, Folder, AttrClass, Description, etc.
Structure
Branch_one
main
Rev A V.1
Rev A V.2
Rev C V.5
Rev AA V.1
Rev BB V.1
Bolt.prt
© 2000 PTC 17
Structure of Family Table ObjectsStructure of Family Table Objects
Pro/INTRALINK allows independent versioning of family table objects. As a result, the Library Object was created
The Family Table is the basic definition of the generic and all instances for that Family Table. Likewise, the Library Object in Pro/INTRALINK contains the PIVs for the generic and its instances.
For each Library Object, you can have many versions. Any time you check in a new version of a member of that family table (whether it is the generic or an instance) a new Library Object Version (LOV) is created.
The LOV is a bin that contains the specific PIVs created when you check in an object with a family table (next slide)
If you delete one of the PIVs of a family table, then ALL LOVs that contain that PIV must be deleted.
Pro/INTRALINK allows independent versioning of family table objects. As a result, the Library Object was created
The Family Table is the basic definition of the generic and all instances for that Family Table. Likewise, the Library Object in Pro/INTRALINK contains the PIVs for the generic and its instances.
For each Library Object, you can have many versions. Any time you check in a new version of a member of that family table (whether it is the generic or an instance) a new Library Object Version (LOV) is created.
The LOV is a bin that contains the specific PIVs created when you check in an object with a family table (next slide)
If you delete one of the PIVs of a family table, then ALL LOVs that contain that PIV must be deleted.
© 2000 PTC 18
Library Object StructureLibrary Object Structure
LOV 1 LOV 2 LOV 3 LOV 4LO
PIV A1
PIV B1
PIV C1
PIV A2
PIV B1
PIV C1
PIV A2
PIV B1
PIV A2
PIV B2
PIV D1PIV E1
© 2000 PTC 19
Pro/INTRALINK Objects con’tPro/INTRALINK Objects con’t
Objects Associated with Pro/ADMIN AttrClass AttrDef Attribute FileSpaceReplica FileVault Folder LCO - Life Cycle Object LCOV - Life Cycle Object Version Role User UserGroup
Objects Associated with Pro/ADMIN AttrClass AttrDef Attribute FileSpaceReplica FileVault Folder LCO - Life Cycle Object LCOV - Life Cycle Object Version Role User UserGroup
© 2000 PTC 22
Pro/INTRALINK Objects con’tPro/INTRALINK Objects con’t
Objects Associated with Workspace: LDB - Local Data Base
Workspace
WSDependency
WSGIR
LIL
LILV
WSPI
WSPIV
Objects Associated with Workspace: LDB - Local Data Base
Workspace
WSDependency
WSGIR
LIL
LILV
WSPI
WSPIV
The structure of these objects is the same as those previously discussed. Naming conventions are different because user may perform different actions on these objects when they are in the Workspace.
© 2000 PTC 23
Pro/INTRALINK Objects - AttrClassPro/INTRALINK Objects - AttrClass
Attribute Classes, AttrClass Attribute classes (AttrClass) are logical objects that contain the
definitions of attributes (AttrDef) .
Can create a hierarchy of AttrClasses for PIs and PIVs
Objects are associated with at least one AttrClass
If the AttrClass is a sub-attribute class and you assign it to a PI or PIV, then the object will also be assigned the AttrDefs of the parent AttrClasses.
Only attributes in the RootAttributeClass are visible in the client.
Tools Create - PDMAttrClassCreate Find Root for PI - PDMPIGetRootAttrClass To add/remove for a PI - PDMPIAddAttrClass,
PDMPIRemoveAttrClass
Attribute Classes, AttrClass Attribute classes (AttrClass) are logical objects that contain the
definitions of attributes (AttrDef) .
Can create a hierarchy of AttrClasses for PIs and PIVs
Objects are associated with at least one AttrClass
If the AttrClass is a sub-attribute class and you assign it to a PI or PIV, then the object will also be assigned the AttrDefs of the parent AttrClasses.
Only attributes in the RootAttributeClass are visible in the client.
Tools Create - PDMAttrClassCreate Find Root for PI - PDMPIGetRootAttrClass To add/remove for a PI - PDMPIAddAttrClass,
PDMPIRemoveAttrClass
© 2000 PTC 24
Attribute StructureAttribute Structure
PI - RootAttributeClass
AttrDef “TeamMembs”
IntegerDefault Value = 4
PI - AttrClass“Motor”
AttrDef “Designer”
StringDefault Value = tbd
PI - AttrClass“ForEurope”
AttrDef “Country”
StringRange: France
ItalyGermany
AttrDef “OnSchedule”
BooleanDefault Value = True
AttrDef “Cost”Real
© 2000 PTC 25
Pro/INTRALINK Objects - AttrDefPro/INTRALINK Objects - AttrDef
Attribute Definitions, AttrDef Defines the definition of the attribute: Name, AttrClass, Type
and optionally Description and Default Value.
Non-versioned or versioned.
Non-versioned attributes are associated with the PI and versioned with the PIV
FileBased (I.e. Pro/ENGINEER designated attributes)
Naming and value limitations of 32 lowercase characters + “_” Restrictions - EnumRestriction or RangeRestriction
Can set a list of discrete values or a range values Tips:
Whether versioned or not determined by how you created the AttrDef - PDMAttrDefCreate, PDMAttrDefCreateVersioned
By default all versioned attributes for PIVs are file based (designated in Pro/E). To change use PDMAttrDefSetFileBased.
Attribute Definitions, AttrDef Defines the definition of the attribute: Name, AttrClass, Type
and optionally Description and Default Value.
Non-versioned or versioned.
Non-versioned attributes are associated with the PI and versioned with the PIV
FileBased (I.e. Pro/ENGINEER designated attributes)
Naming and value limitations of 32 lowercase characters + “_” Restrictions - EnumRestriction or RangeRestriction
Can set a list of discrete values or a range values Tips:
Whether versioned or not determined by how you created the AttrDef - PDMAttrDefCreate, PDMAttrDefCreateVersioned
By default all versioned attributes for PIVs are file based (designated in Pro/E). To change use PDMAttrDefSetFileBased.
© 2000 PTC 26
Pro/INTRALINK Objects - AttributePro/INTRALINK Objects - Attribute
Attributes contain the actual value for the object they are associated
Non-versioned attributes may be modified in the CS.
Versioned attributes must be modified in the WS.
All functions associated with querying and setting attributes follow this template:
PDM<object>GetAtrribute PDM<object>SetAttribute
Tip:
Setting Attribute functions return PTCERROR. If you receive an error, check for value restrictions in the AttrDef.
PDM<object>GetAttribute returns a handle to the AttrDef.
Attributes contain the actual value for the object they are associated
Non-versioned attributes may be modified in the CS.
Versioned attributes must be modified in the WS.
All functions associated with querying and setting attributes follow this template:
PDM<object>GetAtrribute PDM<object>SetAttribute
Tip:
Setting Attribute functions return PTCERROR. If you receive an error, check for value restrictions in the AttrDef.
PDM<object>GetAttribute returns a handle to the AttrDef.
© 2000 PTC 28
AgendaAgenda
Introduction to Pro/INTRALINK Toolkit (50min) Custom Applications
Pro/INTRALINK APIs
Pro/INTRALINK Object
Object Types Handles Cursors Errors
Introduction to Pro/INTRALINK Toolkit (50min) Custom Applications
Pro/INTRALINK APIs
Pro/INTRALINK Object
Object Types Handles Cursors Errors
© 2000 PTC 29
Object TypesObject Types Mulitbyte Strings
const char
Used for any name used visible from the UI (name of PI, Workspace, etc.)
Type - PTCSTRING Integers
Used when passing integers like the revision, version
Type - PTCINTEGER Boolean
Integer of 1 or 0
Used often as a true/false return from an API
Type - PTCBOOL Real Numbers
double
Used often to define values for attributes
Type - PTCREAL
Mulitbyte Strings const char
Used for any name used visible from the UI (name of PI, Workspace, etc.)
Type - PTCSTRING Integers
Used when passing integers like the revision, version
Type - PTCINTEGER Boolean
Integer of 1 or 0
Used often as a true/false return from an API
Type - PTCBOOL Real Numbers
double
Used often to define values for attributes
Type - PTCREAL
© 2000 PTC 30
Intralink Object TypesIntralink Object Types
Handle Memory address
Used to specify objects (e.g. PI, PIV)
Tools PDM_HANDLE_IS_NULL PDM_HANDLE_SET_NULL PDM_HANDLE_CAST PDM_HANDLE_EQUAL
Available types:
HPDMPI, HPDMPIV, HPDMBRANCH, HPDMLOV, HPDMWORKSPACE, HPDMLDB, HPDMPDM, HPDMWSPI, HPDMATTRDEF, HPDMOQL, etc.
Handle Memory address
Used to specify objects (e.g. PI, PIV)
Tools PDM_HANDLE_IS_NULL PDM_HANDLE_SET_NULL PDM_HANDLE_CAST PDM_HANDLE_EQUAL
Available types:
HPDMPI, HPDMPIV, HPDMBRANCH, HPDMLOV, HPDMWORKSPACE, HPDMLDB, HPDMPDM, HPDMWSPI, HPDMATTRDEF, HPDMOQL, etc.
© 2000 PTC 31
Object Types - CursorsObject Types - Cursors
Cursor Memory Address
Used when API returns a list of handles
Temporary
Tools Traverse - PDMCursorGetNext Delete from memory - PDMCursorDelete
Type
HPDMCURSOR
Cursor Memory Address
Used when API returns a list of handles
Temporary
Tools Traverse - PDMCursorGetNext Delete from memory - PDMCursorDelete
Type
HPDMCURSOR
© 2000 PTC 32
Object Types - ErrorsObject Types - Errors
Error Integer
Type - PTCERROR
Values PDM_SUCCESS (0) PDMERR_ILLEGAL_HANDLE PDMERR_SYSTEM_ERROR PDMERR_ATTRVALUE_WRONG_TYPE PDM_PASSWORD_INCORRECT Error Codes found in cerror.h or in Reference Guide
Error Integer
Type - PTCERROR
Values PDM_SUCCESS (0) PDMERR_ILLEGAL_HANDLE PDMERR_SYSTEM_ERROR PDMERR_ATTRVALUE_WRONG_TYPE PDM_PASSWORD_INCORRECT Error Codes found in cerror.h or in Reference Guide
© 2000 PTC 33
Object Type - Errors Con’tObject Type - Errors Con’t
Error Stack
Cursor of Error Handles
Need a handle when the error returns more information than just an error code. E.g. error code plus handles of objects causing the error.
Tools for ErrorStack PDMErrorGetStack PDMErrorGetDetails PDMErrorDumpStack PDMErrorClearStack
Types HPDMERROR (handle) HPDMCURSOR
See Userguide Example p5-4
Error Stack
Cursor of Error Handles
Need a handle when the error returns more information than just an error code. E.g. error code plus handles of objects causing the error.
Tools for ErrorStack PDMErrorGetStack PDMErrorGetDetails PDMErrorDumpStack PDMErrorClearStack
Types HPDMERROR (handle) HPDMCURSOR
See Userguide Example p5-4
© 2000 PTC 34
Error Sample CodeError Sample Code
/*====================================================================*\
Function: ErrorHandle
Purpose: Handle errors.
\*====================================================================*/
static void ErrorHandle()
{
HPDMCURSOR errstack;
HPDMERROR errhandle;
PDM_ERROR_INFO errinfo;
PTCINTEGER i, ctr = 0;
FILE *fp;
/*--------------------------------------------------------------------*\
Get the error stack.
\*--------------------------------------------------------------------*/
PDMErrorGetStack (&errstack);
if (!PDM_HANDLE_IS_NULL (errstack))
{
for (PDMCursorGetNext (errstack, &errhandle);
!PDM_HANDLE_IS_NULL (errhandle);
PDMCursorGetNext (errstack, &errhandle))
{
ctr++;
/*--------------------------------------------------------------------*\
Get the error information.
\*--------------------------------------------------------------------*/
PDMErrorGetDetails (errhandle, &errinfo);
printf (``For error stack %d\n'', ctr);
printf (``\tThe error code is %d\n'', errinfo.m_error_code);
for (i = 0; i < errinfo.m_argument_count; i++)
{
printf (``\tArgument %d - %s\n'', i+1, errinfo.m_arguments[i]);
}
}
}
else
{
printf (``The errorstack is empty\n'');
}
fp = fopen (``errors.out'', ``a'');
/*--------------------------------------------------------------------*\
Print the error stack to a file. If the NULL argument is used,
the stack is dumped on stdout (screen).
\*--------------------------------------------------------------------*/
PDMErrorDumpStack (fp);
PDMErrorClearStack ();
return;
}
© 2000 PTC 38
AgendaAgenda
Introduction to Pro/INTRALINK Toolkit (50min) Custom Applications
Pro/INTRALINK APIs
Pro/INTRALINK Object
Object Types
Break (15 min)
Introduction to Pro/INTRALINK Toolkit (50min) Custom Applications
Pro/INTRALINK APIs
Pro/INTRALINK Object
Object Types
Break (15 min)
© 2000 PTC 39
TriggersTriggers
Trigger Creation PDMTriggerCreate Parameters:
Name, Event Type, Trigger Type, Description, IsRequiredDLLTrigger DLL should be initiated using PDMDLLInit functionDLL Info
Tie up Trigger handle with DLL (Exercise 14)
PDMTriggerGetDLLInfo
Returning Trigger (some tips) Return success to avoid error dialog box and log separate
errors if any APIs generating more triggers not allowed Start a separate Toolkit application to have transactions Return Trigger immediately before launching another toolkit
application (Exercise 15)
Trigger Creation PDMTriggerCreate Parameters:
Name, Event Type, Trigger Type, Description, IsRequiredDLLTrigger DLL should be initiated using PDMDLLInit functionDLL Info
Tie up Trigger handle with DLL (Exercise 14)
PDMTriggerGetDLLInfo
Returning Trigger (some tips) Return success to avoid error dialog box and log separate
errors if any APIs generating more triggers not allowed Start a separate Toolkit application to have transactions Return Trigger immediately before launching another toolkit
application (Exercise 15)
© 2000 PTC 40
Workspace TransactionsWorkspace Transactions
Ensure integrity of local database on concurrent access
Important: references to any WS objects are valid ONLY inside one workspace transaction
Functions PDMLDBStartTransaction PDMLDBCommitTransaction PDMLDBAbortTransaction PDMIsLDBTransactionInProgress
Ensure integrity of local database on concurrent access
Important: references to any WS objects are valid ONLY inside one workspace transaction
Functions PDMLDBStartTransaction PDMLDBCommitTransaction PDMLDBAbortTransaction PDMIsLDBTransactionInProgress
© 2000 PTC 41
Commonspace TransactionsCommonspace Transactions
When to use Group of modifications of CS objects Need abort changes
Limitations of actions Check Out Delete (PI, PIV, Release Procedure) Purge Replicate Files
Functions PDMStartTransaction PDMCommitTransaction PDMAbortTransaction
Example
When to use Group of modifications of CS objects Need abort changes
Limitations of actions Check Out Delete (PI, PIV, Release Procedure) Purge Replicate Files
Functions PDMStartTransaction PDMCommitTransaction PDMAbortTransaction
Example
© 2000 PTC 42
Configuration ObjectsConfiguration Objects
What is a Configuration Object Contains a set of configuration rules
Every rule consists of scope and queryHow to create Configuration
Create configuration object PDMConfigurationCreate PDMConfigurationCreateFromFile
Add rule PDMConfigurationAddRule
When can it be used PDMPIVGetDepGraph
PDMConfigurationExecute
What is a Configuration Object Contains a set of configuration rules
Every rule consists of scope and queryHow to create Configuration
Create configuration object PDMConfigurationCreate PDMConfigurationCreateFromFile
Add rule PDMConfigurationAddRule
When can it be used PDMPIVGetDepGraph
PDMConfigurationExecute
© 2000 PTC 48
Questions?Questions?