几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   ObjectARX(VB.NET/C#) (http://www.dimcax.com/hust/forumdisplay.php?f=176)
-   -   【转帖】hatch的面积? (http://www.dimcax.com/hust/showthread.php?t=8914)

yang686526 2009-04-20 11:21 AM

【转帖】hatch的面积?
 
hatch的面积?
www.dimcax.com
hatch的面积?
这个问题,一个办法就是用vba的hatch对象的area属性了,cad
等我来改写了
这个不行的,
admin 发表于
快点改吧,我等着!
我在试那个所谓的com,没学过搞不明白,怎么才能把.net的hatch对象变成autodesk.autocad.interop.common.acadhatch呢?ctype不行,给指点一下好不?
嘿嘿,原来是这样:
imports autodesk.autocad.interop.common
imports autodesk.autocad.interop
public class study01
private db as database = hostapplicationservices.workingdatabase
private ed as editor = autodesk.autocad.applicationservices.application.documentmanager.mdiactivedocument.editor
private tm as autodesk.autocad.databaseservices.transactionmanager = db.transactionmanager
<commandmethod("test", commandflags.modal)> _
public sub test_com()
dim myt as transaction = tm.starttransaction
try
dim resent as promptentityresult = ed.getentity(vbcrlf & "选择填充")
if resent.status = promptstatus.ok then
dim ohatch as hatch = ctype(tm.getobject(resent.objectid, databaseservices.openmode.forread), hatch)
dim oacadhatch as acadhatch
oacadhatch = ctype(ohatch.acadobject, acadhatch)
ed.writemessage(oacadhatch.area.tostring)
end if
catch ex as system.exception
ed.writemessage(ex.message)
finally
myt.dispose()
end try
end sub
end class
复制代码
下面的代码证明,.net里的hatch.geometricextents得到的填充对象的外框是不正确的,它会把坐标原点放进去,而com的acadhatch.getboundingbox却不会。看来autocad的这个.net包装还很需要改进。
<commandmethod("test", commandflags.modal)> _
public sub test_hatch_extents()
dim myt as transaction = tm.starttransaction
try
dim resent as promptentityresult = ed.getentity(vbcrlf & "选择填充")
if resent.status = promptstatus.ok then
dim ohatch as hatch = ctype(tm.getobject(resent.objectid, databaseservices.openmode.forread), hatch)
dim oextents as extents3d = ohatch.geometricextents()
ed.writemessage(vbcrlf & oextents.tostring) '
dim oacadhatch as acadhatch = ctype(ohatch.acadobject, acadhatch)
dim omin as object = nothing, omax as object = nothing
oacadhatch.getboundingbox(omin, omax)
dim amin as array = ctype(omin, system.array)
ed.writemessage(vbcrlf & amin.getvalue(0).tostring & "," & amin.getvalue(1).tostring)
end if
catch ex as system.exception
ed.writemessage(ex.message)
finally
myt.dispose()
end try
end sub
复制代码


所有的时间均为北京时间。 现在的时间是 02:52 AM.