![objectARX常用功能實現(xiàn)集合_第1頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/27/0b051b48-c82d-489c-b701-9b7a81967780/0b051b48-c82d-489c-b701-9b7a819677801.gif)
![objectARX常用功能實現(xiàn)集合_第2頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/27/0b051b48-c82d-489c-b701-9b7a81967780/0b051b48-c82d-489c-b701-9b7a819677802.gif)
![objectARX常用功能實現(xiàn)集合_第3頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/27/0b051b48-c82d-489c-b701-9b7a81967780/0b051b48-c82d-489c-b701-9b7a819677803.gif)
![objectARX常用功能實現(xiàn)集合_第4頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/27/0b051b48-c82d-489c-b701-9b7a81967780/0b051b48-c82d-489c-b701-9b7a819677804.gif)
![objectARX常用功能實現(xiàn)集合_第5頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/27/0b051b48-c82d-489c-b701-9b7a81967780/0b051b48-c82d-489c-b701-9b7a819677805.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、objectarx 常用功能實現(xiàn)集合一 在 arx中禁用 autocad的某個命令以 line 命令為例,在程序中加入下面的一句即可禁用line 命令:acedcommand(rtstr, undefine, rtstr, line,rtnone); 下面的語句則可恢復(fù)line 命令的定義:acedcommand(rtstr, redefine, rtstr, line,rtnone); 二 在對話框中預(yù)覽dwg 文件使用 acdbdisplaypreviewfromdwg函數(shù),具體的方法為:char filename100; strcpy(filename, c:test.dwg); boo
2、l es; hwnd pwnd; cframewnd *pframe. = (cframewnd*)getdlgitem(idc_picture); es = acdbdisplaypreviewfromdwg(filename, pframe-m_hwnd); 上面的代碼將在一個picture控件中顯示指定的圖形。另外,需要包含“ dbmain.h”頭文件。三 通過 arx更改 autocad窗口的標(biāo)題名稱cmdiframewnd *pp; pp=acedgetacadframe(); pp-setwindowtext (yourname); pp-updatewindow (); 四 獲得
3、當(dāng)前數(shù)據(jù)庫在 arx編程中, 經(jīng)常需要使用當(dāng)前數(shù)據(jù)庫,例如需要獲得當(dāng)前圖形中設(shè)置的文字樣式、標(biāo)注樣式等。要獲得當(dāng)前數(shù)據(jù)庫,都可以直接使用下面的方法:acdbtextstyletable *ptextstyletable; acdbobjectid textstyleid; textstyleid=acdbhostapplicationservices()-workingdatabase()-textstyle(); 如果用 acadcurdwg來代替 acdbhostapplicationservices()-workingdatabase(),也能得到同樣的結(jié)果。五 將一個圖插入另一個圖(
4、兩種方法 ) 在實踐中常常要將外部的圖形文件source.dwg中插入到另外一個圖形中或者當(dāng)前圖形中.以插入到當(dāng)前圖形dest.dwg 為例 . 為了將一個source.dwg 插入 dest.dwg 中, 首先要找到source.dwg 這個文件 . 我們可以使用各種基本的技術(shù)和相應(yīng)的規(guī)則從你的機器上或pdm 數(shù)據(jù)庫中檢索到你要插入的source.dwg, 返回來一個字符竄sfilename 代表整個文件及其路徑. 然后創(chuàng)建一個空的數(shù)據(jù)庫pnewdb讀入 source.dwg. acdbdatabase *pnewdb =new acdbdatabase(adesk:kfalse); / 在
5、這里一定要用adesk:kfalse acdocmanager-lockdocument(acdocmanager-curdocument() ;/如果確定你不需要lockdocument, 這一行可以不要es=pnewdb-readdwgfile(sfilename , _sh_denyno,false); if (es!=acad:eok) acutprintf(nthe file %s cannot be opend,sfilename); return; 這樣 ,source.dwg以經(jīng)用 pnewdb來表示了 . 我們用 pdb來表示當(dāng)前數(shù)據(jù)庫acdbdatabase *pdb; p
6、db =acdbhostapplicationservices ()-workingdatabase () ; 現(xiàn)在 , 我們用 insert來插入數(shù)據(jù)庫. insert有兩種用法 , 一種是直接insert, source.dwg中的圖元實體被分散地插入pdb中pdb-insert( acgematrix3d:kidentity, pnewdb );/這里假定不對source.dwg做比例和轉(zhuǎn)角的變換 . 如果我們在這里結(jié)束程序,我們能看到source.dwg已經(jīng)被插入 , 但不是一個圖塊. 另外一種插入法是要求插入后source.dwg 成為一個圖塊 , 圖塊的 attribute也要從s
7、ource.dwg 中得到 .這種方法要做大量的工作. 首先運行 insert() cstring pblockname= ”testblock ”; acdbobjectid blockid; if(es=pdb-insert(blockid, pblockname,pnewdb, true)=acad:eok) acutprintf(ninsert okn); else afxmessagebox(insert failed); delete pnewdb; return; / 這里 blcokid是 insert運行后產(chǎn)生的, 它代表的是一個塊表記錄acdbblockrecord 的 i
8、d. pblockname是記錄名 , 要在 insert運行前設(shè)定其值. 如果我們在這里結(jié)束程序, 我們看不到任何東西,因為 source 并沒有真正被插入. 我們還要做一些事 ,首先是創(chuàng)建一個acdbblockreference, 并將它指向blockid所代表的acdbblockrecord, 然后將這個acdbblockreference加入 pdb所代表的圖形數(shù)據(jù)庫中. acdbblockreference *pblkref = new acdbblockreference; pblkref-setblocktablerecord(blockid);/指向 blockid; pblk
9、ref-setposition(pt);/設(shè)定位置pblkref-setrotation(angle);/設(shè)定轉(zhuǎn)角pblkref-setscalefactors( xrefscale);/設(shè)定放大比例acdbblocktable *pblocktable; pdb-getsymboltable(pblocktable, acdb:kforread); acdbblocktablerecord *pblocktablerecord; pblocktable-getat(acdb_model_space, pblocktablerecord, acdb:kforwrite); pblocktabl
10、e-close(); acdbobjectid newentid; pblocktablerecord-appendacdbentity(newentid, pblkref); pblocktablerecord-close(); 如果我們在這里結(jié)束程序, 我們將看到當(dāng)前圖形中source.dwg已經(jīng)被作為圖塊插入.但是圖塊中沒有source.dwg 所定義的attibute. 因此我們還要做工作. 后面的事情就簡單了. acdbblocktablerecord *pblockdef; acdbopenobject(pblockdef, blockid, acdb:kforread); acd
11、bblocktablerecorditerator *piterator; pblockdef-newiterator(piterator); acgepoint3d basepoint; acdbentity *pent; acdbattributedefinition *pattdef; for (piterator-start(); !piterator-done(); piterator-step()/將 source.dwg 中所有的attibute進行遍歷 piterator-getentity(pent, acdb:kforread); pattdef = acdbattribu
12、tedefinition:cast(pent); if (pattdef != null & !pattdef-isconstant() acdbattribute *patt = new acdbattribute(); patt-setpropertiesfrom(pattdef); patt-setinvisible(pattdef-isinvisible(); basepoint = pattdef-position(); basepoint += pblkref-position().asvector(); patt-setposition(basepoint); patt-
13、setheight(pattdef-height(); patt-setrotation(pattdef-rotation(); patt-settag(tag); patt-setfieldlength(25); char *pstr = pattdef-tag(); patt-settag(pstr); acutdelstring(pstr); patt-setfieldlength(pattdef-fieldlength(); patt-settextstring(-); acdbobjectid attid; pblkref-appendattribute(attid, patt);
14、patt-close(); pent-close(); / use pent. pattdef might be null delete piterator; 六 在 arx打開文件在 autocad中打開圖形,并且顯示在圖形窗口中,可以使用acedsyncfileopen()函數(shù)。需要注意的是,這個函數(shù)只能在單文檔模式中工作,用戶可以在autocad “選項”對話框的“系統(tǒng)”選項卡中進行設(shè)置,或者在主函數(shù)中添加下面的語句:acrxdynamiclinker-registerappnotmdiaware(pkt); 具體的函數(shù)如下:/ 加載模板文件void loadtemplate() cha
15、r fname50; strcpy(fname,e:tmcadtmcadtukuanga3.dwg); #ifndef _acad2000 acad:errorstatuses; es = acedsyncfileopen(fname); #else acdocmanager-appcontextopendocument(fname); #endif 如果在多文檔模式下,下面的方法可以在執(zhí)行時彈出“選擇文件”對話框,用戶選擇所要打開的文件后,在圖形窗口中顯示該圖形。void zffopenopendwg() / 使用“選擇文件”對話框選擇所要打開的文件acdocmanager-opendocu
16、ment(); 下面的方法則打開指定位置的dwg 文件。void opendoc( void *pdata) acapdocument* pdoc = acdocmanager-curdocument(); if (acdocmanager-isapplicationcontext() acdocmanager-appcontextopendocument(const char *)pdata); else acutprintf(nerror to open doc!n); / this is command open1 void zffopenopen1() / 直接打開系統(tǒng)中存在的某個圖形
17、文件g:autocad 圖形 wen2.dwg static char pdata = g:autocad圖形 wen2.dwg; acdocmanager-executeinapplicationcontext(opendoc, (void *)pdata); acedinputpointmanager類acedinputpointmanager類 折疊 輸入點管理器對autocad中每個激活的文件實例化一次,而且通過一個acapdocument 成員函數(shù)輸出。每個實例管理文件編輯工作任務(wù)的下列任務(wù):輸入點過濾器和輸入點監(jiān)視器的注冊和取消注冊輸入環(huán)境反應(yīng)器的注冊和取消注冊使失效和重生效系統(tǒng)產(chǎn)
18、生的光標(biāo)圖形,它是圖形自定義光標(biāo)圖形的關(guān)鍵元素在要求選擇必須完成的輸入事件中請求強制的實體選擇。這用在光標(biāo)追蹤穿過當(dāng)前的視口時追蹤光標(biāo)下的實體。繼承自無包含文件acedinpt.h 成員acedinputpointmanager函數(shù)acedinputpointmanager:addinputcontextreactor函數(shù)virtual acad:errorstatus addinputcontextreactor( acedinputcontextreactor* preactor) = 0; preactor 輸入一個要增加的輸入環(huán)境反應(yīng)器對象此函數(shù)增加一個輸入環(huán)境反應(yīng)器。找出通過auto
19、cad輸入機制 (窗口對話框除外)提示用戶的內(nèi)容。任何可以增加的反應(yīng)器的數(shù)量,除了每個只能被增加一次的反應(yīng)器,與輸入點監(jiān)視器相同。增加相同的反應(yīng)器兩次(用地址進行比較)將返回 acad:eduplicatekey。否則,則返回acad:eok 。acedinputpointmanager:addpointmonitor函數(shù)virtual acad:errorstatus addpointmonitor( acedinputpointmonitor* pmonitor) = 0; pmonitor 輸入要增加的輸入點監(jiān)視器此函數(shù)增加一個點監(jiān)視器至當(dāng)前集合。每個監(jiān)視器在每個輸入點事件中只被調(diào)用一次
20、。增加相同的監(jiān)視器兩次(用地址進行比較)將返回acad:eduplicatekey。否則,則返回acad:eok 。acedinputpointmanager:currentpointfilter函數(shù)virtual acedinputpointfilter * currentpointfilter() const = 0; 返回當(dāng)前的點過濾器(如果有),否則返回null 。acedinputpointmanager:disablesystemcursorgraphics函數(shù)virtual acad:errorstatus disablesystemcursorgraphics() = 0; 使
21、光標(biāo)圖形對關(guān)聯(lián)的文件失效。與自定義的光標(biāo)圖形一起使用。這個函數(shù)與enablesystemcursorgraphics()成對地作用于一個內(nèi)部的計數(shù)器上,因此系統(tǒng)可知道要禁止系統(tǒng)光標(biāo)的多重應(yīng)用程序。如果成功返回acad:eok ,如果光標(biāo)因某種原因不能被禁止則返回acad:einvalidcontext。acedinputpointmanager:enablesystemcursorgraphics函數(shù)virtual acad:errorstatus enablesystemcursorgraphics() = 0; 使光標(biāo)圖形對關(guān)聯(lián)的文件生效。與自定義的光標(biāo)圖形一起使用。這個函數(shù)與disabl
22、esystemcursorgraphics()成對地作用于一個內(nèi)部的計數(shù)器上,因此系統(tǒng)可知道要禁止系統(tǒng)光標(biāo)的多重應(yīng)用程序。如果成功返回acad:eok ,如果失效計數(shù)已經(jīng)為0 則返回 acad:einvalidcontext。acedinputpointmanager:forcedpickcount函數(shù)virtual int forcedpickcount() const = 0; 如果強制選擇為打開的調(diào)用者數(shù)量。acedinputpointmanager:mousehasmoved函數(shù)virtual int mousehasmoved() const = 0; 此函數(shù)提供一種方法讓輸入點監(jiān)視
23、器和過濾器檢查鼠標(biāo)移動并可盡快地從回調(diào)中返回,而無需做任何耗時的計算。如果序列中沒有任何數(shù)字化設(shè)備事件則返回1,否則返回0。acedinputpointmanager:registerpointfilter函數(shù)virtual acad:errorstatus registerpointfilter( acedinputpointfilter* pfilter) = 0; pfilter 輸入要注冊的輸入點過濾器對象使用這個函數(shù)注冊一個點過濾器。確認(rèn)在完成時清空過濾器槽,因為在一個時間只能有一個過濾器被注冊。如果當(dāng)前沒有使用任何過濾器,則返回acad:eok ;否則返回acad:eillegal
24、replacement。acedinputpointmanager:removeinputcontextreactor函數(shù)virtual acad:errorstatus removeinputcontextreactor( acedinputcontextreactor* preact) = 0; preact 輸入要刪除的輸入環(huán)境反應(yīng)器用于從激活的集合中刪除一個輸入的環(huán)境反應(yīng)器。如果反應(yīng)器在集合中,則返回acad:eok ,否則返回acad:einvalidkey。acedinputpointmanager:removepointmonitor函數(shù)virtual acad:errorsta
25、tus removepointmonitor( acedinputpointmonitor* pmonitor) = 0; pmonitor 輸入要刪除的輸入點監(jiān)視器此函數(shù)用于從激活的集合中刪除一個點監(jiān)視器。如果監(jiān)視器在集合中,則返回acad:eok ;否則返回acad:einvalidkey。acedinputpointmanager:revokepointfilter函數(shù)virtual acad:errorstatus revokepointfilter() = 0; 此函數(shù)用于取消當(dāng)前的點過濾器。最好不要取消另一個應(yīng)用程序的過濾器;然而如果必須這樣做,可使用 currentpointfilter()取得當(dāng)前的這個過濾器并將其放在臺面。如果有一
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 教育培訓(xùn)合作委托居間合同
- 品牌營銷推廣策略指南
- 技術(shù)產(chǎn)品銷售合同
- 華為勞動合同管理制度
- 遺傳基因技術(shù)服務(wù)合同
- 外貿(mào)實務(wù)操作作業(yè)指導(dǎo)書
- 倉儲配送合同
- 智能工廠建設(shè)與運營作業(yè)指導(dǎo)書
- 2025年來賓貨運從業(yè)資格證模擬考試題庫
- 2025年陜西貨運從業(yè)資格考試模擬考試題庫及答案大全
- 小學(xué)校本課程教材《趣味數(shù)學(xué)》
- 干細胞療法推廣方案
- (2024年)電工安全培訓(xùn)(新編)課件
- mil-std-1916抽樣標(biāo)準(zhǔn)(中文版)
- 城鄉(xiāng)環(huán)衛(wèi)一體化內(nèi)部管理制度
- 廣匯煤炭清潔煉化有限責(zé)任公司1000萬噸年煤炭分級提質(zhì)綜合利用項目變更環(huán)境影響報告書
- 小學(xué)數(shù)學(xué)六年級解方程練習(xí)300題及答案
- 大數(shù)據(jù)在化工行業(yè)中的應(yīng)用與創(chuàng)新
- 光伏十林業(yè)可行性報告
- 小學(xué)綜合實踐《我做環(huán)保宣傳員 保護環(huán)境人人有責(zé)》
- 鋼煤斗內(nèi)襯不銹鋼板施工工法
評論
0/150
提交評論