找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 585|回复: 4

[每日一码] Get path of file on clipboard

[复制链接]

已领礼包: 859个

财富等级: 财运亨通

发表于 2017-1-15 15:49:58 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
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 String
  Dim dataObject As IDataObject =
    System.Windows.Clipboard.GetDataObject()

  ' Get the list of available formats
  Dim 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 If
  Next

  Return Nothing
End 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!
游客,如果您要查看本帖隐藏内容请回复
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 2409个

财富等级: 金玉满堂

发表于 2017-4-12 10:35:32 | 显示全部楼层
学习!!!!!!!!!!!!!!!!!!!!!!!!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复

使用道具 举报

已领礼包: 2963个

财富等级: 家财万贯

发表于 2017-4-12 12:54:31 | 显示全部楼层
回复学习,学习分享
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2017-4-12 13:55:19 | 显示全部楼层
回复回复,学习学习
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 2226个

财富等级: 金玉满堂

发表于 2024-3-14 20:27:55 | 显示全部楼层
学习!!!!!!!!!!!!!!!!!!!!!!!!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-4-29 15:26 , Processed in 0.259251 second(s), 35 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表