Skip to content

Commit b0823e1

Browse files
author
vicwjb
committed
增加批量插入dxf到当前空间的示例
1 parent 0805b78 commit b0823e1

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tests/TestShared/TestBlock.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,31 @@ public void Test_BlockFile()
262262
tr.CurrentSpace.InsertBlock(Point3d.Origin, id);
263263
}
264264

265+
[CommandMethod(nameof(Test_BlockFiledxf))]
266+
public void Test_BlockFiledxf()
267+
{
268+
string [] files;
269+
var folder= new System.Windows.Forms.FolderBrowserDialog();
270+
if (folder.ShowDialog() == System.Windows.Forms.DialogResult.OK)
271+
{
272+
files = Directory.GetFiles(folder.SelectedPath,"*.dxf",SearchOption.AllDirectories);
273+
using DBTrans tr = new();
274+
foreach (var item in files)
275+
{
276+
var id = tr.BlockTable.GetBlockFrom(item, false);
277+
var pt = Env.Editor.GetPoint("pick pt");
278+
if (pt.Status == PromptStatus.OK)
279+
{
280+
tr.CurrentSpace.InsertBlock(pt.Value, id);
281+
Env.Editor.Redraw();
282+
}
283+
284+
}
285+
286+
}
287+
288+
289+
}
265290

266291
[CommandMethod(nameof(Test_ClipBlock))]
267292
public void Test_ClipBlock()

0 commit comments

Comments
 (0)