0

我想知道是否可以,如果可以,如何通过设计自动化实现dwg比较?我有办法创建一个接受 2 dwg 输入的比较活动,并发布一个布尔值作为输出?

4

1 回答 1

0

是的,您可以创建一个接受两张图纸的活动。以下活动 JSON 使用内置比较并输出结果差异图。

示例活动 Json

{
    "HostApplication": "",
    "RequiredEngineVersion": "23.0",
    "Parameters": {
        "InputParameters": [
            {
                "Name": "HostDwg",
                "LocalFileName": "$(HostDwg)"
            },
            {
                "Name": "ToCompareWith",
                "LocalFileName": "ToCompareWith.dwg"
            }
        ],
        "OutputParameters": [
            {
                "Name": "Result",
                "LocalFileName": "output.dwg"
            }
        ]
    },
    "Instruction": {
        "CommandLineParameters": null,
        "Script": "COMPAREINPLACE\nON\n-COMPARE\n\nToCompareWith.dwg\n_SAVEAS\n\noutput.dwg\n"
    },
    "Id": "FPDCompare"
}

工作项 Json

{
    "Arguments": {
        "InputArguments": [
            {
                "Resource": "https://madhukar-fda.s3.us-west-2.amazonaws.com/Kitchens1.dwg",
                "Name": "HostDwg"
            },
            {
                "Resource": "https://madhukar-fda.s3.us-west-2.amazonaws.com/Kitchens2.dwg",
                "Name": "ToCompareWith"
            }
        ],
        "OutputArguments": [
            {
                "Name": "Result",
                "HttpVerb": "POST"
            }
        ]
    },
    "ActivityId": "FPDCompare"
}

如果您使用自己的自定义比较逻辑,则可以将结果输出到 txt 文件或 json 文件。

活动 Json

{
    "HostApplication": "",
    "RequiredEngineVersion": "23.0",
    "Parameters": {
        "InputParameters": [
            {
                "Name": "HostDwg",
                "LocalFileName": "$(HostDwg)"
            },
            {
                "Name": "ToCompareWith",
                "LocalFileName": "ToCompareWith.dwg"
            }
        ],
        "OutputParameters": [
            {
                "Name": "Result",
                "LocalFileName": "output.txt"
            }
        ]
    },
    "Instruction": {
        "CommandLineParameters": null,
        "Script": "ISDWGSIMILAR\nToCompareWith.dwg\n"
    },
    "AppPackages":["Compare"],
    "Version": 1,
    "Id": "Compare"
}

工作项 Json

{
    "Arguments": {
        "InputArguments": [
            {
                "Resource":"https://madhukar-fda.s3.us-west-2.amazonaws.com/Kitchens.dwg",
                "Name": "HostDwg"
            },
            {
                "Resource":"https://madhukar-fda.s3.us-west-2.amazonaws.com/Kitchens1.dwg",
                "Name": "ToCompareWith"
            }
        ],
        "OutputArguments": [
            {
                "Name": "Result",
                "HttpVerb": "POST"
            }
        ]
    },
    "ActivityId": "Compare"
}

注意:在脚本参数中 - “ISDWGSIMILAR”是一个自定义命令,您将在其中处理两个图形,第一个是当前图形,第二个是您愿意比较的图形 [ToCompareWith]

自定义 NET 命令

    [CommandMethod("FDACOMMANDS", "ISDWGSIMILAR", CommandFlags.Transparent)]
    public static void CompareDrawing()
    {
        var doc = Application.DocumentManager.MdiActiveDocument;
        var db = doc.Database;
        var ed = doc.Editor;
        var promptResult = ed.GetString("Select Drawing To Compare With");
        if (promptResult.Status != PromptStatus.OK) return;
        var drawingToCompareWith = promptResult.StringResult;
        ed = Application.DocumentManager.MdiActiveDocument.Editor;
        using (OpenCloseTransaction o = new OpenCloseTransaction())
        {
           /*

           {

           Here your logic code to compare two drawings

           }

           */

            /*output.txt / json is pushed to your cloud storage as provided in workitem json*/
            using (var writer = File.CreateText("output.txt"))
            {
                if (b != null) /*b value is result of your compare*/
                {
                    writer.WriteLine("TRUE Drawings are same");
                }
                else writer.WriteLine("FALSE Drawings aren't same");
            }
        }
    }
于 2018-08-15T05:07:02.317 回答