nhy12345678 发表于 2008-5-14 15:21:00

如何获得最近一次创建的对象?

<p>如何获得最近一次创建的对象?谢谢,能在VBA中使用的哈。</p>

job_ho 发表于 2008-5-14 17:04:00

<p>可以參考OBJECTADDED事件</p><p>或許可以吧!</p>

wylong 发表于 2008-5-14 18:17:00

<p>&nbsp;&nbsp;&nbsp; ' 返回当前模型空间中最后一个实体方法一</p><p>&nbsp;&nbsp;&nbsp; Dim InsertBlock As Object<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;Set InsertBlock = ThisDrawing.ModelSpace.Item(ThisDrawing.ModelSpace.Count - 1)</p><p><br/>&nbsp;&nbsp;&nbsp; ' 返回当前模型空间中最后一个实体方法二</p><p>&nbsp;&nbsp;&nbsp; Dim SSet As OBJECT<br/>&nbsp;&nbsp;&nbsp; Dim InsertBlock As OBJECT<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp; Set SSet = ThisDrawing.SelectionSets("ss")<br/>&nbsp;&nbsp;&nbsp; If Err Then Set SSet = ThisDrawing.SelectionSets.Add("ss")<br/>&nbsp;&nbsp;&nbsp; SSet.Select acSelectionSetLast '注意这里 acSelectionSetLast !!<br/>&nbsp;&nbsp;&nbsp; Set InsertBlock = SSet.Item(0)<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp; Set SSet = Nothing<br/>&nbsp;&nbsp;&nbsp; ThisDrawing.SelectionSets("ss").Delete</p>

bios8086 发表于 2008-5-14 20:01:00

<p>&nbsp;Dim textObj As AcadText</p><p>textObj = ThisDrawing.ModelSpace.Item(0)<br/>&nbsp;text = textObj.TextString</p><p></p><p>textObj 可以这样得到吗?</p><p></p><p></p>

xxxtttxxx 发表于 2008-5-14 21:15:00

<p>set textObj = ThisDrawing.ModelSpace.Item(0)<br/></p><p></p><p>所有的对象都要用set的方法</p>

xxxtttxxx 发表于 2008-5-14 21:16:00

<p>set textObj = ThisDrawing.ModelSpace.Item(0)<br/></p><p></p><p>所有的对象都要用set的方法</p>

nhy12345678 发表于 2008-5-15 10:46:00

非常感谢各位的帮助,<strong><font face="Verdana" color="#61b713">wylong<font color="#000000">的答案比较全面和正确</font></font></strong>
页: [1]
查看完整版本: 如何获得最近一次创建的对象?