- 积分
- 63873
- 明经币
- 个
- 注册时间
- 2010-5-9
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
将dwg文件打包进自己的VLX(测试与实战)
highflybird曰:DynamicWrapperX 是一个ActiveX部件,它可以极大程度地扩展LISP的编程范围,赋予DCL和VLISP更多功能
压缩包内Drawing2.dwg、Drawing2.txt、TEST1.VLX三个文件
1 Drawing2.dwg
2 Drawing2.txt是根据highflybird程序(http://bbs.mjtd.com/thread-85724-1-1.html),将Drawing2.dwg转成的二进制文件。
3 TEST1.VLX是将自写的lsp、Drawing2.txt编译的文件。
第一步 注册DynamicWrapperX
第二步 将Drawing2.dwg转成Drawing2.txt
第三步 编写自己的lisp文件,保存为w1.lsp
第四步 将w1.lsp、EditElv.txt编译成自己的vlx文件,test1.VLX
第五步 加载test1.VLX
第六步 执行命令w1.lsp内部自定义命令MyOpen,成功!!!
编写自己的lisp文件
(vl-load-com)
;;;Write Binary file from strings
(defun WriteBinary (FileName buffer / wsObj str)
(if (setq wsObj (vlax-create-object "ScriptControl"))
(progn
(vlax-put wsObj "language" "VBS")
(setq str
"Sub WriteBinary(FileName, Buf)
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Dim stream, xmldom, node
Set xmldom = CreateObject(\"Microsoft.XMLDOM\")
Set node = xmldom.CreateElement(\"binary\")
node.DataType = \"bin.hex\"
node.Text = Buf
Set stream = CreateObject(\"ADODB.Stream\")
stream.Type = adTypeBinary
stream.Open
stream.write node.NodeTypedValue
stream.saveToFile FileName, adSaveCreateOverWrite
stream.Close
Set stream = Nothing
Set node = Nothing
Set xmldom = Nothing
End Sub"
)
(vlax-invoke wsObj 'ExecuteStatement str)
(vlax-invoke wsObj 'run "WriteBinary" Filename buffer)
(vlax-release-object wsObj)
(princ)
)
)
)
(defun C:MyOpen (/ NAME)
(or *ACAD* (setq *ACAD* (vlax-get-acad-object)))
(setq name (vl-filename-mktemp "Drawing2.dwg"))
(WriteBinary name (vl-get-resource "Drawing2"))
(vla-Activate (vla-open (vla-get-Documents *ACAD*) name))
(VL-file-delete name)
(princ)
)
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|