[求助]pb开发autocad中getboundingbox问题
www.dimcax.com
[求助]pb开发autocad中getboundingbox问题
请教下有谁用过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