马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
把WORD中的文字、表格等提取相关属性包括文字的大小、字型、颜色等和CAD之间的接口问题,希望高手能讨论一下~
这个是在一本书上找到的一个连接程序:
- (vl-load-com)
- (setq *AcadApp* (vlax-get-acad-object))
- (setq *ModelSpace* (vla-get-ModelSpace
- (vla-get-activedocument *AcadApp*)))
- (if (equal nil mswc-wd100Words)
- (vlax-import-type-library
- :tlb-filename "C:/Microsoft Office/Office10/MSWORD.OLB"
- :methods-prefix "mswm-"
- :properties-prefix "mswp-"
- :constants-prefix "mswc-"
- )
- )
- (setq msw (vlax-get-object "Word.Application"))
- (if(equal nil msw)
- (progn
- (setq msw (vlax-create-object "Word.Application"))
- (vla-put-visible msw :vlax-true)
- )
- )
- (if(/= nil msw)
- (progn
- (setq docs (vlax-get-object "Word.Application"))
- (vla-put-visible msw :vlax-true)
- (setq docs (vla-get-documents msw))
- (setq doc (mswm-add docs))
- (setq paragraphs (mswp-get-paragraphs doc))
- (vlax-for ent *ModelSpace*)
-
- (if(equal(vla-get-ObjectName ent) "AcDbMText")
- (progn
- (setq text (vla-get-TextString ent)
- textpos (vla-get-InsertionPoint ent)
- attyTextpos (vlax-variant-value textpos)
- textinfo
- (strcat
- (rtos(vlax-safearray-get-element
- arrayTextpos
- 0
- )
- 2
- 2
- )
- "'"
- (rtos(vlax-safearray-get-element
- arrayTextpos
- 1
- )
- 2
- 2
- )
- "'"
- (rtos(vlax-safearray-get-element
- arrayTextpos
- 2
- )
- 2
- 2
- )
- )
- )
- (setq pg(mswp-get-last paragraphs))
- (setq range (mswp-get-range pg)
- (mswp-put-bold range 1)
- (mswp-put-underline range mswc-wdUnderlineSingle)
- (mswm-InsertAfter
- range
- (strcat "AcDBMText at position" textinfo "\n")
- )
- (setq pg (mswp-get-last paragraphs))
- (setq range (mswp-get-range pg))
- (mswp-put-bold range 0)
- (mswp-put-bold range 0)
- (mswp-put-underline range mswc-wdUnderlineNone)
- (mswm-InsertAfter range (strcat text "\n\n"))
- )
- )
- )
- )
- (princ "\nNo Microsoft Word application found.\n")
- )
|