AE新增CAD檔案

2021-05-22 18:05:23 字數 2854 閱讀 2729

void caoex1view::onaddcad()

cstring strfilter;

strfilter = "auto cad(*.dxf)| *.dxf|auto cad(*.dwg)|*.dwg||";

cfiledialog pdlg(true,null,null,

ofn_allowmultiselect|ofn_explorer|ofn_longnames|ofn_filemustexist|ofn_hidereadonly,

(lpctstr)strfilter,

null);

cstring strtitle =l"select cad file";

pdlg.m_ofn.lpstrtitle = strtitle;

if(idcancel ==pdlg.domodal()) return;

cstring strext,strpath;

strext = pdlg.getfileext();

strpath = pdlg.getpathname();

if(!(strext.isempty()))

int temp;

temp = strpath.reversefind('//');

strpath = strpath.left(temp);

iworkspacefactoryptr ipcadwksfact(clsid_cadworkspacefactory);

iworkspaceptr ipwspace;

hresult hr = ipcadwksfact->openfromfile((_bstr_t)strpath,null,&ipwspace);

if(failed(hr)) return;

ifeatureworkspaceptr ipworkspace(ipwspace);

ifeaturelayerptr ipcadfeaturelayer;

ifeaturedatasetptr ipfeaturedataset;

ifeatureclassptr ipfeatureclass;

cstring strtemp;

int ipathlength;

int i;

ipathlength =strpath.getlength();

position ps;

ps= pdlg.getstartposition();

isetptr ipset(clsid_set);

while (ps != null)

strtemp = pdlg.getnextpathname(ps);

strtemp = strtemp.right(strtemp.getlength() - (ipathlength + 1));

hr = ipworkspace->openfeaturedataset((_bstr_t)strtemp,&ipfeaturedataset);

if(failed(hr)) return;

ifeatureclasscontainerptr ipfeatureclasscontainer(ipfeaturedataset);

long itemp;

ipfeatureclasscontainer->get_classcount(&itemp);

enum esrifeaturetype featuretype;

bstr aliasname;

for(i = 0;ihr = ipfeatureclasscontainer->get_class(i,&ipfeatureclass);

if(failed(hr)) return;

hr = ipfeatureclass->get_featuretype(&featuretype);

if(failed(hr)) return;

if (featuretype == esriftcoverageannotation)

cocreateinstance(clsid_cadannotationlayer,null,clsctx_all,iid_ifeaturelayer,(void**)&ipcadfeaturelayer);

if(ipcadfeaturelayer == null) return;

else

cocreateinstance(clsid_cadfeaturelayer,null,clsctx_all,iid_ifeaturelayer,(void**)&ipcadfeaturelayer);

if(ipcadfeaturelayer == null) return;

ipfeatureclass->get_aliasname(&aliasname);

ipcadfeaturelayer->put_name(aliasname);

ipcadfeaturelayer->putref_featureclass(ipfeatureclass);

m_ipmap = m_ctrlmap.get_map();

hr = m_ipmap->addlayer(ipcadfeaturelayer);

if(failed(hr)) return;

ienvelopeptr ipenv;

iactiveviewptr ipactiveview(m_ipmap);

hr = ipactiveview->get_fullextent(&ipenv);

if(failed(hr)) return;

hr = ipactiveview->put_extent(ipenv);

if(failed(hr)) return;

hr = ipactiveview->refresh();

if(failed(hr)) return;

AE新增引用和控制項

這幾天要學習一下arcgis二次開發。之前完全沒有接觸過。首先是怎麼在vs中新增控制項 一 必備條件 1 電腦安裝arcgis engine,是否需要安裝arcgis不得而知,反正我安裝了。先安的arcgis10,後安的arcgis engine10,電腦是win7旗艦版,64位。2 電腦安裝vis...

CAD批量合併檔案

要求 將整飾完成504幅單獨的宗地圖合併成一張總圖,合併後,去掉其他要素,只保留畢合的權屬線。解決 1.合併dwg檔案,除了手工貼上複製外,最先想到的是插入塊,即用insert命令插入,測試結果可行 這裡需要注意的是檔案的路徑,預設windows複製過來的路徑是 e 石安村副 51340121220...

AE 開啟各種格式檔案

開啟shapefile檔案 檔案路徑 檔名 ifeatureclass public ifeatureclass getshpfile string filepath,string filename catch releaseae.releaseaeobject featureworkspace r...