ObjectARX使用数据库,拼图就这么简单
int iCount = m_FileList.GetCount();
if (iCount > 1)
{
acedSetStatusBarProgressMeter("正在合拼图纸,等稍等!", 0, iCount);
for (int i = 0; i < iCount; i++)
{
AcDbDatabase pDb = NULL;
CString fileName;
m_FileList.GetText(i, fileName);
pDb.readDwgFile(fileName);
AcGeMatrix3d m_xform;
acdbHostApplicationServices()->workingDatabase()->insert(m_xform, &pDb, TRUE);
acedSetStatusBarProgressMeterPos(i);
}
acedRestoreStatusBar();
acedCommand(RTSTR, TEXT("ZOOM"), RTSTR, TEXT("E"), RTNONE);
}
else
{
acutPrintf(TEXT("所选文件夹内少于两个dwg文件!"));
}
===========================================================================================
CString title = TEXT("选择DWG图形文件");
CString path = TEXT("C:\\");
struct resbuf *fileName = acutNewRb(RTSTR);
if (acedGetFileD(title, path, TEXT("dwg;dxf"), 0, fileName) == RTNORM)
{
m_FileList.AddString(fileName->resval.rstring);
}
acutRelRb(fileName);
===========================================================================================
CString ReturnPach;
CTextFileUtil::Getbrowse(ReturnPach);
m_PathEdit.SetWindowText(ReturnPach);
if (_tcscmp(ReturnPach, TEXT("")) == 1)
{
std::vector<CString> lstFiles;
CTextFileUtil::GetbrowseFiles(ReturnPach, lstFiles);
if (lstFiles.size() > 1)
{
for (int i = 0; i < lstFiles.size(); i++)
{
m_FileList.AddString(lstFiles);
}
}
}
===========================================================================================
CString CTextFileUtil::Getbrowse(CString &ReturnPach)
{
// CString ReturnPach;
TCHAR szPath; // 保存路径变量
BROWSEINFO bi; // BROWSEINFO结构变量
bi.hwndOwner = NULL; // HWND句柄
bi.pidlRoot = NULL; // 默认值为NULL
bi.lpszTitle = _T("文件浏览对话框"); // 对话框标题
bi.pszDisplayName = szPath; // 选择文件夹路径
bi.ulFlags = BIF_RETURNONLYFSDIRS; // 标记
bi.lpfn = NULL; // 默认值为NULL
bi.lParam = NULL; // 回调消息
LPITEMIDLIST pItemIDList = SHBrowseForFolder(&bi);// 显示文件浏览对话框
if(pItemIDList)
{
if(SHGetPathFromIDList(pItemIDList,szPath)) // 判断是否获得文件夹路径
{
ReturnPach = szPath;
}
}
else
{
ReturnPach = ""; //文件夹路径为空
}
return ReturnPach;
}
void CTextFileUtil::GetbrowseFiles(const TCHAR* ReturnPach, std::vector<CString> &lstFiles)
{
CFileFind ff;
CString strPath = ReturnPach;
if (strPath.Right(1) != "\\")
{
strPath += "\\";
}
strPath += "*.*";
BOOL res = ff.FindFile(strPath);
while (res)
{
res = ff.FindNextFile();
if (ff.IsDirectory() && !ff.IsDots()) // 如果是一个子目录,进行递归查找
{
CTextFileUtil::GetbrowseFiles(ff.GetFilePath(), lstFiles);
}
else
{
if (!ff.IsDirectory() && !ff.IsDots())
{
CString strFileName = ff.GetFileName();
if (strFileName.Right(3) == "dwg")
{
strFileName = TEXT("\\") + strFileName;
strFileName = ReturnPach + strFileName;
lstFiles.push_back(strFileName);
}
}
}
}
ff.Close();
}
高深莫测啊 拼起来的图打散了吗?貌似很快啊 完全看不懂,连命令都不知道是什么:'( 好东西,收藏留存,拼图神器
页:
[1]