从atc文件中导入部件但挡墙dwg中,
工具选项板对应的atc文件与创建部件pkt文件中的atc文件稍有区别,
主要体现在dll文件的路径上,
另外数据类型名称,
需要首字母大写,
比如Double不能写成double,
如果是小写,
导入过程中识别不了部件的参数...
测试代码如下:
public void C_SaiTest() { Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; Editor ed = acDoc.Editor; CivilDocument civilDoc = CivilApplication.ActiveDocument; var rootkey = HostApplicationServices.Current.UserRegistryProductRootKey; RegistryKey key = Registry.CurrentUser.OpenSubKey(rootkey); var rrf = key.GetValue("RoamableRootFolder").ToString(); //部件的GUID string guid = "55729DA9-FCBF-465B-A4D1-E2E88DD56F50"; using (Transaction tr = acDoc.TransactionManager.StartTransaction()) { //ESSubassembly.atc为路基选项板对应的atc文件 var saId = civilDoc.SubassemblyCollection.ImportSubassembly("双线铁路路基", rrf + @"\Support\ToolPalette\Palettes\ESSubassembly.atc", guid, Point3d.Origin); var id = civilDoc.AssemblyCollection.Add("双线铁路路基", AssemblyType.Other, Point3d.Origin); //var sa = saId.GetObject(OpenMode.ForWrite) as Subassembly; //ed.WriteMessage("\n" + sa.ParamsDouble.Count); var ass = id.GetObject(OpenMode.ForWrite) as Assembly; ass.AddSubassembly(saId); tr.Commit(); } }