wsad1231 发表于 2009-2-11 19:19:00

怎么把图编译成块

<p>我想吧画的圆编译成块 并且属性标注知道这圆的中心和半径</p><p>现在圆点的坐标我知道了怎么知道半径啊&nbsp;&nbsp; </p><p>谁有关于块的这方面的知识介绍下 谢谢 网上好多的 都是大致带过没有具体的说</p>

nhy12345678 发表于 2009-2-12 23:01:00

本帖最后由 作者 于 2009-2-12 23:04:54 编辑 <br /><br /> <p>给你个完整的代码:</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 功能为你选择一个圆,立即把这个圆创建为一个块,并把注释写入圆的圆心坐标和半径,然后显示该注释内容检验正确性,最后把该块插入到图纸中。</p><p>Sub ttttt()<br/>Dim ss As AcadSelectionSet<br/>Dim c(0 To 0) As AcadCircle<br/>Dim ent As AcadEntity<br/>Dim blockObj As AcadBlock<br/>Dim cc As Variant<br/>Dim r As Double<br/>Set ss = ThisDrawing.SelectionSets.Add("ssss") '在屏幕上选择对象<br/>ss.SelectOnScreen<br/>For Each ent In ss<br/>&nbsp;&nbsp;&nbsp; If ent.ObjectName = "AcDbCircle" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set c(0) = ent<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cc = c(0).Center<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r = c(0).Radius<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GoTo aa<br/>&nbsp;&nbsp;&nbsp; End If<br/>Next<br/>MsgBox "你没有选择到任何圆形对象!"<br/>ss.Delete<br/>End<br/>aa:<br/>Set blockObj = ThisDrawing.Blocks.Add(cc, "圆形块")<br/>ThisDrawing.CopyObjects c, blockObj<br/>blockObj.Comments = "圆心:" &amp; cc(0) &amp; "," &amp; cc(1) &amp; "," &amp; cc(2) &amp; "," &amp; "&nbsp;&nbsp;&nbsp; 半径:" &amp; r<br/>MsgBox blockObj.Comments '显示块注释<br/>ThisDrawing.ModelSpace.InsertBlock cc, "圆形块", 1, 1, 1, 0 '插入建立的块<br/>ss.Delete<br/>End Sub</p>

home 发表于 2009-2-13 22:33:00

<p>楼上的程序是用哪个版本运行的?</p><p>blockObj.Comments ……</p><p>怎么我的块没有这个属性呢,运行不过去?</p><p></p>
页: [1]
查看完整版本: 怎么把图编译成块