明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3491|回复: 2

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

[复制链接]
发表于 2007-1-31 15:42:00 | 显示全部楼层 |阅读模式

请教如何在VisualStuio2005+托管(acmgd.dll和acdbmgd.dll)的编程中在AutoCAD中加入表格"Table".

程序在编译中没有问题,但是运行时总是不能成功!

发表于 2007-12-31 17:41:00 | 显示全部楼层
<CommandMethod("creattable")> _
    Public Sub ceattable()
        Try
            Dim prpointres As PromptPointResult = ed.GetPoint("选择插入点")

            Dim blkTbl As BlockTable = CType(trans.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
            Dim blkTblRec As BlockTableRecord = CType(trans.GetObject(blkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
            'Dim stId As ObjectId = AcadTableUtilities.makeTableStyle
            Dim ptable As New Table
            With ptable
                .Position = prpointres.Value
                .NumColumns = 5 '5列
                .NumRows = 33 '33行

                '初始化表格ptable
                .IsHeaderSuppressed = True '去掉页眉
                .IsTitleSuppressed = True '去掉标题行
                .SetColumnWidth(0, 900)
                .SetColumnWidth(1, 6400)
                .SetColumnWidth(2, 4400)
                .SetColumnWidth(3, 4400)
                .SetColumnWidth(4, 1900)
                .SetRowHeight(700) '行高700
                For j = 0 To 32
                    .SetTextHeight(j, 0, 300)
                    .SetAlignment(j, 0, CellAlignment.MiddleCenter)
                    .SetTextHeight(j, 1, 400)
                    .SetAlignment(j, 1, CellAlignment.MiddleLeft)
                    .SetTextHeight(j, 2, 300)
                    .SetAlignment(j, 2, CellAlignment.MiddleCenter)
                    .SetTextHeight(j, 3, 400)
                    .SetAlignment(j, 3, CellAlignment.MiddleCenter)
                    .SetTextHeight(j, 4, 300)
                    .SetAlignment(j, 4, CellAlignment.MiddleCenter)
                Next
            End With

            blkTblRec.AppendEntity(ptable)
            trans.AddNewlyCreatedDBObject(ptable, True)

            ptable.RecomputeTableBlock(True)
            'ed.Regen()
            ptable.Dispose()
            blkTbl.Dispose()
            blkTblRec.Dispose()
        Catch ex As System.Exception
            MsgBox(ex.StackTrace)
        End Try
        trans.Commit()
        trans.Dispose()
    End Sub
发表于 2008-7-31 15:38:00 | 显示全部楼层
学习!!!致敬!!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 05:46 , Processed in 0.161275 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表