利用 GH C# 脚本 DrawViewportWires 绘制图形不显示

我正在跟随 https://developer.rhino3d.com/guides/scripting/scripting-gh-csharp/ 教程学习如何编写 GH C# 脚本,但没有顺利地将矩形绘制出来,请教问题出在哪里?

// Grasshopper Script Instance
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;

using Rhino;
using Rhino.Geometry;

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;

public class Script_Instance : GH_ScriptInstance
{ 
  private void RunScript(object x, object y, out object a)
  {
    // Write your logic here
    a = null;
  }

  public override BoundingBox ClippingBox => new BoundingBox(new Point3d(0, 0, 0), new Point3d(500, 500, 500));

  public override void DrawViewportMeshes(IGH_PreviewArgs args)
  {
  }

  public override void DrawViewportWires(IGH_PreviewArgs args)
  {
    args.Display.Draw2dRectangle(
        new System.Drawing.Rectangle(100,100,150,150)
        System.Drawing.Color.Red,
        20,
        System.Drawing.Color.Yellow
    );
  }
}

我的操作步骤:1)新建 Document, 2) 拖入 script 电池,3)编辑脚本,4)运行脚本

错误挺明显的,你在使用脚本编辑器的时候应该注意查看下方的信息:

1.使用了中文的‘,’,应该改为英文的 ‘,’;
2.这句后面要添加 ‘,’。

修改这一句后即可正常运行程序:

// Grasshopper Script Instance
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;

using Rhino;
using Rhino.Geometry;

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;

public class Script_Instance : GH_ScriptInstance
{ 
  private void RunScript(object x, object y, ref object a)
  {
    // Write your logic here
    a = null;
  }

  public override BoundingBox ClippingBox => new BoundingBox(new Point3d(0, 0, 0), new Point3d(500, 500, 500));

  public override void DrawViewportMeshes(IGH_PreviewArgs args)
  {
  }

  public override void DrawViewportWires(IGH_PreviewArgs args)
  {
    args.Display.Draw2dRectangle(
        new System.Drawing.Rectangle(100, 100, 150, 150), //修改了这一行
        System.Drawing.Color.Red,
        20,
        System.Drawing.Color.Yellow
    );
  }
}

感谢指出,new System.Drawing.Rectangle(100,100,150,150) 这句后面还少了个 ,。改正后确实可以显示了,感谢!