CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2020 开发者帮助

Next 方法 (ActiveX/CSP)

2024-5-18 18:23| 发布者: admin| 查看: 82| 评论: 0|原作者: admin|来自: AutoCAD

Next 方法 (ActiveX/CSP)

获取当前上下文中的下一个错误。

支持的平台:仅限 Windows

命名空间:AcStMgr (英语)

集会:AcStMgr.tlb

签名 - AcStErrorIterator 对象

仅供内部使用。

VB.NET:

object.Next()

C#:

object.Next();
对象

类型:AcStErrorIterator 对象

此方法应用到的对象。

签名 - IAcStPlugin2 接口

VB.NET:

Public Sub Next() _
              Implements AcStMgr.IAcStPlugin2.Next
    ...
End Sub

C#:

public void Next()
{
    ...;
}
对象

类型:IAcStPlugin2 接口

此方法适用的接口。

返回值 (RetVal)

无返回值。

言论

没有其他评论。

发行信息

释放:AutoCAD 2004 及更高版本

  • AcStMgr.tlb - AutoCAD 2004 及更高版本

示例 - AcStErrorIterator 对象

VB.NET:

Not available

C#:

Not available

示例 - IAcStPlugin2 接口

VB.NET:

Public Sub PlugIn_Next() _
           Implements IAcStPlugin2.Next
    m_pError = Nothing

    If m_ContextList.Count > 0 Then

        ' Check to see if there are objects to check
        ' << Change based on standards implementation >>
        If m_LayerCacheArray.Length() > 0 Then

            Dim bFoundError As Boolean

            ' Check to see if this is the last object to be checked
            If m_curIndex < m_ContextList.Count - 1 Then
                m_curIndex = m_curIndex + 1
                bFoundError = False

                ' << Change based on standards implementation >>
                Dim layerObj As AcadLayer
                Dim iCache As Integer

                ' Iterate the objects to be checked
                While m_curIndex < m_ContextList.Count

                    ' Get the ObjectId of the object to be checked
                    layerObj = m_pCheckDatabase.ObjectIdToObject(m_ContextList.Item(m_curIndex))

                    ' Iterate through each of the standards objects and check for a match based on name
                    For iCache = LBound(m_LayerCacheArray) To UBound(m_LayerCacheArray)
                        ' Compare the names of the two layers
                        If (layerObj.Name.CompareTo(m_LayerCacheArray(iCache).Name) <> 0) Then

                            ' Check to see if the object is a macth,
                            ' if not flag as possible error
                            bFoundError = True
                        Else
                            bFoundError = False
 
                            ' Layer names matched, compare color and linetype values
                            If layerObj.color.ToString() <> m_LayerCacheArray(iCache).Color.ToString() Or _
                                layerObj.Lineweight.ToString() <> m_LayerCacheArray(iCache).Lineweight.ToString() Then

                                bFoundError = True
                            End If

                            ' Exit For loop since a match by name was found
                            Exit For
                        End If
                    Next

                    ' No match or a property difference was found
                    If bFoundError = True Then
                        Dim pError As New AcStError()

                        ' Assign a description to the error
                        pError.Description = "Layer is non-standard"

                        ' Assign an ObjectId to the error
                        pError.BadObjectId = layerObj.ObjectID

                        ' Assign the name of the object, plug-in, and error type
                        pError.BadObjectName = layerObj.Name
                        pError.Plugin = m_pPlugin
                        pError.ErrorTypeName = "Layer "

                        ' Assign a result status to the error
                        pError.ResultStatus = AcStResultStatus.acStResFlagsNone

                        ' Assign the object's property values to the error for checking
                        If pError.PropertyCount = 0 Then
                            pError.PropertyValuePut("Color", layerObj.color)
                            pError.PropertyValuePut("Lineweight", layerObj.Lineweight)
                        End If

                        m_pError = pError
                        bFoundError = False

                        Exit While
                    End If

                    ' Increment the counter
                    m_curIndex = m_curIndex + 1
                End While
            End If
        End If
    End If
End Sub

C#:

public void PlugIn_Next()
{
    m_pError = null;

    if (m_ContextList.Count > 0)
    {
        AcadLayer layerObj = default(AcadLayer);
        int iCache = 0;
        bool bFoundError = false;

        // Check to see if there are objects to check
        // << Change based on standards implementation >>
        if (m_LayerCacheArray.Length > 0)
        {
            // Check to see if this is the last object to be checked
            if (m_curIndex < m_ContextList.Count - 1)
            {
                m_curIndex = m_curIndex + 1;
                bFoundError = false;

                // Iterate the objects to be checked
                while (m_curIndex < m_ContextList.Count)
                {
                    // Get the ObjectId of the object to be checked
                    layerObj = (AXDBLib.AcadLayer)m_pCheckDatabase.ObjectIdToObject((long)m_ContextList.GetItem(m_curIndex));

                    int nLBound = m_LayerCacheArray.GetLowerBound(0);
                    int nUBound = m_LayerCacheArray.GetUpperBound(0);

                    // Iterate through each of the standards objects and check for a match based on name
                    for (iCache = nLBound; iCache <= nUBound; iCache++)
                    {
                        // Compare the names of the two layers
                        if ((layerObj.Name.CompareTo(m_LayerCacheArray[iCache].Name) != 0))
                        {
                            // Check to see if the object is a macth,
                            // if not flag as possible error
                            bFoundError = true;
                        }
                        else
                        {
                            bFoundError = false;

                            // Layer names matched, compare color and linetype values
                            if (layerObj.color.ToString() != m_LayerCacheArray[iCache].Color.ToString() |
                                layerObj.Lineweight.ToString() != m_LayerCacheArray[iCache].Lineweight.ToString())
                            {
                                bFoundError = true;
                            }

                            // Exit For loop since a match by name was found
                            break;
                        }
                    }

                    // No match or a property difference was found
                    if (bFoundError == true)
                    {
                        AcStError pError = new AcStError();

                        // Assign a description to the error
                        pError.Description = "Layer is non-standard";

                        // Assign an ObjectId to the error
                        pError.BadObjectId = layerObj.ObjectID;

                        // Assign the name of the object, plug-in, and error type
                        pError.BadObjectName = layerObj.Name;
                        pError.Plugin = m_pPlugin;
                        pError.ErrorTypeName = "Layer ";

                        // Assign a result status to the error
                        pError.ResultStatus = AcStResultStatus.acStResFlagsNone;

                        // Assign the object's property values to the error for checking
                        if (pError.PropertyCount == 0)
                        {
                            pError.PropertyValuePut("Color", (ACAD_COLOR)layerObj.color);
                            pError.PropertyValuePut("Lineweight", (ACAD_LWEIGHT)layerObj.Lineweight);
                        }

                        m_pError = pError;
                        bFoundError = false;
                        break;
                    }

                    // Increment the counter
                    m_curIndex = m_curIndex + 1;
                }
            }
        }
    }
}

void IAcStPlugin2.Next()
{
    PlugIn_Next();
}

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 13:05

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部