[求助].Net下如何实现ads_entlast()及ads_entnext()类似功能?
<p>程序代码如下:</p><p> </p>
<p><font face="Verdana"> //拷贝层图到点上<br/> ads_ssadd(NULL, NULL, newSs); //新建选择集newSs<br/> ads_entlast(las);---------------------------------------此处选择drawing中最后一个图形<br/> ads_point pt;<br/> pt=10.0; pt=10.0;<br/> ads_command(RTSTR,"copy", RTPICKS,CengSs,RTSTR,"", <br/> RT3DPOINT,pt, RT3DPOINT,pt, 0); --------------------------------使用copy命令添加CengSs(层图选择集)的复制对象<br/> //拷贝的层图放入新的选择集<br/> int seted=0;<br/> while(ads_entnext(las, nex)==RTNORM) <br/> {<br/> ads_ssadd(nex, newSs, newSs);<br/> ads_name_set(nex, las);<br/> ......<br/> }</font></p>
<p> </p>
<p>程序总体要实现将一个SelectionSet中的实体复制到另一个新的SelectionSet中,该怎么实现?</p> 问题该如何解决的,楼主 复制用
<div class="Element5">Database.DeepCloneObjects Method</div>
<p>这个方法会返回一个IdMapping对象,里面有复制后的实体ID,</p> 谢谢斑竹,想问下使用InvokeArx.Command<font face="Verdana">(false,"copy",CengSs,"",pt,pt)复制得到的SelectionSet,在.NET下有办法访问吗(CengSs为一SelectionSet)?</font> <p><font face="Verdana">Autodesk.AutoCAD.Internal命名空间有的</font></p>
<p><font face="Verdana"></font> </p>
<p><font face="Verdana">public static Autodesk.AutoCAD.DatabaseServices.ObjectId EntFirst()<br/> Autodesk.AutoCAD.Internal.Utils 的成员<br/><font face="Verdana">public static Autodesk.AutoCAD.DatabaseServices.ObjectId EntLast()<br/> Autodesk.AutoCAD.Internal.Utils 的成员<br/><font face="Verdana">public static Autodesk.AutoCAD.DatabaseServices.ObjectId EntNext(Autodesk.AutoCAD.DatabaseServices.ObjectId entId)<br/> Autodesk.AutoCAD.Internal.Utils 的成员<br/><font face="Verdana">public static Autodesk.AutoCAD.DatabaseServices.ObjectId EntNext(Autodesk.AutoCAD.DatabaseServices.ObjectId entId, bool skipSubEnt)<br/> Autodesk.AutoCAD.Internal.Utils 的成员<br/></p></font></font></font></font> 这个是好东西,谢谢 <p>问下斑竹的AutoCAD是哪个版本的,我的Autodesk.AutoCAD.Internal.Utils类在【对象浏览器】下找不到上面的方法,版本AutoCAD2008?</p>
<p> </p> <p>Cad2010</p>
<p>命令调用在.Net中少用,尽量使用Api提供的方法</p> <p>但有时非得用命令不过啊~!</p>
<p>俺常用的是CAD2008</p>
<p> </p>
<p>老大给个在2008下的entnext entlast解决方法哈!~</p> 嗯,力挺楼上! 本帖最后由 作者 于 2010-11-20 21:52:29 编辑
InvokeArx.cs+
private static extern int acdbEntLast(long[] name);
public static bool EntLast(out long[] name)
{
name = new long;
int errStatus = acdbEntLast(name);
return errStatus == 5100;
}
private static extern int acdbEntNext(long[] name, long[] next);
public static bool EntNext(long[] name, out long[] next)
{
next = new long;
int errStatus = acdbEntNext(name, next);
return errStatus == 5100;
}
private static extern IntPtr acdbEntGet(long[] name);
public static ResultBuffer EntGet(long[] name)
{
IntPtr ip = acdbEntGet(name);
if(ip != IntPtr.Zero)
return ResultBuffer.Create(ip, false);
return null;
}
private static extern ErrorStatus acdbGetObjectId(ref ObjectId id, long[] name);
public static ObjectId GetObjectId(long[] name)
{
ObjectId id = ObjectId.Null;
ErrorStatus errStatus = acdbGetObjectId(ref id, name);
return id;
}
调用:
public static void test26()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
long[] name;
InvokeArx.EntLast(out name);
ed.WriteMessage("\n" + name.ToString());
InvokeArx.Command(false, "line", Point3d.Origin, new Point3d(10, 10, 0));
long[] next;
InvokeArx.EntNext(name, out next);
ed.WriteMessage("\n" + next.ToString());
ResultBuffer rb = InvokeArx.EntGet(next);
ed.WriteMessage("\n" + rb.ToString());
var id = InvokeArx.GetObjectId(next);
ed.WriteMessage("\n" + id.ToString());
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Line l = tr.GetObject(id, OpenMode.ForWrite) as Line;
l.ColorIndex = 2;
tr.Commit();
}
}
先在图里画一个图元
命令: 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)
页:
[1]
2