CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2019 开发者帮助

PropertyValueGet 方法 (ActiveX/CSP)

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

PropertyValueGet 方法 (ActiveX/CSP)

获取指定属性的值。

支持的平台:仅限 Windows

命名空间:AcStMgr (英语)

集会:AcStMgr.tlb

Signature - AcStError 对象

VB.NET:

RetVal = object.PropertyValueGet(szName)

C#:

RetVal = object.PropertyValueGet(szName);
对象

类型:AcStError 对象

此方法应用到的对象。

szName (中文名)

访问:仅输入

类型:字符串

属性列表中要获取其值的属性的名称。

签名 - AcStFix 对象

VB.NET:

object.PropertyValueGet(szName, value)

C#:

object.PropertyValueGet(szName, ref value);
对象

类型:AcStFix 对象

此方法应用到的对象。

szName (中文名)

访问:仅输入

类型:字符串

属性列表中要获取其值的属性的名称。

价值

访问:仅输出

类型:变体

属性列表中属性的值。

返回值 (RetVal)

类型:变体

属性列表中属性的值。

言论

没有其他评论。

发行信息

释放:AutoCAD 2004 及更高版本

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

示例 - AcStError 对象

VB.NET:

Not available

C#:

Not available

示例 - AcStFix 对象

VB.NET:

Public Sub GetPropertyDiffs(ByVal pError As AcStError, _
                            ByVal pFix As AcStFix, _
                            ByRef pPropNames As Object, _
                            ByRef pErrorValues As Object, _
                            ByRef pFixValues As Object, _
                            ByRef pFixableStatuses As Object) _
                            Implements IAcStPlugin2.GetPropertyDiffs

    If IsNothing(pError) = False And IsNothing(pFix) = False Then

        ' Define the arrays that will hold the property values to compare
        Dim sPropNames(0) As String
        Dim sErrorValues(0) As String
        Dim sFixValues(0) As String
        Dim bFixableStatuses(0) As Boolean

        Dim sPropName As String = ""
        Dim vErrorVal As Object = Nothing
        Dim vFixVal As Object = Nothing
        Dim i As Integer, nPropCnt As Integer = 0

        ' Iterate the properties of the error object
        For i = 0 To pError.PropertyCount - 1
            ' Get a property name and value from the error
            pError.PropertyGetAt(i, sPropName, vErrorVal)
            m_sPropName = sPropName

            Try
                ' Retrieve the corresponding property value for the fix object
                pFix.PropertyValueGet(sPropName, vFixVal)

                ' Compare the value of the error and fix objects
                If (vErrorVal.CompareTo(vFixVal) <> 0) Then
                    ' Resize the arrays and add the new values
                    ReDim Preserve sPropNames(nPropCnt + 1)
                    ReDim Preserve sErrorValues(nPropCnt + 1)
                    ReDim Preserve sFixValues(nPropCnt + 1)
                    ReDim Preserve bFixableStatuses(nPropCnt + 1)

                    ' Store the property names and values in arrays
                    sPropNames(nPropCnt) = sPropName
                    sErrorValues(nPropCnt) = vErrorVal.ToString
                    sFixValues(nPropCnt) = vFixVal.ToString
                    bFixableStatuses(nPropCnt) = True

                    ' Increment the property counter
                    nPropCnt = nPropCnt + 1
                End If
            Catch
                ' Catch and handle the error as needed
            End Try
        Next

        ' Return the arrays
        pPropNames = sPropNames
        pErrorValues = sErrorValues
        pFixValues = sFixValues
        pFixableStatuses = bFixableStatuses

        ' Clear the local arrays
        Erase sPropNames
        Erase sErrorValues
        Erase sFixValues
        Erase bFixableStatuses

        ' Increment the number of fixes
        m_FixCnt = m_FixCnt + 1
    End If
End Sub

C#:

public void GetPropertyDiffs(AcStError pError, AcStFix pFix, ref object pPropNames, 
                             ref object pErrorValues, ref object pFixValues, ref object pFixableStatuses)
{
    if ((pError == null) == false & (pFix == null) == false)
    {
        // Define the arrays that will hold the property values to compare
        string[] sPropNames = new string[0];
        string[] sErrorValues = new string[0];
        string[] sFixValues = new string[0];
        bool[] bFixableStatuses = new bool[0];

        string sPropName = "";
        object vErrorVal = null;
        object vFixVal = null;
        int nPropCnt = 0;

        // Iterate the properties of the error object
        for (int i = 0; i <= pError.PropertyCount - 1; i++)
        {
            // Get a property name and value from the error
            pError.PropertyGetAt(i, ref sPropName, ref vErrorVal);
            m_sPropName = sPropName;

            try
            {
                // Retrieve the corresponding property value for the fix object
                pFix.PropertyValueGet(sPropName, ref vFixVal);

                // Compare the value of the error and fix objects
                if ((vErrorVal.Equals(vFixVal) == false))
                {
                    // Resize the arrays and add the new values
                    Array.Resize<string>(ref sPropNames, nPropCnt + 1);
                    Array.Resize<string>(ref sErrorValues, nPropCnt + 1);
                    Array.Resize<string>(ref sFixValues, nPropCnt + 1);
                    Array.Resize<bool>(ref bFixableStatuses, nPropCnt + 1);

                    // Store the property names and values in arrays
                    sPropNames[nPropCnt] = sPropName;
                    sErrorValues[nPropCnt] = vErrorVal.ToString();
                    sFixValues[nPropCnt] = vFixVal.ToString();
                    bFixableStatuses[nPropCnt] = true;

                    // Increment the property counter
                    nPropCnt = nPropCnt + 1;
                }
            }
            catch
            {
                // Catch and handle the error as needed
            }
        }

        // Return the arrays
        pPropNames = sPropNames;
        pErrorValues = sErrorValues;
        pFixValues = sFixValues;
        pFixableStatuses = bFixableStatuses;

        // Clear the local arrays
        sPropNames = null;
        sErrorValues = null;
        sFixValues = null;
        bFixableStatuses = null;

        // Increment the number of fixes
        m_FixCnt = m_FixCnt + 1;
    }
}

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 11:26

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部