天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 64|回复: 0

arx 禁用 COPY,PASTE 命令

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
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.
普通浏览复制代码
void CEdReactor::commandEnded(const char *cmd)
{
acutPrintf ("Command Ended %s\n", cmd);

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

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

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

  if (NULL != pLayerTable)
  {
   if ((es = pLayerTable->getAt(kchLayerName,pLayerTableRecord,AcDb::kForWrite))==
Acad::eOk)
   {
    //layer name 'Layer1' has been found. Check if it is locked ??
    if (pLayerTableRecord->isLocked() != true)
    {
     //if not locked lock the the same
     pLayerTableRecord->setIsLocked(true);
    }
   }
  }
  pLayerTableRecord->close();
  pLayerTable->close();
}
}


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

 

 

 

 

arx  禁用 COPY,PASTE 命令
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

GMT+8, 2024-11-1 15:22 , Processed in 0.167880 second(s), 26 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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