首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Grasshopper返回的‘“期望的标识符”和“方法必须具有返回类型”

Grasshopper返回的‘“期望的标识符”和“方法必须具有返回类型”
EN

Stack Overflow用户
提问于 2018-02-03 11:46:14
回答 1查看 231关注 0票数 1

我对C#相当陌生,或者至少,当我涉足它的时候,已经有一段时间了。在第88行附近,我不断得到标题中所述的错误。我真的不确定,我也不太理解编码,只是理解事物的逻辑。它在第二部分起作用了,我不确定为什么我的返回会给我错误。当我在这个网站上查找其他解决方案时,它主要是一个大写之类的问题,我尝试了一下,但都无济于事……

代码语言:javascript
复制
using Rhino;
using Rhino.Geometry;
using Rhino.DocObjects;
using Rhino.Collections;

using GH_IO;
using GH_IO.Serialization;
using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;

using System;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Linq;
using System.Data;
using System.Drawing;
using System.Reflection;
using System.Collections;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Runtime.InteropServices;



/// <summary>
/// This class will be instantiated on demand by the Script component.
/// </summary>
public class Script_Instance : GH_ScriptInstance
{
#region Utility functions
  /// <summary>Print a String to the [Out] Parameter of the Script component.</summary>
  /// <param name="text">String to print.</param>
  private void Print(string text) { /* Implementation hidden. */ }
  /// <summary>Print a formatted String to the [Out] Parameter of the Script component.</summary>
  /// <param name="format">String format.</param>
  /// <param name="args">Formatting parameters.</param>
  private void Print(string format, params object[] args) { /* Implementation hidden. */ }
  /// <summary>Print useful information about an object instance to the [Out] Parameter of the Script component. </summary>
  /// <param name="obj">Object instance to parse.</param>
  private void Reflect(object obj) { /* Implementation hidden. */ }
  /// <summary>Print the signatures of all the overloads of a specific method to the [Out] Parameter of the Script component. </summary>
  /// <param name="obj">Object instance to parse.</param>
  private void Reflect(object obj, string method_name) { /* Implementation hidden. */ }
#endregion

#region Members
  /// <summary>Gets the current Rhino document.</summary>
  private readonly RhinoDoc RhinoDocument;
  /// <summary>Gets the Grasshopper document that owns this script.</summary>
  private readonly GH_Document GrasshopperDocument;
  /// <summary>Gets the Grasshopper script component that owns this script.</summary>
  private readonly IGH_Component Component;
  /// <summary>
  /// Gets the current iteration count. The first call to RunScript() is associated with Iteration==0.
  /// Any subsequent call within the same solution will increment the Iteration count.
  /// </summary>
  private readonly int Iteration;
#endregion

  /// <summary>
  /// This procedure contains the user code. Input parameters are provided as regular arguments,
  /// Output parameters as ref arguments. You don't have to assign output parameters,
  /// they will have a default value.
  /// </summary>
  private void RunScript(double div, double rad, bool boolt, ref object Geometry)
  {
    var geometry = new List<object>();
    var pattlines = new List<Line>();
    var tri = Tri(rad, boolt);
    Line[] tr = tri.GetSegments(); // array creation, data structure functions similar to dict
    pattlines.Add(tr[0]);
    pattlines.Add(tr[1]);
    pattlines.Add(tr[2]);

    var gm = new List<Polyline>();
    int i = 0;
    while(i < div){
      gm.AddRange(pattlines);
      pattlines.AddRange(Patterning(gm));
      i++;
    }
    Geometry = pattlines;
  }

  Patterning(List<Line>)
  {
    var patternLines = new List<Line>();
    foreach(Line l in pattlines){
      double le = l.Length;
      Point3d pS = l.PointAt(0.0);
      Point3d p0 = l.PointAt(1 / 3);
      Point3d p1 = l.PointAt(2 / 3);
      Point3d pE = l.PointAt(1.0);

      var rotate = new Line(p0, p1);
      rotate.Transform(Rhino.Geometry.Transform.Rotation(Math.PI / 3, p0));
      Point3d tip = rotate.PointAt(1.0);
      var line0 = new Line(tip, p1);
      var line1 = new Line(pS, p0);
      var line2 = new Line(p1, pE);

      patternLines.Add(line0);
      patternLines.Add(line1);
      patternLines.Add(line2);

    }
    return patternLines;
  }

  Polyline Tri(double rad, bool boolt)
  {
    var a0 = 0;
    var a1 = a0 + Math.PI * 2 / 3;
    var a2 = a1 + Math.PI * 2 / 3;
    var p0 = new Point3d(Math.Cos(a0), Math.Sin(a0), 0);
    var p1 = new Point3d(Math.Cos(a1), Math.Sin(a1), 0);
    var p2 = new Point3d(Math.Cos(a2), Math.Sin(a2), 0);

    var tripl = new Polyline();
    tripl.Add(p0);
    tripl.Add(p1);
    tripl.Add(p2);
    tripl.Add(p0);

    if (boolt == true){
      tripl.Reverse();
    }

    return tripl;


  }

  // <Custom additional code> 

  // </Custom additional code> 
}
EN

回答 1

Stack Overflow用户

发布于 2018-02-03 11:53:44

将您的方法更改为

代码语言:javascript
复制
Patterning(List<Line>)

代码语言:javascript
复制
private List<Line> Patterning(List<Line>)

您的方法返回的是List<Line>类型的patternLines

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48593735

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档