private static void CurrentDocument_CommandWillStart(object sender, CommandEventArgs e)
{
string sCmdName = e.GlobalCommandName.ToUpper();
if (sCmdName.Contains("REFEDIT") || sCmdName.Contains("BEDIT"))
{
}
}
private static void DocumentManager_DocumentLockModeChanged(object sender, DocumentLockModeChangedEventArgs e)
{
//定义数据库
Database db = HostApplicationServices.WorkingDatabase;
string sCmdName = e.GlobalCommandName.ToUpper();
if (e.CurrentMode== DocumentLockMode.Write && (sCmdName.Contains("REFEDIT") || sCmdName.Contains("BEDIT")))
{
SelectHelper sh = new SelectHelper();
using (Transaction trans = db.TransactionManager.StartTransaction())
{
sh.GetEntity("
请点选一个块参照…", "INSERT");
if (sh.Status == PromptStatus.OK)
{
try
{
BlockReference brf = (BlockReference)trans.GetObject(sh.ResultObjectId, OpenMode.ForRead);
string sPartType = brf.GetXdataPartType();
if (!string.IsNullOrEmpty(sPartType))
{
PvEntityEdit(brf, sPartType);
e.Veto();
}
}
catch
{
e.Veto();
}
}
else
{
e.Veto();
}
trans.Commit();
}
}
}