几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【转帖】各位高手:添加一多义线并设置线型错在什么地方 (http://www.dimcax.com/hust/showthread.php?t=9394)

yang686526 2009-04-20 08:51 PM

【转帖】各位高手:添加一多义线并设置线型错在什么地方
 
各位高手:添加一多义线并设置线型错在什么地方
www.dimcax.com
各位高手:添加一多义线并设置线型错在什么地方
'绘多义线
<commandmethod("addpl")> _
public sub addpl()
dim pl as new polyline
dim db as database
dim trans as transaction
dim btr as blocktablerecord
dim bt as blocktable
'dim li as object
db = hostapplicationservices.workingdatabase
trans = db.transactionmanager.starttransaction
bt = trans.getobject(db.blocktableid, openmode.forwrite)
btr = trans.getobject(bt(blocktablerecord.modelspace), openmode.forwrite)
'dim plinetypetbl as linetypetable = trans.getobject(db.linetypetableid, openmode.forread)
'if plinetypetbl.has("dashdot") then
'db.loadlinetypefile("dashdot", "acadiso.lin")
'end if
dim point2d(2) as point2d
point2d(0) = new point2d(10, 10)
point2d(1) = new point2d(10, 5)
point2d(2) = new point2d(30, 40)
pl.addvertexat(0, point2d(0), 0, 1, 1)
pl.addvertexat(1, point2d(1), 0, 1, 1)
pl.addvertexat(2, point2d(2), 0, 1, 1)
pl.linetypeid = creatlinetype("dashdot")
' pl.linetype = "dashdot"
btr.appendentity(pl)
trans.addnewlycreateddbobject(pl, true)
trans.commit()
trans.dispose()
end sub
private function creatlinetype(byval linetypename as string) as objectid
dim linetypeid as objectid
dim db as database = hostapplicationservices.workingdatabase
using trans as transaction = db.transactionmanager.starttransaction
dim it as linetypetable = trans.getobject(db.linetypetableid, openmode.forread)
if it.has(linetypename) then
linetypeid = it.item(linetypename)
else
db.loadlinetypefile(linetypename, "acadiso.lin")
dim ltr as new linetypetablerecord
ltr.name = linetypename
it.upgradeopen()
linetypeid = it.add(ltr)
trans.addnewlycreateddbobject(ltr, true)

end if
trans.commit()
end using
return linetypeid
end function
dim it as linetypetable = trans.getobject(db.linetypetableid, openmode.forread)
openmode.forread 改为openmode.forwrite
没有测试过,只是看见这个地方有问题


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