Get path of file on clipboard
Get path of file on clipboard By Adam NagyAs 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 ***** 学习!!!!!!!!!!!!!!!!!!!!!!!!
回复学习,学习分享
回复回复,学习学习 学习!!!!!!!!!!!!!!!!!!!!!!!! 回复学习,学习分享
页:
[1]