sieben 发表于 2006-8-15 16:20:00

C# 当前图形中引入其它未打开的图形中的图块

<P>&nbsp;&nbsp;C# 当前图形中引入其它未打开的图形中的图块<BR>&nbsp;&nbsp;static public void DBX_InsertBlock(string fileName, string blockName,AcadModelSpace CurSpace)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;AxDbDocumentClass dbx = new AxDbDocumentClass();<BR>&nbsp;&nbsp;&nbsp;dbx.Open(fileName, "");<BR>&nbsp;&nbsp;&nbsp;AcadBlock[] blk1 = new AcadBlock;<BR>&nbsp;&nbsp;&nbsp;for (int i = 0; i &lt; dbx.Blocks.Count; i++)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (dbx.Blocks.Item(i).Name&nbsp; == blockName)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;blk1 = (AcadBlock)dbx.Blocks.Item(i);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Object missing = Type.Missing;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dbx.CopyObjects(blk1, CurSpace, ref missing);&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;}</P>
<P>各位老大:</P>
<P>上面代码能实现"当前图形中引入其它未打开的图形中的图块"<BR></P>
<P>但要怎样才能断了dbx的连接啊?好象要退出AutoCAD这个连接才会断.</P>
<P>否则不能对fileName这个文件进行操作.</P>

xiaojinwen 发表于 2006-11-18 20:35:00

<P>你建一个空的如TEMP.DWG文件,使用完上述文件后再</P>
<P>dbx.Open("TEMP.DWG", "");</P>
<P>应该可以解决问题的。</P>
<P>一个对象不可能同时开两个文件的<BR></P>
页: [1]
查看完整版本: C# 当前图形中引入其它未打开的图形中的图块