参照这个帖子,
简单修改了一下,
改成了扩展方法:
public static void MoveTo(this TinSurface sur,string folderName) { var surfRootFolderId = Autodesk.Civil.DatabaseServices.FolderUtil.GetNonAlignmentRootFolder(RXClass.GetClass(typeof(Autodesk.Civil.DatabaseServices.Surface)), sur.Database); using (Transaction tr = sur.Database.TransactionManager.StartTransaction()) { var surfRootFolder = (Folder)tr.GetObject(surfRootFolderId, OpenMode.ForWrite); Folder folder = null; foreach (ObjectId id in surfRootFolder.GetSubFolders()) { var f = (Folder)tr.GetObject(id, OpenMode.ForRead); if (f.Name == folderName) { folder = f; folder.UpgradeOpen(); break; } } if (folder == null) folder = (Folder)tr.GetObject(surfRootFolder.CreateFolder(folderName), OpenMode.ForWrite); if (sur.FolderId != folder.ObjectId) folder.AddEntity(sur.ObjectId); tr.Commit(); } }
标签:OpenMode,tr,GetObject,文件夹,sur,曲面,folder,Folder,移植 From: https://www.cnblogs.com/myzw/p/18125481