天天看點

CAD替換圖檔

主要用到函數說明:

IMxDrawImageMark::ImageFile

圖檔檔案路徑。

js中實作代碼說明:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

​function​

​​ ​

​ModifyImage() {​

​// 建立一個COM元件對象​

​var​

​​ ​

​selEnt = mxOcx.NewComObject(​

​​

​"IMxDrawUiPrEntity"​

​​

​);​

​selEnt.message = ​

​​

​"選擇圖像對象"​

​​

​;​

​if​

​​

​(selEnt.go() != 1)​

​return​

​​

​;​

​var​

​​ ​

​image = selEnt.Entity();​

​if​

​​

​(image == ​

​​

​null​

​​

​)​

​return​

​​

​;​

​if​

​​ ​

​(image.ObjectName != ​

​​

​"McDbMxImageMark"​

​​

​) {​

​alert(​

​​

​"選擇對象不是圖像"​

​​

​)​

​return​

​​

​;​

​}​

​// 控件程式在磁盤的檔案路徑​

​var​

​​ ​

​sImageFile = mxOcx.GetOcxAppPath() + ​

​​

​"\\mxdraw.png"​

​​

​;​

​//替換目标檔案​

​image.ImageFile = sImageFile;​

​}​