CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

SetupForAudit Method (ActiveX/CSP)

2023-1-2 20:15| 发布者: admin| 查看: 138| 评论: 0|来自: AutoCAD

摘要: 定义插件将在其中运行的上下文,特别是要检查的数据库和将用于检查的图形标准 (DWS) 文件。

定义插件将在其中运行的上下文,特别是要检查的数据库和将用于检查的图形标准 (DWS) 文件。

支持的平台:仅窗口

Namespace:AcStMgr

集会:AcStMgr.tlb

签名

VB.NET:

Public Sub SetupForAudit(pDb, szPathName, stdNameArray, stdPathArray, stdDbArray) _
                               Implements IAcStPlugin2.SetupForAudit
    ...
End Sub

C#:

public void SetupForAudit(pDb, szPathName, stdNameArray, stdPathArray, stdDbArray)
{
    ...;
}
对象

类型:IAcSt插件2接口

此方法适用的接口。

pDb

访问:仅输入

类型:对象AcadDatabase

要检查的图形文件的数据库对象。

sz路径名

访问:仅输入

类型:字符串

包含要检查的数据库的图形文件的路径和文件名。

标准名称数组

访问:仅输入

类型:变体(字符串数组)

检查数据库时要使用的每个标准图形 (DWS) 文件的名称数组。

标准路径阵列

访问:仅输入

类型:变体(字符串数组)

标准图形 (DWS) 文件的路径数组。

标准数据库阵列

访问:仅输入

类型:变体(对象数组)AcadDatabase

检查数据库时要使用的数据库对象的数组。

返回值(RetVal)

无返回值。

言论

要检查的对象由接口的方法指定。在编辑会话期间,它可能会不时变化。SetContextIAcStPlugin2

传递给此方法的对象保证在插件的生存期内有效。插件应将此对象缓存在插件的成员变量中,以允许从其他插件方法访问对象。AcadDatabase

插件不应缓存传递给stdDbArray参数的对象。标准主机应用程序在获取迭代器后可以自由关闭DWS文件,从而使数据库对象失效。需要 DWS 文件中信息的插件应使用此方法缓存来自它们的信息,例如通过将必要的数据复制到内存缓存中。AcadDatabase

Release Information

Releases: AutoCAD 2004 and later

  • AcStMgr.tlb - AutoCAD 2004 and later

Examples

VB.NET:

Public Sub SetupForAudit(ByVal pDb As AcadDatabase, _
                         ByVal szPathName As String, _
                         ByVal stdNameArray As Object, _
                         ByVal stdPathArray As Object, _
                         ByVal stdDbArray As Object) _
                               Implements IAcStPlugin2.SetupForAudit

    ' Used to define the context which the plug-in will operate.

    ' The drawing to be checked and the DWS files being used are passed
    ' to the plug-in at this point. Store the DWS standards definitions
    ' and the objects to be checked. The GetObjectFilter() method is used
    ' to specify the object type that the plug-in should check for errors.

    ' WARNING!: Do not save a reference to the database object,
    ' as it may not be valid going forward.

    If Not IsNothing(pDb) Then
        ' Store a reference to the DWG to be checked
        m_pCheckDatabase = pDb

        ' Verify the reference to the DWG is valid object
        If Not IsNothing(m_pCheckDatabase) Then
            ' << Change based on standards implementation >>
            For Each acObj As AcadObject In m_pCheckDatabase.Layers
                If acObj.ObjectName = "AcDbLayerTableRecord" Then
                    m_ContextList.Add(acObj.ObjectID, True)
                End If
            Next
        End If

        Dim iDWS As Integer

        ' Iterate each of the DWS files and cache the objects to use to fix errors
        For iDWS = 0 To UBound(stdDbArray)
            ' Get the DWS database
            m_pDWSDatabase = stdDbArray(iDWS)

            ' << Change based on standards implementation >>
            Dim pStdLayer As AcadLayer

            ' Iterate the layers in the database
            Dim i As Integer = 0
            For Each pStdLayer In m_pDWSDatabase.Layers
                Dim layerCache As New LayerCache()
                ' Cache the properties of the layers in the DWS database
                layerCache.Name = pStdLayer.Name
                layerCache.Color = pStdLayer.color
                layerCache.Lineweight = pStdLayer.Lineweight

                layerCache.StandardFileName = stdNameArray(iDWS)

                ' Create a fix object to be used later to correct a standards violation
                Dim pFix As New AcStFix()
                pFix.Description = "Layer fix"
                pFix.StandardFileName = layerCache.StandardFileName
                pFix.FixObjectName = pStdLayer.Name

                If pFix.PropertyCount = 0 Then
                    pFix.PropertyValuePut("Color", pStdLayer.color)
                    pFix.PropertyValuePut("Lineweight", pStdLayer.Lineweight)
                End If

                layerCache.StandardsFix = pFix
                ReDim Preserve m_LayerCacheArray(i)
                m_LayerCacheArray(i) = layerCache
                layerCache = Nothing
                pFix = Nothing
                i = i + 1
            Next

            m_pDWSDatabase = Nothing
        Next
    End If
