明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4831|回复: 13

[运行时] [求助].Net下如何实现ads_entlast()及ads_entnext()类似功能?

  [复制链接]
发表于 2010-11-19 15:17 | 显示全部楼层 |阅读模式

程序代码如下:

 

 //拷贝层图到点上
 ads_ssadd(NULL, NULL, newSs); //新建选择集newSs
 ads_entlast(las);---------------------------------------此处选择drawing中最后一个图形
 ads_point pt;
 pt[X]=10.0; pt[Y]=10.0;
 ads_command(RTSTR,"copy", RTPICKS,CengSs,RTSTR,"", 
    RT3DPOINT,pt, RT3DPOINT,pt, 0);   --------------------------------使用copy命令添加CengSs(层图选择集)的复制对象
 //拷贝的层图放入新的选择集
 int seted=0;
 while(ads_entnext(las, nex)==RTNORM) 
 {
  ads_ssadd(nex, newSs, newSs);
  ads_name_set(nex, las);
  ......
 }

 

程序总体要实现将一个SelectionSet中的实体复制到另一个新的SelectionSet中,该怎么实现?

发表于 2020-12-15 14:32 | 显示全部楼层
问题该如何解决的,楼主
发表于 2010-11-19 17:19 | 显示全部楼层
复制用
Database.DeepCloneObjects Method

这个方法会返回一个IdMapping对象,里面有复制后的实体ID,

 楼主| 发表于 2010-11-19 23:08 | 显示全部楼层
谢谢斑竹,想问下使用InvokeArx.Command(false,"copy",CengSs,"",pt,pt)复制得到的SelectionSet,在.NET下有办法访问吗(CengSs为一SelectionSet)?
发表于 2010-11-20 09:22 | 显示全部楼层

Autodesk.AutoCAD.Internal命名空间有的

 

public static Autodesk.AutoCAD.DatabaseServices.ObjectId EntFirst()
    Autodesk.AutoCAD.Internal.Utils 的成员
public static Autodesk.AutoCAD.DatabaseServices.ObjectId EntLast()
    Autodesk.AutoCAD.Internal.Utils 的成员
public static Autodesk.AutoCAD.DatabaseServices.ObjectId EntNext(Autodesk.AutoCAD.DatabaseServices.ObjectId entId)
    Autodesk.AutoCAD.Internal.Utils 的成员
public static Autodesk.AutoCAD.DatabaseServices.ObjectId EntNext(Autodesk.AutoCAD.DatabaseServices.ObjectId entId, bool skipSubEnt)
    Autodesk.AutoCAD.Internal.Utils 的成员

 楼主| 发表于 2010-11-20 09:40 | 显示全部楼层
这个是好东西,谢谢
 楼主| 发表于 2010-11-20 10:45 | 显示全部楼层

问下斑竹的AutoCAD是哪个版本的,我的Autodesk.AutoCAD.Internal.Utils类在【对象浏览器】下找不到上面的方法,版本AutoCAD2008?

 

本帖子中包含更多资源

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

x
发表于 2010-11-20 11:13 | 显示全部楼层

Cad2010

命令调用在.Net中少用,尽量使用Api提供的方法

发表于 2010-11-20 11:53 | 显示全部楼层

但有时非得用命令不过啊~!

俺常用的是CAD2008

 

老大给个在2008下的entnext entlast解决方法哈!~

 楼主| 发表于 2010-11-20 13:54 | 显示全部楼层
嗯,力挺楼上!
发表于 2010-11-20 16:04 | 显示全部楼层
本帖最后由 作者 于 2010-11-20 21:52:29 编辑

InvokeArx.cs+
  1.         [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
  2.         private static extern int acdbEntLast(long[] name);
  3.         public static bool EntLast(out long[] name)
  4.         {
  5.             name = new long[2];
  6.             int errStatus = acdbEntLast(name);
  7.             return errStatus == 5100;
  8.         }
  9.         [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
  10.         private static extern int acdbEntNext(long[] name, long[] next);
  11.         public static bool EntNext(long[] name, out long[] next)
  12.         {
  13.             next = new long[2];
  14.             int errStatus = acdbEntNext(name, next);
  15.             return errStatus == 5100;
  16.         }
  17.         [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
  18.         private static extern IntPtr acdbEntGet(long[] name);
  19.         public static ResultBuffer EntGet(long[] name)
  20.         {
  21.             IntPtr ip = acdbEntGet(name);
  22.             if(ip != IntPtr.Zero)
  23.                 return ResultBuffer.Create(ip, false);
  24.             return null;
  25.         }
  26.         [DllImport("acdb17.dll", CallingConvention = CallingConvention.Cdecl)]
  27.         private static extern ErrorStatus acdbGetObjectId(ref ObjectId id, long[] name);
  28.         public static ObjectId GetObjectId(long[] name)
  29.         {
  30.             ObjectId id = ObjectId.Null;
  31.             ErrorStatus errStatus = acdbGetObjectId(ref id, name);
  32.             return id;
  33.         }

调用:
  1.         [CommandMethod("tt6")]
  2.         public static void test26()
  3.         {
  4.             Document doc = Application.DocumentManager.MdiActiveDocument;
  5.             Editor ed = doc.Editor;
  6.             Database db = doc.Database;
  7.             long[] name;
  8.             InvokeArx.EntLast(out name);
  9.             ed.WriteMessage("\n" + name[0].ToString());
  10.             InvokeArx.Command(false, "line", Point3d.Origin, new Point3d(10, 10, 0));
  11.             long[] next;
  12.             InvokeArx.EntNext(name, out next);
  13.             ed.WriteMessage("\n" + next[0].ToString());
  14.             ResultBuffer rb = InvokeArx.EntGet(next);
  15.             ed.WriteMessage("\n" + rb.ToString());
  16.             var id = InvokeArx.GetObjectId(next);
  17.             ed.WriteMessage("\n" + id.ToString());
  18.             using (Transaction tr = db.TransactionManager.StartTransaction())
  19.             {
  20.                 Line l = tr.GetObject(id, OpenMode.ForWrite) as Line;
  21.                 l.ColorIndex = 2;
  22.                 tr.Commit();
  23.             }
  24.         }
先在图里画一个图元
命令: tt6
9033026376985834376指定第一点: _non
指定下一点或 [放弃(U)]: _non
指定下一点或 [放弃(U)]:
命令:
9033026480065049488
((-1,(2130277264))(0,LINE)(330,(2130271480))(5,1B2)(100,AcDbEntity)(67,0)(410,Mo
del)(8,0)(100,AcDbLine)(10,(0,0,0))(11,(10,10,0))(210,(0,0,1)))
(2130277264)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-28 14:29 , Processed in 0.305369 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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