日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

夢(mèng)想云圖Node.JS服務(wù) ( 最近更新時(shí)間:2022-12-30 10:04:50 )

 成都?jí)粝雱P德 2022-12-30 發(fā)布于四川

說(shuō)明

后臺(tái)提供夢(mèng)想Node.JS服務(wù),方便調(diào)用控件后臺(tái)功能,Windows服務(wù)程序所在目錄:Bin\MxDrawServer\Windows,Linux服務(wù)程序所在目錄:Bin\Linux\MxDrawServer

ws.png

ws2.png

啟動(dòng)服務(wù)

Windows:進(jìn)入Bin\MxDrawServer\Windows目錄,運(yùn)行start.bat啟動(dòng)服務(wù),如下圖:

圖片2.png

Linux: 進(jìn)入Bin\Linux\MxDrawServer,

執(zhí)行如下命令,增加文件的執(zhí)行權(quán)限


su root

chmod -R 777 *

如下:

linuserver.png

運(yùn)行: ./node app.js 啟動(dòng)服務(wù)

服務(wù)啟動(dòng)后,默認(rèn)會(huì)在1337端口監(jiān)聽,目錄下有個(gè)ini.js文件,編輯該文件,配置服務(wù)參數(shù),如下圖:

圖片4.png

服務(wù)使用

A.上傳文件,DWG文件格式轉(zhuǎn)換

服務(wù)接口說(shuō)明:

直接調(diào)用POST對(duì)服務(wù)器上的文件進(jìn)行轉(zhuǎn)換:

服務(wù)接口說(shuō)明:

*  POST users { cmd: "convert", file: "O:/1.dwg" }

*  file:  需要轉(zhuǎn)的cad文件路徑

如下代碼:


 $.ajax({

            url: 'http://localhost:1337/users',

            data: { cmd: "convert", file: "O:/1.dwg" },

            method: 'post'

        }).success(function (res) {

            console.log(res);

        })

前端上傳文件轉(zhuǎn)換如下:

POST convert file;file是<input id="input" type="file"> 選擇的文件.

該接口后臺(tái)源碼在Bin\MxDrawNode\MxDrawNode\src\mxconvert\MxConvert.ts 中的CadToMx

參考例子:Bin\MxDrawServer\Test\sample.html

代碼如下:

圖片5.png

默認(rèn)文件轉(zhuǎn)換后存放位置如下圖:

圖片6.png

B. 保存批注到DWG文件

服務(wù)接口說(shuō)明:

*  POST savecomment {filename:保存到的DWG文件;savefile :保存后的dwg, userConvertPath:false}

*  userConvertPath: 默認(rèn)值是false,把當(dāng)前圖上的批注內(nèi)容保存到指定的dwg文件中

*  filename: 是個(gè)相對(duì)路徑,默認(rèn)是相對(duì)于后臺(tái)程序所在目錄Bin\Release(windows),Bin\Linux\Bin(linux)

*  如果userConvertPath為接true,相對(duì)于Bin\Release\ini.json [linux:Bin\Linux\Bin\ini.json] 中的nodeConvert.path設(shè)置值 

*  savefile: 也是個(gè)相對(duì)路徑,同filename。該接口后臺(tái)源碼在Bin\MxDrawNode\MxDrawNode\src\mxconvert\SaveCommentToDwg.ts 中的SaveCommentToDWG.do 

參考例子:SRC\sample\Browse\VueBrowse,代碼如下:

圖片7.png

demo運(yùn)行后,點(diǎn)擊“保存到DWG文件”,查看接口調(diào)用效果:

圖片8.png

C. 得到到DWG文件中信息 

參考例子: Bin\MxDrawServer\Test\sample.html 

服務(wù)接口說(shuō)明:

POST users {cmd:"getcaddata",cadfile:"1.dwg",outfile:"1.dwg.json"} 

 代碼如下:


   function TestPost(){

        $.ajax({

            url:'http://localhost:1337/users',

            data:{cmd:"getcaddata",cadfile:"1.dwg",outfile:"1.dwg.json"},

            method:'post'

        }).success(function (res){

            console.log(res);

})

}

getcaddata的實(shí)現(xiàn),參見“夢(mèng)想控件2-后臺(tái)讀寫CAD文件.doc”執(zhí)行結(jié)果如下:

圖片10.png

D.  DWG文件轉(zhuǎn)成PDF

參考例子: Bin\MxDrawServer\Test\sample.html 

服務(wù)接口說(shuō)明:

POST tools { cmd: "cadtopdf", param: "file=O:/1.dwg" },

 代碼如下:


    $.ajax({

            url: 'http://localhost:1337/users/tools',

            data: { cmd: "cadtopdf", param: "file=O:/1.dwg" },

            method: 'post'

        }).success(function (res) {

            console.log(res);

        })

E.  DWG文件轉(zhuǎn)成JPG

參考例子: Bin\MxDrawServer\Test\sample.html 

服務(wù)接口說(shuō)明:

POST tools { cmd: "cadtopdf", param: "file=O:/1.dwg" },

 代碼如下:


    $.ajax({

            url: 'http://localhost:1337/users/tools',

            data: { cmd: "cadtojpg", param: "file=O:/1.dwg" },

            method: 'post'

        }).success(function (res) {

            console.log(res);

        })

F.  對(duì)CAD圖紙剪切,剪切輸出pdf,dwg

參考例子: Bin\MxDrawServer\Test\sample.html 

服務(wù)接口說(shuō)明:

POST tools { cmd: "cutcad", param: "file=O:/hhhh.dwg out=O:/1.pdf lbx=60009.152793 lby=42457.503649 rtx=120145.567345 rty=85507.693766"},

out傳的值擴(kuò)展名是pdf輸出pdf文件,是dwg時(shí)輸出dwg

 代碼如下:


$.ajax({

            url: 'http://localhost:1337/users/tools',

            data: { cmd: "cutcad", param: "file=O:/hhhh.dwg out=O:/1.pdf lbx=60009.152793 lby=42457.503649 rtx=120145.567345 rty=85507.693766"},

            method: 'post'

        }).success(function (res) {

            console.log(res);

        })

E.  根據(jù)圖框,折分pdf

參考例子: Bin\MxDrawServer\Test\sample.html 

服務(wù)接口說(shuō)明:

POST tools { cmd: "cadtopdf", file: "tk.dwg"},

調(diào)用 代碼如下:


     $.ajax({

            url: 'http://localhost:1337/users',

            data: { cmd: "cadtopdf", file: "O:/tk.dwg"},

            method: 'post'

        }).success(function (res) {

            console.log(res);

        })

該功能的源碼在:

Bin\MxDrawNode\MxDrawNode\src\mxconvert\CADToPDF.ts

    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多