明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1164|回复: 3

[运行时] 尝试读取或写入受保护的内存

[复制链接]
发表于 2013-9-13 16:03 | 显示全部楼层 |阅读模式
  try
            {
                Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
                DocumentLock docLock = doc.LockDocument();
                ObjectId LastId = new ObjectId();
                string SelectId = dg_data.Rows[e.RowIndex].Cells[0].Value.ToString();
                string Rid = SelectId.Replace("(", "").Replace(")", "");
                Int64 Fid = Int64.Parse(Rid);
                IntPtr Sid = (IntPtr)Fid;
                ObjectId Id = new ObjectId(Sid);
                Database extDatabase = new Database(false,false);
                using (Transaction trans = extDatabase.TransactionManager.StartTransaction())
                {
                    try
                    {
                        if (LastId != null)
                        {
                            Entity Ent = trans.GetObject(LastId, OpenMode.ForRead) as Entity;
                            Ent.Unhighlight();
                        }
                    }
                    catch { }
                    Entity ent = trans.GetObject(Id, OpenMode.ForRead) as Entity;
                    if (ent.GetType().Name == "Line")
                    {
                        ent.Highlight();
                        //Line line = ent as Line;
                        //if (line != null)
                        //{
                        //    line.StartPoint = new Point3d(0.0,0.0,0.0);
                        //    line.EndPoint = new Point3d(0.0, 0.0, 0.0);
                        //}
                    }
                    LastId = Id;
                    //ent.TransformBy(Matrix3d.Displacement(new Vector3d(0, 0, 3)));//移动整个实体
                    trans.Commit();
                }
                docLock.Dispose();
            }
            catch { }

红色报错  尝试读取或写入受保护的内存。这通常指示其他内存已损坏。   请高手帮忙看下~我想让实体闪烁Highlight
而且我想修改直线的 line.StartPoint = new Point3d(0.0,0.0,0.0);
                        //    line.EndPoint = new Point3d(0.0, 0.0, 0.0);

不知道这样可不可以  求高手!!!
 楼主| 发表于 2013-9-13 16:29 | 显示全部楼层
如果有错误 请大家提出来,或者那里要改的请告诉我一下,谢谢了~
发表于 2013-9-14 07:51 | 显示全部楼层
本帖最后由 ps122hb 于 2013-9-14 07:54 编辑

这个得在环境下调试
 楼主| 发表于 2013-9-14 10:22 | 显示全部楼层
ps122hb 发表于 2013-9-14 07:51
这个得在环境下调试

好的 ,谢谢~
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-11 03:18 , Processed in 0.141960 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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