glyyy 发表于 2007-4-10 10:26:00

[求助]pb开发AUTOCAD中GETBOUNDINGBOX问题

<p>请教下有谁用过PB开发AUTOCAD 的</p><p>我在VB中使用GETBOUNDINGBOX能够得到坐标</p><p>但在PB下总是空值 ,得不到数据,望达人指点一二~</p><p>int oleok<br/>oleobject olecad,olecaddoc<br/>oleobject olemospace,olepaspace</p><p>//连接CAD<br/>olecad=create oleobject<br/>oleok=olecad.connecttoobject("","autocad.application")<br/>if oleok&lt;&gt; 0 then //没打开AUTOCAD<br/>&nbsp;oleok=olecad.ConnectToNewObject("AUTOCAD.Application")<br/>&nbsp;if oleok &gt; 0 then<br/>&nbsp;&nbsp;messagebox("OLE失败","该功能无法使用!"+"~n"+"请先安装autocad。",stopsign!)<br/>&nbsp;end if<br/>end if <br/>olecad.visible=true<br/>olecaddoc&nbsp; = olecad.activedocument<br/>olemospace = olecaddoc.modelspace<br/>olepaspace = olecaddoc.paperspace</p><p></p><p>oleobject&nbsp; elem<br/>decimal{3} x1,y1,x2,y2,xb1,yb1,xb2,yb2//文字的坐标<br/>decimal{3} minext,maxext//边界的坐标<br/>decimal{3} min[],max[]<br/>double li_elem[],minpoint[],maxpoint[]</p><p>integer li_count,i,m,k<br/>string ls_name<br/>any s</p><p>m=1<br/>//li_elem = upperbound(olemospace.elem[])<br/>//for each elem in olemospace<br/>//next elem<br/>//得到边界坐标<br/>minext[] = olecaddoc.getvariable("extmin")<br/>maxext[] = olecaddoc.getvariable("extmax")<br/>xb1=minext<br/>xb2=maxext<br/>yb1=minext<br/>yb2=maxext<br/>//sle_1.text=string(x1)<br/>//messagebox("wr",string(minext)+"&nbsp; "+string(minext))<br/>//messagebox("wr",string(maxext)+"&nbsp; "+string(maxext))<br/>li_count = olemospace.count</p><p>//messagebox("er",string(li_count))</p><p>for i =1 to li_count - 6<br/>//for i =1 to 44<br/>//&nbsp;ls_name =string(olemospace.item(i).EntityName)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elem = olemospace.item(i)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If elem.EntityName = "AcDbBlockReference" Then<br/>&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elem.Explode()</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;If elem.EntityName = "AcDbText" Or elem.EntityName = "AcDbMText" Then<br/>//If olemospace.item(i).EntityName = "AcDbText" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp; elem.getboundingbox(min,max) //得到坐标<br/>&nbsp;&nbsp;&nbsp;ls_name = trim(elem.textstring) <br/>&nbsp;&nbsp;&nbsp;if len(ls_name)&lt;50 then</p><p>&nbsp;&nbsp;&nbsp;dw_1.insertrow(1)<br/>//&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;dw_1.setitem(1, "name", ls_name)<br/>&nbsp;&nbsp;dw_1.setitem(1, "x1",min)<br/>dw_1.setitem(1, "y1", min)<br/>&nbsp;&nbsp;dw_1.setitem(1, "x2", max)<br/>&nbsp;&nbsp;dw_1.setitem(1, "y2", max)<br/>&nbsp;&nbsp;m=m+1 <br/>&nbsp;&nbsp;end if<br/>&nbsp;&nbsp;end if </p><p><br/>next </p>
页: [1]
查看完整版本: [求助]pb开发AUTOCAD中GETBOUNDINGBOX问题