CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

FixError Method (ActiveX/CSP)

2023-1-2 21:10| 发布者: admin| 查看: 151| 评论: 0|来自: AutoCAD

摘要: 将修复对象的属性值应用于错误对象的相同属性。

将修复对象的属性值应用于错误对象的相同属性。

支持的平台:仅窗口

Namespace:AcStMgr

集会:AcStMgr.tlb

签名

VB.NET:

Public Sub FixError(pError, pFix[, pFailedReason]) _
                    Implements IAcStPlugin2.FixError
    ...
End Sub

C#:

public void FixError(pError, pFix[, out pFailedReason])
{
    ...;
}
对象

类型:AcStError迭代器对象

此方法适用的对象。

p错误

访问:仅输入

类型:AcStError对象

与已建立的 CAD 标准不匹配的错误对象。

pFix

访问:仅输入

类型:AcStFix对象

将用于更正错误对象的属性的修复对象。

p失败原因

访问:仅输出

类型:字符串

表示修复失败原因的错误值。返回的值应与枚举中的值之一对齐。 AcStResultStatus

默认返回值为“0”。

返回值(RetVal)

无返回值。

言论

没有额外的评论。

发布信息

释放:AutoCAD 2004 及更高版本

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

例子

VB.NET:

Public Sub FixError(ByVal pError As AcStError, _
                    ByVal pFix As AcStFix, _
                    Optional ByRef pFailedReason As String = "0") _
                    Implements IAcStPlugin2.FixError

    ' << Change based on standards implementation >>
    If IsNothing(pError) = False Then

        Dim sFixClrVal As ACAD_COLOR
        Dim sFixLWVal As ACAD_COLOR

        ' Get the drawing object to fix
        Dim badObjID As Long = pError.BadObjectId
        Dim badObj As AcadLayer = m_pCheckDatabase.ObjectIdToObject(badObjID)

        ' If no fix is provided, try the recommended fix
        If IsNothing(pFix) Then
            Dim tmpFix As New AcStFix()
            tmpFix = GetRecommendedFix(pError)

            If IsNothing(tmpFix) Then
                ' Set the result status of the error to Failed and No Recommended Fix
                pError.ResultStatus = AcStResultStatus.acStResFixFailed + AcStResultStatus.acStResNoRecommendedFix
            Else
                ' Fix the bad object
                pFix = tmpFix
                tmpFix = Nothing

                ' Fix the color of the layer
                pFix.PropertyValueGet("Color", sFixClrVal)
                Try
                    badObj.color = sFixClrVal
                    pError.ResultStatus = AcStResultStatus.acStResFixed
                Catch m_ex As Exception
                    pError.ResultStatus = AcStResultStatus.acStResFixFailed
                End Try

                ' Fix the Lineweight of the layer
                pFix.PropertyValueGet("Lineweight", sFixLWVal)
                Try
                    badObj.Lineweight = sFixLWVal
                    pError.ResultStatus = AcStResultStatus.acStResFixed
                Catch m_ex As Exception
                    pError.ResultStatus = AcStResultStatus.acStResFixFailed
                End Try
            End If

            tmpFix = Nothing
        Else
            ' Fix the color of the layer
            pFix.PropertyValueGet("Color", sFixClrVal)
            Try
                badObj.color = sFixClrVal
                pError.ResultStatus = AcStResultStatus.acStResFixed
            Catch m_ex As Exception
                pError.ResultStatus = AcStResultStatus.acStResFixFailed
            End Try

            ' Fix the Lineweight of the layer
            pFix.PropertyValueGet("Lineweight", sFixLWVal)
            Try
                badObj.Lineweight = sFixLWVal
                pError.ResultStatus = AcStResultStatus.acStResFixed
            Catch m_ex As Exception
                pError.ResultStatus = AcStResultStatus.acStResFixFailed
            End Try
        End If
    End If
End Sub

C#:

public void FixError(AcStError pError, AcStFix pFix, out string pFailedReason)
{
    // << Change based on standards implementation >>
    if ((pError == null) == false)
    {
        object sFixClrVal = default(ACAD_COLOR);
        object sFixLWVal = default(ACAD_LWEIGHT);

        // Get the drawing object to fix
        long badObjID = pError.BadObjectId;
        AcadLayer badObj = (AcadLayer)m_pCheckDatabase.ObjectIdToObject(badObjID);

        // If no fix is provided, try the recommended fix
        if (pFix == null)
        {
            AcStFix tmpFix = new AcStFix();
            tmpFix = GetRecommendedFix(pError);

            if (tmpFix == null)
            {
                // Set the result status of the error to Failed and No Recommended Fix
                pError.ResultStatus = AcStResultStatus.acStResFixFailed | AcStResultStatus.acStResNoRecommendedFix;
            }
            else
            {
                // Fix the bad object
                pFix = tmpFix;
                tmpFix = null;

                // Fix the color of the layer
                pFix.PropertyValueGet("Color", ref sFixClrVal);
                try
                {
                    badObj.color = (AcColor)sFixClrVal;
                    pError.ResultStatus = AcStResultStatus.acStResFixed;
                }
                catch (Exception m_ex)
                {
                    pError.ResultStatus = AcStResultStatus.acStResFixFailed;
                }

                // Fix the Lineweight of the layer
                pFix.PropertyValueGet("Lineweight", ref sFixLWVal);
                try
                {
                    badObj.Lineweight = (ACAD_LWEIGHT)sFixLWVal;
                    pError.ResultStatus = AcStResultStatus.acStResFixed;
                }
                catch (Exception m_ex)
                {
                    pError.ResultStatus = AcStResultStatus.acStResFixFailed;
                }
            }
        }
        else
        {
            // Fix the color of the layer
            pFix.PropertyValueGet("Color", ref sFixClrVal);
            try
            {
                badObj.color = (AcColor)sFixClrVal;
                pError.ResultStatus = AcStResultStatus.acStResFixed;
            }
            catch (Exception m_ex)
            {
                pError.ResultStatus = AcStResultStatus.acStResFixFailed;
            }

            // Fix the Lineweight of the layer
            pFix.PropertyValueGet("Lineweight", ref sFixLWVal);
            try
            {
                badObj.Lineweight = (ACAD_LWEIGHT)sFixLWVal;
                pError.ResultStatus = AcStResultStatus.acStResFixed;
            }
            catch (Exception m_ex)
            {
                pError.ResultStatus = AcStResultStatus.acStResFixFailed;
            }
        }
    }

    pFailedReason = "0";
}

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-11 22:00

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部