找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 2185|回复: 2

[其他] 禁用 COPY,PASTE 命令

[复制链接]

已领礼包: 40个

财富等级: 招财进宝

发表于 2021-1-31 00:14:50 | 显示全部楼层 |阅读模式

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

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

×
Disabling copy, paste functionality   

问题:

You can do this by placing the entities on a locked layer. The same can be achieved
with API as follows. Make sure that you have layer named "Layer1" which is locked
(or modify the code to your needs). When you execute the attached code you are
prompted to select the entity. You can extend the same for a set of entities
by using acedSSGet().

解答:

Since there is a possibility that user might change the layer settings by invoking
'LAYER' command, You can restrict user not to unlock the layer by implementing
'AcEditorReactor'.

Please look at the attached code for (locklayer.cpp) implementation. Assume
user will invoke
Format-->Layer and unlocks the layers named 'Layer1' and clicks on OK. As soon
as layer dialog is closed following code snippet will be executed.
  1. void CEdReactor::commandEnded(const char *cmd)
  2. {
  3. acutPrintf ("Command Ended %s\n", cmd);

  4. //check if the latest command invoked is LAYER ??
  5. if ((_tcsicmp("layer", cmd) == 0)||(_tcscmp("-LAYER", cmd) == 0))
  6. {
  7.   //The following piece of code makes 'layer1' always in locked mode
  8.   Acad::ErrorStatus      es;
  9.   AcDbLayerTable*        pLayerTable = NULL;
  10.   AcDbLayerTableRecord*  pLayerTableRecord = NULL;

  11.   if ((es = acdbHostApplicationServices()->workingDatabase()->getLayerTable(pLayerTable,
  12. AcDb::kForRead))!= Acad::eOk)
  13.   {
  14.      acutPrintf ("Layer table open has failed\n");
  15.      pLayerTable->close();
  16.      return;
  17.   }

  18.   const char* kchLayerName = "Layer1"; /* assume this is what you want to be locked*/
  19.   AcDbObjectId recordId;
  20.   AcDbEntity* pEnt = NULL;

  21.   if (NULL != pLayerTable)
  22.   {
  23.    if ((es = pLayerTable->getAt(kchLayerName,pLayerTableRecord,AcDb::kForWrite))==
  24. Acad::eOk)
  25.    {
  26.     //layer name 'Layer1' has been found. Check if it is locked ??
  27.     if (pLayerTableRecord->isLocked() != true)
  28.     {
  29.      //if not locked lock the the same
  30.      pLayerTableRecord->setIsLocked(true);
  31.     }
  32.    }
  33.   }
  34.   pLayerTableRecord->close();
  35.   pLayerTable->close();
  36. }
  37. }


The one drawback of this implementation is that even for first time if you invoke
the layer dialog to create the 'Layer1' it locks for you.
You need to decide the appropriate time when you want to load this application
(need more customization which suits to your requirements

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

已领礼包: 226个

财富等级: 日进斗金

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

使用道具 举报

已领礼包: 226个

财富等级: 日进斗金

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-12-22 13:50 , Processed in 0.399850 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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