sujianyong 发表于 2007-1-31 15:42:00

AutoCAD的二次开发中表格操作的问题

<p>请教如何在VisualStuio2005+托管(acmgd.dll和acdbmgd.dll)的编程中在AutoCAD中加入表格"Table".</p><p>程序在编译中没有问题,但是运行时总是不能成功!</p>

lkq67 发表于 2007-12-31 17:41:00

&lt;CommandMethod("creattable")&gt; _<br/>    Public Sub ceattable()<br/>        Try<br/>            Dim prpointres As PromptPointResult = ed.GetPoint("选择插入点")<br/><br/>            Dim blkTbl As BlockTable = CType(trans.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)<br/>            Dim blkTblRec As BlockTableRecord = CType(trans.GetObject(blkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)<br/>            'Dim stId As ObjectId = AcadTableUtilities.makeTableStyle<br/>            Dim ptable As New Table<br/>            With ptable<br/>                .Position = prpointres.Value<br/>                .NumColumns = 5 '5列<br/>                .NumRows = 33 '33行<br/><br/>                '初始化表格ptable<br/>                .IsHeaderSuppressed = True '去掉页眉<br/>                .IsTitleSuppressed = True '去掉标题行<br/>                .SetColumnWidth(0, 900)<br/>                .SetColumnWidth(1, 6400)<br/>                .SetColumnWidth(2, 4400)<br/>                .SetColumnWidth(3, 4400)<br/>                .SetColumnWidth(4, 1900)<br/>                .SetRowHeight(700) '行高700<br/>                For j = 0 To 32<br/>                    .SetTextHeight(j, 0, 300)<br/>                    .SetAlignment(j, 0, CellAlignment.MiddleCenter)<br/>                    .SetTextHeight(j, 1, 400)<br/>                    .SetAlignment(j, 1, CellAlignment.MiddleLeft)<br/>                    .SetTextHeight(j, 2, 300)<br/>                    .SetAlignment(j, 2, CellAlignment.MiddleCenter)<br/>                    .SetTextHeight(j, 3, 400)<br/>                    .SetAlignment(j, 3, CellAlignment.MiddleCenter)<br/>                    .SetTextHeight(j, 4, 300)<br/>                    .SetAlignment(j, 4, CellAlignment.MiddleCenter)<br/>                Next<br/>            End With<br/><br/>            blkTblRec.AppendEntity(ptable)<br/>            trans.AddNewlyCreatedDBObject(ptable, True)<br/><br/>            ptable.RecomputeTableBlock(True)<br/>            'ed.Regen()<br/>            ptable.Dispose()<br/>            blkTbl.Dispose()<br/>            blkTblRec.Dispose()<br/>        Catch ex As System.Exception<br/>            MsgBox(ex.StackTrace)<br/>        End Try<br/>        trans.Commit()<br/>        trans.Dispose()<br/>    End Sub

wangfen_feng 发表于 2008-7-31 15:38:00

学习!!!致敬!!!!
页: [1]
查看完整版本: AutoCAD的二次开发中表格操作的问题