SurfaceOperation收集和排序SurfaceOperationObject
你好我从图形中的曲面读取了SurfaceOperationCollection。此曲面具有不同的类型(或包括曲面操作)。在我处理曲面之前(例如,删除或创建新的曲面操作,如特征线、等高线或边界…),所有这些曲面操作都在集合中进行了正确排序。编辑后,我希望在曲面中进行与之前相同的排序
在表面操作中,它有不同的方法,如MoveUp()或MoveDown()。有人在林克郡的Sytax和他们一起工作过。我非常感谢能得到一些建议
**** Hidden Message ***** 也许更好的描述:
我必须删除Surface中的边界,而不是重新创建它们并设置与以前相同的名称。重新创建的边界的位置在SurfacoperationCollection的末尾。但它必须位于位置2(例如)
public static SurfaceOperationCollection ReadSurfaceOperations(TinSurface tinsurf)
{
Document acadDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
using (Transaction tr = acadDoc.TransactionManager.StartTransaction())
{
SurfaceOperationCollection SuOpColl = tinsurf.Operations;
tr.Commit();
return SuOpColl;
}
}
public static void SortSurfaceOperations(SurfaceOperationCollection before, SurfaceOperationCollection after)
{
Document acadDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
using (Transaction tr = acadDoc.TransactionManager.StartTransaction())
{
var m_Bef = from x in before.GetType().FullName
//where x.GetType().FullName == "Autodesk.Civil.DatabaseServices.SurfaceOperationAddBoundary"
select x;
var m_Aft = from x in before.GetType().FullName
//where x.GetType().FullName == "Autodesk.Civil.DatabaseServices.SurfaceOperationAddBoundary"
select x;
foreach(SurfaceOperation x in m_Bef)
{
foreach(SurfaceOperation y in m_Aft)
{
if(x != y)
{
y.MoveUp();
}
}
}
tr.Commit();
}
}
Dirk,您不能将Linq与SurfaceAction ationCollection一起使用,因为它没有GetEnumator()方法。就像您不能将foreach()与此集合一起使用一样,因此,您必须使用for()循环。以下代码没有经过测试,但应该可以工作(或者无论如何都接近工作)。公共静态空SortSurfaceAction(之前是SurfaceAction ationCollection,之后是SurfaceAction ationCollection)。
{。
文档acadDoc=Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;。
使用(事务tr=acadDoc.TransactionManager.StartTransaction())。
{。
bool完成=false;。
对于(int i=0; i。
{。
var x=在之前;。
if(x.GetType () == 类型)。
{。
for(int j=0; j。
{。
var y=在之后;。
if(y.GetType () == 类型)。
{。
同时(i。
{。
y.MoveUp();。
j--;。
}。
完成=真;。
休息;。
}。
}。
}。
如果(完成)。
休息;。
}。
tr.Commit();。
}。
}。
。
再次感谢杰夫!
你是我的“患难之交”
页:
[1]