TA的每日心情 | 开心 昨天 06:36 |
---|
签到天数: 15 天 [LV.4]偶尔看看III
管理员
- 积分
- 1308
|
- 主对话框CPP内代码:
- #include "StdAfx.h"
- #include "resource.h"
- #include "BlockDialog.h"
- #include "..\..\Common\我的类\file.h"
- #include "..\..\Common\Document\DwgDatabaseUtil.h"
- #include <dbents.h>
- #include <dbmain.h>
- #include "..\..\Chapter11\PreviewControl\GsPreviewCtrl.h"
- #include "GsPreviewCtrl.h"
- #include <gepnt3d.h>
- #include <geassign.h>
- CString filepatha;
- CString filepath;
- void CBlockDialog::OnButton1()
- {
- m采用combo1.ResetContent();
- m采用combo2.ResetContent();
- m采用combo3.ResetContent();
- m采用list.ResetContent();
- vector<CString> filename;
- Cfile::getFiles(filepath,filename);
- int i;
- for (i=0;i<filename.size()-2;i++)
- {
- m采用combo1.AddString(filename[i+2]);
- }
- if (m采用combo1.GetCount()>0)
- {
- m采用combo1.SetCurSel(0);
- filepatha=filepath.Left(filepath.GetLength()-1);
- CString ca;
- m采用combo1.GetWindowText(ca);
- CString filepathaa=filepatha+ca;
- vector<CString> filenamea;
- Cfile::getFiles(filepathaa,filenamea);
- for (i=0;i<filenamea.size()-2;i++)
- {
- m采用combo2.AddString(filenamea[i+2]);
- }
- if (m采用combo2.GetCount()>0)
- {
- m采用combo2.SetCurSel(0);
- CString filepathb=filepathaa.Left(filepathaa.GetLength()-1);
- m采用combo2.GetWindowText(ca);
- CString filepathbb=filepathb+ca;
- vector<CString> filenameb;
- Cfile::getFiles(filepathbb,filenameb);
- for (i=0;i<filenameb.size()-2;i++)
- {
- m采用combo3.AddString(filenameb[i+2]);
- }
- if (m采用combo3.GetCount()>0)
- {
- m采用combo3.SetCurSel(0);
- CString filepathc=filepathbb.Left(filepathbb.GetLength()-1);
- m采用combo3.GetWindowText(ca);
- CString filepathcc=filepathc+ca;
- AcDbDatabase *pDb=new AcDbDatabase(false);
- pDb->readDwgFile(filepathcc,采用SH采用DENYWR);
- AcDbObjectIdArray allEntIds = CDwgDatabaseUtil::GetAllEntityIds(NULL,pDb);
- for (i=0;i<allEntIds.length();i++)
- {
- AcDbEntity *pEnt=NULL;
- if (acdbOpenObject(pEnt,allEntIds[i],AcDb::kForRead)==Acad::eOk)
- {
- if (pEnt->isKindOf(AcDbBlockReference::desc()))
- {
- AcDbBlockReference *pBlkRef=NULL;
- pBlkRef=AcDbBlockReference::cast(pEnt);
- pEnt->close();
- AcDbObjectId blkDefId=pBlkRef->blockTableRecord();
- pBlkRef->close();
- AcDbBlockTableRecord *pBlkDef=NULL;
- char *blkDefName;
- if (acdbOpenObject(pBlkDef,blkDefId,AcDb::kForRead)==Acad::eOk)
- {
- pBlkDef->getName(blkDefName);
- m采用list.AddString(blkDefName);
- pBlkDef->close();
- }
- }
- }
- }
- pDb->closeInput();
- delete pDb;
- }
- }
- }
- filepath=filepath.Left(filepath.GetLength()-2);
- }
-
-
- void CBlockDialog::OnSelchangeCombo1()
- {
- m采用combo2.ResetContent();
- CString ca;
- m采用combo1.GetLBText(m采用combo1.GetCurSel(),ca);
- CString filepa=filepatha+ca;
- vector<CString>filename;
- Cfile::getFiles(filepa,filename);
- int i;
- for (i=0;i<filename.size()-2;i++)
- {
- m采用combo2.AddString(filename[i+2]);
- }
- if (m采用combo2.GetCount()>0)
- {
- m采用combo2.SetCurSel(0);
- m采用combo3.ResetContent();
- m采用combo2.GetWindowText(ca);
- filepa=filepa.Left(filepa.GetLength()-1);
- filepa+=ca;
- vector<CString>filenamea;
- Cfile::getFiles(filepa,filenamea);
- for (i=0;i<filenamea.size()-2;i++)
- {
- m采用combo3.AddString(filenamea[i+2]);
- }
- if (m采用combo3.GetCount()>0)
- {
- m采用combo3.SetCurSel(0);
- m采用list.ResetContent();
- m采用combo3.GetWindowText(ca);
- filepa=filepa.Left(filepa.GetLength()-1);
- filepa+=ca;
- AcDbDatabase *pDb=new AcDbDatabase(false);
- pDb->readDwgFile(filepa,采用SH采用DENYWR);
- AcDbObjectIdArray allEntIds = CDwgDatabaseUtil::GetAllEntityIds(NULL,pDb);
- for (int i=0;i<allEntIds.length();i++)
- {
- AcDbEntity *pEnt=NULL;
- if (acdbOpenObject(pEnt,allEntIds[i],AcDb::kForRead)==Acad::eOk)
- {
- if (pEnt->isKindOf(AcDbBlockReference::desc()))
- {
- AcDbBlockReference *pBlkRef=NULL;
- pBlkRef=AcDbBlockReference::cast(pEnt);
- pEnt->close();
- AcDbObjectId blkDefId=pBlkRef->blockTableRecord();
- pBlkRef->close();
- AcDbBlockTableRecord *pBlkDef=NULL;
- char *blkDefName;
- if (acdbOpenObject(pBlkDef,blkDefId,AcDb::kForRead)==Acad::eOk)
- {
- pBlkDef->getName(blkDefName);
- m采用list.AddString(blkDefName);
- pBlkDef->close();
- }
- }
- }
- }
- delete pDb;
- filepa="";
- }
- }
- }
- void CBlockDialog::OnSelchangeCombo2()
- {
- m采用combo3.ResetContent();
- CString ca;
- CString cb;
- m采用combo2.GetLBText(m采用combo2.GetCurSel(),ca);
- m采用combo1.GetWindowText(cb);
- CString filepa=filepatha+cb;
- filepa+="\";
- filepa=filepa+ca;
- vector<CString>filename;
- Cfile::getFiles(filepa,filename);
- for (int i=0;i<filename.size()-2;i++)
- {
- m采用combo3.AddString(filename[i+2]);
- }
- if (m采用combo3.GetCount()>0)
- {
- m采用combo3.SetCurSel(0);
- m采用list.ResetContent();
- m采用combo3.GetWindowText(ca);
- filepa=filepa.Left(filepa.GetLength()-1);
- filepa+=ca;
- AcDbDatabase *pDb=new AcDbDatabase();
- pDb->readDwgFile(filepa,采用SH采用DENYWR);
- AcDbObjectIdArray allEntIds = CDwgDatabaseUtil::GetAllEntityIds(NULL,pDb);
- for (i=0;i<allEntIds.length();i++)
- {
- AcDbEntity *pEnt=NULL;
- if (acdbOpenObject(pEnt,allEntIds[i],AcDb::kForRead)==Acad::eOk)
- {
- if (pEnt->isKindOf(AcDbBlockReference::desc()))
- {
- AcDbBlockReference *pBlkRef=NULL;
- pBlkRef=AcDbBlockReference::cast(pEnt);
- pEnt->close();
- AcDbObjectId blkDefId=pBlkRef->blockTableRecord();
- pBlkRef->close();
- AcDbBlockTableRecord *pBlkDef=NULL;
- char *blkDefName;
- if (acdbOpenObject(pBlkDef,blkDefId,AcDb::kForRead)==Acad::eOk)
- {
- pBlkDef->getName(blkDefName);
- m采用list.AddString(blkDefName);
- pBlkDef->close();
- }
- }
- }
- }
- delete pDb;
- filepa="";
- }
- }
- void CBlockDialog::OnSelchangeCombo3()
- {
- CString ca;
- CString cb;
- CString cc;
- m采用list.ResetContent();
- m采用combo1.GetWindowText(ca);
- m采用combo2.GetWindowText(cb);
- m采用combo3.GetLBText(m采用combo3.GetCurSel(),cc);
- CString filepa=filepatha+ca;
- filepa+="\";
- filepa=filepa+cb;
- filepa+="\";
- filepa=filepa+cc;
- AcDbDatabase *pDb=new AcDbDatabase();
- pDb->readDwgFile(filepa,采用SH采用DENYWR);
- AcDbObjectIdArray allEntIds = CDwgDatabaseUtil::GetAllEntityIds(NULL,pDb);
- for (int i=0;i<allEntIds.length();i++)
- {
- AcDbEntity *pEnt=NULL;
- if (acdbOpenObject(pEnt,allEntIds[i],AcDb::kForRead)==Acad::eOk)
- {
- if (pEnt->isKindOf(AcDbBlockReference::desc()))
- {
- AcDbBlockReference *pBlkRef=NULL;
- pBlkRef=AcDbBlockReference::cast(pEnt);
- pEnt->close();
- AcDbObjectId blkDefId=pBlkRef->blockTableRecord();
- pBlkRef->close();
- AcDbBlockTableRecord *pBlkDef=NULL;
- char *blkDefName;
- if (acdbOpenObject(pBlkDef,blkDefId,AcDb::kForRead)==Acad::eOk)
- {
- pBlkDef->getName(blkDefName);
- m采用list.AddString(blkDefName);
- pBlkDef->close();
- }
- }
- }
- }
- delete pDb;
- filepa="";
- }
- BOOL CBlockDialog::OnInitDialog()
- {
- CAcUiDialog::OnInitDialog();
- m采用edit.SetWindowText("E:\\ARX\\资源");
- m采用edit.GetWindowText(filepath);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CBlockDialog::OnKillfocusEdit1()
- {
- m采用edit.Convert();
- m采用edit.GetWindowText(filepath);
- }
- void CBlockDialog::OnSelchangeList3()
- {
- // TODO: Add your control notification handler code here
- CString blockName;
- m采用list.GetText(m采用list.GetCurSel(),blockName);
- CString ca,cb,cc;
- CString fileName;
- m采用combo1.GetWindowText(ca);
- m采用combo2.GetWindowText(cb);
- m采用combo3.GetWindowText(cc);
- fileName=filepatha+ca;
- fileName+="\";
- fileName=fileName+cb;
- fileName+="\";
- fileName=fileName+cc;
- AcDbDatabase *m采用pDb=new AcDbDatabase();
- m采用pDb->readDwgFile(fileName,采用SH采用DENYWR);
- AcDbBlockTable *pBlkTbl=NULL;
- m采用pDb->getSymbolTable(pBlkTbl,AcDb::kForRead);
- AcDbObjectId blkDefId;
- pBlkTbl->getAt(blockName,blkDefId);
- pBlkTbl->close();
- AcDbBlockReference *pBlkRef=new AcDbBlockReference(AcGePoint3d::kOrigin,blkDefId);
- AcDbDatabase *pDb=new AcDbDatabase();
- CDwgDatabaseUtil::PostToModelSpace(pBlkRef,pDb);
- m采用gsPreviewCtrl.SubclassDlgItem(IDC采用PREVIEW,this);
- m采用gsPreviewCtrl.Init(PreviewControlDLL.ModuleResourceInstance(),true);
- m采用gsPreviewCtrl.SetDatabase(pDb);
- }
- void CBlockDialog::OnButton()
- {
- CString blockName;
- m采用list.GetText(m采用list.GetCurSel(),blockName);
- CString ca,cb,cc;
- CString fileName;
- m采用combo1.GetWindowText(ca);
- m采用combo2.GetWindowText(cb);
- m采用combo3.GetWindowText(cc);
- fileName=filepatha+ca;
- fileName+="\";
- fileName=fileName+cb;
- fileName+="\";
- fileName=fileName+cc;
- AcDbDatabase *m采用pDb=new AcDbDatabase();
- m采用pDb->readDwgFile(fileName,采用SH采用DENYWR);
- AcDbBlockTable *pBlkTbl=NULL;
- m采用pDb->getSymbolTable(pBlkTbl,AcDb::kForRead);
- AcDbObjectId blkDefId;
- pBlkTbl->getAt(blockName,blkDefId);
- pBlkTbl->close();
- BeginEditorCommand();
- ads采用point pt;
- if (acedGetPoint(NULL,"\n输入一个点:",pt)!=RTNORM)
- {
- CompleteEditorCommand();
- }
- else
- {
- AcGePoint3d pt3d=asPnt3d(pt);
- AcDbBlockReference *pBlkRef=new AcDbBlockReference(pt3d,blkDefId);
- AcDbDatabase *pDb=acdbHostApplicationServices()->workingDatabase();
- CDwgDatabaseUtil::PostToModelSpace(pBlkRef,pDb);
- pBlkRef->close();
- CompleteEditorCommand();
- }
- }
复制代码 |
|