End Sub

C#:

public void SetupForAudit(AcadDatabase pDb, string szPathName, object stdNameArray, 
                          object stdPathArray, object stdDbArray)
{

    // Used to define the context which the plug-in will operate.

    // The drawing to be checked and the DWS files being used are passed
    // to the plug-in at this point. Store the DWS standards definitions
    // and the objects to be checked. The GetObjectFilter() method is used
    // to specify the object type that the plug-in should check for errors.

    // WARNING!: Do not save a reference to the database object,
    // as it may not be valid going forward.
    if (pDb != null)
    {
        // Store a reference to the DWG to be checked
        m_pCheckDatabase = pDb;

        // Verify the reference to the DWG is valid object
        if ((m_pCheckDatabase != null))
        {
            // << Change based on standards implementation >>
            foreach (AcadObject acObj in m_pCheckDatabase.Layers)
            {
                if (acObj.ObjectName == "AcDbLayerTableRecord")
                {
                    m_ContextList.Add(acObj.ObjectID, true);
                }
            }
        }

        int i = 0;
        int iDWS = 0;

        int nLBound = ((Array)stdDbArray).GetLowerBound(0);
        int nUBound = ((Array)stdDbArray).GetUpperBound(0);

        // Iterate each of the DWS files and cache the objects to use to fix errors
        for (iDWS = 0; iDWS <= nUBound; iDWS++)
        {
            // Get the DWS database
            m_pDWSDatabase = (AcadDatabase)((Array)stdDbArray).GetValue(iDWS);

            // << Change based on standards implementation >>
            // Iterate the layers in the database
            foreach (AcadLayer pStdLayer in m_pDWSDatabase.Layers)
            {
                AdskLayersPlugin.StandardsHelpers.LayerCache oLayerCache = new AdskLayersPlugin.StandardsHelpers.LayerCache();

                // Cache the properties of the layers in the DWS database
                oLayerCache.Name = pStdLayer.Name;

                oLayerCache.Color = (ACAD_COLOR)pStdLayer.color;
                oLayerCache.Lineweight = (ACAD_LWEIGHT)pStdLayer.Lineweight;

                oLayerCache.StandardFileName = (String)((Array)stdNameArray).GetValue(iDWS);
                oLayerCache.ObjectId = pStdLayer.ObjectID;

                // Create a fix object to be used later to correct a standards violation
                AcStFix pFix = new AcStFix();

                pFix.Description = "Layer fix";
                pFix.StandardFileName = oLayerCache.StandardFileName;
                pFix.FixObjectName = pStdLayer.Name;
                pFix.FixObjectId = oLayerCache.ObjectId;

                if (pFix.PropertyCount == 0)
                {
                    pFix.PropertyValuePut("Color", (ACAD_COLOR)pStdLayer.color);
                    pFix.PropertyValuePut("Lineweight", (ACAD_LWEIGHT)pStdLayer.Lineweight);
                }

                oLayerCache.StandardsFix = pFix;

                Array.Resize(ref m_LayerCacheArray, i + 1);
                m_LayerCacheArray[i] = oLayerCache;
                oLayerCache = null;
                pFix = null;
                i = i + 1;
            }

            m_pDWSDatabase = null;
        }
    }
}

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-11 14:45

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部