csharp 发表于 2017-1-15 15:49:58

Get path of file on clipboard

Get path of file on clipboard By Adam Nagy
As mentioned in Kean's blog post, when you select entities in a drawing inside AutoCAD and run _COPYCLIP (Ctrl+C) then AutoCAD will WBLOCK out the selected entities into a temp DWG file. The content that's placed on the clipboard will also contain the path to that temp file. In case you would like to use that file, here is one way to find out its path:
Public Function GetClipboardFilePath() As StringDim dataObject As IDataObject =     System.Windows.Clipboard.GetDataObject()
' Get the list of available formatsDim formats() As String = dataObject.GetFormats()
For Each format As String In formats    ' In case of AutoCAD 2013 this would be "AutoCAD.R19"    If format.StartsWith("AutoCAD.") Then      Using stream As MemoryStream = dataObject.GetData(format)      ' Unicode encoding is 16 bit (2 bytes) just like ACHAR      Using reader As TextReader =           New StreamReader(stream, System.Text.Encoding.Unicode)           ' 0..259 = 260           Dim text(259) As Char           reader.Read(text, 0, 260)          ' There will be lots of 0 value characters in the array          ' that we need to clean up             Return New String(text).TrimEnd(New Char(){Chr(0)})         End Using      End Using     End IfNext
Return NothingEnd Function



以下为 ObjectARX 实现, AutoCAD 2004 + XP 测试 OK
命令: mycommand
Ok, temp file= C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\A$C28C724E3.DWG
命令: 指定对角点:
命令: mycommand
No AutoCAD clipboard entity!
**** Hidden Message *****

zjy2999 发表于 2017-4-12 10:35:32

学习!!!!!!!!!!!!!!!!!!!!!!!!

819534890 发表于 2017-4-12 12:54:31

回复学习,学习分享

pupubear 发表于 2017-4-12 13:55:19

回复回复,学习学习

cable2004 发表于 2024-3-14 20:27:55

学习!!!!!!!!!!!!!!!!!!!!!!!!

w15994259099 发表于 2024-7-9 13:54:14

回复学习,学习分享
页: [1]
查看完整版本: Get path of file on clipboard