打印本文 打印本文 关闭窗口 关闭窗口
Autodesk官方最新的.NET教程(四)(vb.net版)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3209  更新时间:2009/4/23 19:00:01  文章录入:mintao  责任编辑:mintao
bsp;        ''''现在,让我们从公司字典中获取老板的名字

                    ''''在NOD中找到.

                    Dim NOD As DBDictionary = trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead, False)

                    Dim acmeDict As DBDictionary = trans.GetObject(NOD.GetAt("ACME_DIVISION"), OpenMode.ForRead)

                    ''''注意我们直接使用扩展数据...

                    Dim salesDict As DBDictionary = trans.GetObject(acmeDict.GetAt(EmployeeXRec.Data.AsArray(2).Value), OpenMode.ForRead)

                    Dim salesXRec As Xrecord = trans.GetObject(salesDict.GetAt("Department Manager"), OpenMode.ForRead)

                    ''''最后,把雇员的数据输出到命令行

                    resBuf = salesXRec.Data.AsArray(0)

                    saEmployeeList.SetValue(String.Format("{0}" + ControlChars.Lf, resBuf.Value), nEmployeeDataCount)

                    nEmployeeDataCount += 1

                End If

            End If

            trans.Commit()

        Finally

            trans.Dispose()

        End Try

    End Sub

 

 

    <CommandMethod("PRINTOUTEMPLOYEE")> _

    Public Shared Function PrintoutEmployee()

        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor

 

        Dim nEmployeeCount As Integer = 0

 

        Dim nEmployeeDataCount As Integer

        ''''声明我们将在下面使用的工具...

        Dim db = HostApplicationServices.WorkingDatabase

        Dim trans As Transaction = db.TransactionManager.StartTransaction() ''''Start the transaction.

        Try

            ''''首先,获取块表和模型空间块表记录

            Dim bt As BlockTable = trans.GetObject(HostApplicationServices.WorkingDatabase.BlockTableId, OpenMode.ForRead)

            Dim btr As BlockTableRecord = trans.GetObject(bt(btr.ModelSpace), OpenMode.ForRead)

            ''''现在,我们需要把内容输出到命令行。这里可以有一个对象帮助我们:

            ''''下面的部分,我们将遍历模型空间:

            Dim id As ObjectId '''' – 首先,定义一个ObjectId对象,用于For循环。

            For Each id In btr

                Dim ent As Entity = trans.GetObject(id, OpenMode.ForRead, False) ''''打开当前对象!

                If TypeOf ent Is BlockReference Then

                    Dim saEmployeeList(-1) As String ''''这是正确的...它被重新定义。

                    ListEmployee(id, saEmployeeList)

                    Dim sEmployeeData As String

 

                    If (saEmployeeList.Length = 4) Then

                        ed.WriteMessage("Employee Name: {0}", saEmployeeList(0))

                        ed.WriteMessage("Employee Salary: {0}", saEmployeeList(1))

                        ed.WriteMessage("Employee Division: {0}", saEmployeeList(2))

                        ed.WriteMessage("Division Manager: {0}", saEmployeeList(3))

                    End If

                End If

            Next

        Finally

        End Try

    End Function

 

 

上一页  [1] [2] [3] [4] 

打印本文 打印本文 关闭窗口 关闭窗口