Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Register Log in

Create drawing with J-link


New member
Hi All<?:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" />

I use a J-link application to export instances from a ProE assemblies to different formats. I want to extend the function of this application to also export different 2D-formats. The problem is that I do not get the createDrawingFromTemplate method (copied from the J-link documentation) to work. Have any of you guys used it?
A small part of the code:
Model solid = session.GetCurrentModel();
Drawing drw = session.CreateDrawingFromTemplate (newDrawingName, predefinedTemplate, solid.GetDescr(), options);

//Peter Altsten

PS I'm notaskilled java hacker, on the contrary a novice.


New member

I don't know J-Link but I do know Pro/Toolkit. Pro/Toolkit has an identical function which I have used regularly. My guess it that it is in your options or your model. Here is the code that I would use in Pro/Toolkit.

char*funcName&nbsp ;= "SetupPart()";
ProErrorpro_error& nbsp;= PRO_TK_NO_ERROR;
ProNamepro_tpltName&nbsp ;= L"blank";
ProDwgcreateOptionspro_dwgCreateOpt= PRODWGCREATE_DISPLAY_DRAWING;
ProDwgcreateErrspro_dwgCreateErr= NULL;

//Load the model
swprintf(pro_mdlPath, L"%S", genName);
pro_error = ProMdlRetrieve(pro_mdlPath, PRO_MDL_PART, &pro_dlgData.pro_mdl);
PROUTIL_CALL_REPORT("ProMdlRetrieve()", funcName, pro_error, pro_error!=PRO_TK_NO_ERROR);

//Get the mdl data
pro_error = ProMdlDataGet(pro_dlgData.pro_mdl, &pro_mdlData);
PROUTIL_CALL_REPORT("ProMdlDataGet()", funcName, pro_error, pro_error!=PRO_TK_NO_ERROR);

wcscpy(pro_model.name, pro_mdlData.name);
wcscpy(pro_model.type, pro_mdlData.type);

//Create a drawing
pro_error = ProDrawingFromTmpltCreate(pro_model.name, pro_tpltName, &pro_model,&nb sp;
pro_dwgCreateOpt, drawing,&pro_dwgCreateErr);&nbsp ;&nbsp ;
PROUTIL_CALL_REPORT("ProDrawingFromTmpltCreate()", funcName, pro_error, pro_error!=PRO_TK_NO_ERROR && pro_error!=PRO_TK_DWGCREATE_ERRORS);
if(pro_error == PRO_TK_DWGCREATE_ERRORS) {

//Print the drawing creation errors
pro_error = PrintDwgCreatErrors(&pro_dwgCreateErr);
PROUTIL_CALL_REPORT("PrintDwgCreatErrors()", funcName, pro_error, pro_error!=PRO_TK_NO_ERROR);


//Free the drawing creation errors
pro_error = ProDwgcreateErrsFree(&pro_dwgCreateErr);
PROUTIL_CALL_REPORT("ProDwgcreateErrsFree()", funcName, pro_error, pro_error!=PRO_TK_NO_ERROR);

//Display the drawing
pro_error = ProMdlDisplay(*drawing);
PROUTIL_CALL_REPORT("ProMdlDisplay()", funcName, pro_error, pro_error!=PRO_TK_NO_ERROR);