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