Proe5.0导出PDF至配置文件的相关方法,VC++

定义文件bcsMessage.txt

PLM
PLM
PLM
#

login
login
测试
#

Active messagebox menu
Active messagebox menu
激活菜单
#

将Menu文件放置与程序同级的text文件夹下

配置ini文件

[BCS]
Path=C:\3

将配置文件放置Proe的工作目录下

 

代码如下:

C++

// bcsproe.cpp : 定义 DLL 的初始化例程。
//

#include "stdafx.h"
#include "bcsproe.h"
#include "afx.h"

#include "ProMenu.h"
#include "ProUtil.h"
#include "ProMenubar.h"
#include "ProPDF.h"

static uiCmdAccessState AccessDefault (uiCmdAccessMode);
void login();
void exportpdf();

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CbcsproeApp

BEGIN_MESSAGE_MAP(CbcsproeApp, CWinApp)
END_MESSAGE_MAP()


// CbcsproeApp 构造

CbcsproeApp::CbcsproeApp()
{
	// TODO: 在此处添加构造代码,
	// 将所有重要的初始化放置在 InitInstance 中
}


// 唯一的一个 CbcsproeApp 对象

CbcsproeApp theApp;


// CbcsproeApp 初始化

BOOL CbcsproeApp::InitInstance()
{
	CWinApp::InitInstance();

	return TRUE;
}
extern "C" int user_initialize()
{
     ProError     status;
     ProFileName  message_file;
     uiCmdCmdId   cmd_id1;
	
     ProFileName MsgFile;
     ProStringToWstring(MsgFile, "bcsMessage.txt");
     status=ProMenubarMenuAdd ("PLM", "PLM","Utilities", PRO_B_TRUE, MsgFile);

	 //login
     status = ProCmdActionAdd("ShowTest1",(uiCmdCmdActFn)login,uiCmdPrioDefault,AccessDefault,
              PRO_B_TRUE,PRO_B_TRUE,&cmd_id1);

     status = ProMenubarmenuPushbuttonAdd("PLM", "login", "login","Active messagebox menu", NULL,
              PRO_B_TRUE, cmd_id1, ProStringToWstring(message_file, "bcsMessage.txt"));
	
	      return status;
}

extern "C" void user_terminate()
{
   AFX_MANAGE_STATE(AfxGetStaticModuleState());
}

/*================================================================*\
FUNCTION: AccessDefault()
\*================================================================*/
static uiCmdAccessState AccessDefault (uiCmdAccessMode access_mode)
{
    return (ACCESS_AVAILABLE);
}

void login()/消息框
{
	exportpdf();return;
}

void exportpdf()
{
	ProError err;
    ProPath current_path;
    char c_p[200];
    err=ProDirectoryCurrentGet(current_path);
    if (err!=PRO_TK_NO_ERROR)
	{
		AfxMessageBox(_T("未获取到Proe起始目录"));
        return;
	}
    ProWstringToString(c_p,current_path);
    CString  strcurrent_path = current_path;

	获取配置文件路径
	CString FileName =L"\\bcsConfiguration.ini"; 
	LPTSTR lpPath = new TCHAR[MAX_PATH];
	LPWSTR Path = new TCHAR[MAX_PATH];
	strcurrent_path = strcurrent_path + FileName;

	//AfxMessageBox(strcurrent_path);
	GetPrivateProfileString(L"BCS",L"Path",L"",Path,MAX_PATH,strcurrent_path);
	//AfxMessageBox(Path);
	if (_tcslen(Path) < 1)
    {
		AfxMessageBox(L"未找到配置信息!");
		return;
	}
	delete [] lpPath;

	ProPDFOptions  ops;
    ProPDFoptionsAlloc(&ops);

    ProMdl mdl;
	//获取文件名
    err = ProMdlCurrentGet(&mdl);
    if (PRO_TK_NO_ERROR != err)
	{
		AfxMessageBox(_T("当前没有文件打开"));
        return;
	}

    ProMode  mode;
    err = ProModeCurrentGet(&mode);
    if (err != PRO_TK_NO_ERROR)
    {
		AfxMessageBox(_T("未获取到当前打开文件"));
        return;
    }

    if (mode != PRO_MODE_DRAWING)
    {
        AfxMessageBox(_T("当前只支持DRW文件导出pdf"));
        return;
    }

    ProName name;
    err = ProMdlNameGet(mdl, name);
    CString cstrName = name;
	CString outfilepathname = Path;
	outfilepathname = outfilepathname +L"\\" + cstrName + L".pdf";
	//AfxMessageBox(outfilepathname.GetBuffer(0));

	//导出pdf
    ProPDFExport(mdl,outfilepathname.GetBuffer(0),ops);
    ProPDFoptionsFree(ops);
	AfxMessageBox(_T("导出完成!"));弹出一个消息框
}

 

下面是关于在Proe客户端的配置

定义注册文件

 Protk.dat

内容如下:

NAME		pt_inst_test
STARTUP		DLL
ALLOW_STOP	TRUE
DELAY_START	FALSE
EXEC_FILE	C:/Documents and Settings/Administrator/My Documents/bcsproe.dll
TEXT_DIR	C:/Documents and Settings/Administrator/My Documents/text
REVISION	1000
END


若想实现Proe自动注册,则将此文件放置Proe的安装目录的text文件下,例如:C:\Program Files\proeWildfire 5.0\text,具体路径根据自己安装目录指定

注:文件名必须为Protk不能更换

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值