CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2020 开发者帮助

BadObjectName 属性 (ActiveX/CSP)

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

BadObjectName 属性 (ActiveX/CSP)

指定其属性与要比较的图形标准文件中定义的属性不匹配的对象的名称。

支持的平台:仅限 Windows

命名空间:AcStMgr (英语)

集会:AcStMgr.tlb

签名

VB.NET:

object.BadObjectName

C#:

object.BadObjectName;
对象

类型:AcStError 对象

此属性应用于的对象。

属性值

只读:

类型:字符串

与错误关联的对象的名称。

言论

没有其他评论。

发行信息

释放:AutoCAD 2004 及更高版本

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

例子

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;
                }
            }
        }
    }
}

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-16 00:01

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部