二级士官
UID2941341
U币1
G币212
技术0
主题5
精华0
阅读权限40
注册时间2017-8-24
最后登录2019-4-10
在线时间44 小时
二级士官
|
file:///C:\Users\Administrator\AppData\Roaming\Tencent\Users\429570094\QQ\WinTemp\RichOle\E6SGE6ICVUU7M~8HXXQQY(0.png这是为啥,prt打不开这是我用nxopen导入stp形成的prt
/***
** VayoDFM2UG_prt.cpp
**
** Description:
** Contains Unigraphics entry points for the application.
**
*****************************************************************************/
/* Include files */
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
# include <strstream>
# include <iostream>
using std::ostrstream;
using std::endl;
using std::ends;
using std::cerr;
#else
# include <strstream.h>
# include <iostream.h>
#endif
#include <uf.h>
#include <uf_ui.h>
#include <uf_exit.h>
#include <uf_part.h>
#include <io.h>
#include <string.h>
#include <string>
#include <locale.h>
#include <stdlib.h>
#include <fstream>
#include <stdafx.h>
#include <uf_modl.h>
#include "uf_weight.h"
#include <uf_attr.h>
#include<uf_obj.h>
#include<UF_ASSEM.h>
#include "Step214Importer.hxx"
#include <uf_defs.h>
#include <NXOpen/NXException.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/BasePart.hxx>
#include <NXOpen/Builder.hxx>
#include <NXOpen/DexManager.hxx>
#include <NXOpen/FileNew.hxx>
#include <NXOpen/NXObject.hxx>
#include <NXOpen/ObjectTypeSelector.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/PartCloseResponses.hxx>
#include <NXOpen/PDM_PartFromTemplateBuilder.hxx>
#include <NXOpen/PDM_PartManager.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/Step214Importer.hxx>
using namespace NXOpen;
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
using namespace std;
static int report_error( char *file, int line, char *call, int irc)
{
if (irc)
{
char err[133],
msg[133];
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
irc, line, file);
UF_get_fail_message(irc, err);
UF_print_syslog(msg, FALSE);
UF_print_syslog(err, FALSE);
UF_print_syslog("\n", FALSE);
UF_print_syslog(call, FALSE);
UF_print_syslog(";\n", FALSE);
if (!UF_UI_open_listing_window())
{
UF_UI_write_listing_window(msg);
UF_UI_write_listing_window(err);
UF_UI_write_listing_window("\n");
UF_UI_write_listing_window(call);
UF_UI_write_listing_window(";\n");
}
}
return(irc);
}
CStringArray* SplitLine(CString source, CString division)
{
CString csflag;
CStringArray* dest = new CStringArray() ;
OutputDebugString(source);
OutputDebugString(L"\n");
dest->RemoveAll();
int pos = 0;
int pre_pos = 0;
int iCount_1=0;
CString Temp;
while( -1 != pos ){
int temp1=0;
int temp2=0;
iCount_1++;
pre_pos = pos;
pos = source.Find(division,(pos+1));
if(pos == -1){
if(iCount_1 == 1){
// temp1=source.GetLength()-pre_pos;
//temp2=pre_pos;
// csflag.Format(L"%d",temp1);
// OutputDebugString(csflag);
//OutputDebugString(L"\n");
//csflag.Format(L"%d",temp2);
// OutputDebugString(csflag);
//OutputDebugString(L"\n");
Temp=source.Mid(pre_pos,source.GetLength()-pre_pos);
}
else{
// temp1=source.GetLength()-(pre_pos+1);
// temp2=pre_pos+1;
// csflag.Format(L"%d",temp1);
// OutputDebugString(csflag);
//OutputDebugString(L"\n");
//csflag.Format(L"%d",temp2);
// OutputDebugString(csflag);
//OutputDebugString(L"\n");
Temp=source.Mid(pre_pos+1,source.GetLength()-(pre_pos+1));
}
}else{
if(iCount_1 == 1){
// temp1=pos-(pre_pos);
// temp2=pre_pos;
// csflag.Format(L"%d",temp1);
// OutputDebugString(csflag);
//OutputDebugString(L"\n");
//csflag.Format(L"%d",temp2);
// OutputDebugString(csflag);
//OutputDebugString(L"\n");
Temp=source.Mid(pre_pos,(pos-(pre_pos)));
}
else{
// temp1=pos-(pre_pos+1);
// temp2=pre_pos+1;
// csflag.Format(L"%d",temp1);
// OutputDebugString(csflag);
//OutputDebugString(L"\n");
//csflag.Format(L"%d",temp2);
// OutputDebugString(csflag);
//OutputDebugString(L"\n");
Temp=source.Mid(pre_pos+1,(pos-(pre_pos+1)));
}
}
int compareid=wcscmp(Temp.GetBuffer(), L"");
if(compareid != 0){
dest->Add(Temp);
}
Temp.ReleaseBuffer();
//AfxMessageBox(Temp);
}
return dest;
}
/////////////////////////////////////////////////////////////////////////////////////////
// 将Char型字符转换为Unicode字符
int CharToUnicode(char *pchIn, CString *pstrOut)
{
int nLen;
WCHAR *ptch;
if(pchIn == NULL)
{
return 0;
}
nLen = MultiByteToWideChar(CP_ACP, 0, pchIn, -1, NULL, 0);
ptch = new WCHAR[nLen];
MultiByteToWideChar(CP_ACP, 0, pchIn, -1, ptch, nLen);
pstrOut->Format(_T("%s"), ptch);
delete [] ptch;
return nLen;
}
/*****************************************************************************
** Activation Methods
*****************************************************************************/
/* Unigraphics Startup
** This entry point activates the application at Unigraphics startup */
extern DllExport void ufsta( char *param, int *returnCode, int rlen )
{
/* Initialize the API environment */
if( UF_CALL(UF_initialize()) )
{
/* Failed to initialize */
return;
}
CString strText;
CString szLine; //存储行字符串
CStdioFile file;
CString file_path;//list文件路径
CStringArray *destArray;//全局数组,参数名
CStringArray *OutputArrayFile;//文件读入数组
//ProError Error;
TCHAR strPath_temp[MAX_PATH];
OutputDebugString(strPath_temp);
////////////////////test use
//////////////EXE路径
//CString path=AfxGetApp()->m_pszHelpFilePath;
//CString str=AfxGetApp()->m_pszExeName;
//path=path.Left(path.GetLength()-str.GetLength()-4);
CString inipath;
CString PropList;
CString PropLIB;
//inipath=path+ L"\config.ini";
inipath="D:\\UG\\UGII\\config.ini";
//AfxMessageBox(inipath);
OutputDebugString(inipath);
OutputDebugString(L"\n");
GetPrivateProfileString(L"ProE_Parameter",L"PropList",L"Default",PropList.GetBuffer(MAX_PATH),MAX_PATH,inipath);
GetPrivateProfileString(L"ProE_Parameter",L"LIB",L"Default",PropLIB.GetBuffer(MAX_PATH),MAX_PATH,inipath);
bool flag = CreateDirectory(PropLIB, NULL);
OutputDebugString(PropLIB);
OutputDebugString(L"\n");
char temps1[99999];
sprintf(temps1,"%S",PropLIB);
if(_access(temps1, 00)==0)
{
OutputDebugString(L"LIB has created\n");
}else{
flag = CreateDirectory(PropLIB, NULL);
if(flag)
{
}
else{
PropLIB="C:\\LIB";
OutputDebugString(L"LIB has created C:\\LIB\n");
}
flag = CreateDirectory(PropLIB, NULL);
}
//AfxMessageBox(PropList);
destArray=SplitLine(PropList.GetBuffer(PropList.GetLength()),L",");//ini文件解析
PropList.ReleaseBuffer();
destArray->InsertAt(0,L"STEP_NAME");
destArray->InsertAt(0,L"PART_RENAME");
destArray->InsertAt(0,L"PART_NAME");
CString t;
t.Format(L"%d",destArray->GetCount());
OutputDebugString(L"destArray: Count->");
OutputDebugString(t);
OutputDebugString(L"\n");
for (int n = 0; n < destArray->GetCount(); n ++)
{
CString t;
t.Format(L"%s",(*destArray)[n]);
OutputDebugString(t);
OutputDebugString(L"\n");
}
///////////////////////////////////////////////////
GetTempPath(MAX_PATH, strPath_temp);
file_path.Format(L"%s\\proe\\list.txt",strPath_temp);
//MessageBox(file_path);
//Error=ProDirectoryCurrentGet(pro_path);
//Error=ProDirectoryChange(PropLIB.GetBuffer());
//PropLIB.ReleaseBuffer();
// if( Error != PRO_TK_NO_ERROR )
// {
// AfxMessageBox(L"ProDirectoryChange error: 可能PROE未启动 ");
// return;
// }
///////////////////
try
{
CFile file(file_path, CFile::modeRead);
char* buf = NULL;
DWORD dwLen = (DWORD)file.GetLength();
buf = new char[dwLen + 1];
memset(buf, 0, dwLen + 1);
file.Read(buf, dwLen);
file.Close();
CString str(buf);
delete[] buf;
buf = NULL;
//AfxMessageBox(str);
OutputArrayFile=SplitLine(str,L"\r");
CString t;
t.Format(L"FileLineCount: %d",OutputArrayFile->GetCount());
OutputDebugString(t);
OutputDebugString(L"|end\n");
}
catch (CException* e)
{
e->ReportError();
e->Delete();
}
/////////////////////
//file.Open(file_path,CFile::modeRead);//打开文件
//逐行读取字符串
|
|