• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# RhinoDoc类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中RhinoDoc的典型用法代码示例。如果您正苦于以下问题:C# RhinoDoc类的具体用法?C# RhinoDoc怎么用?C# RhinoDoc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RhinoDoc类属于命名空间,在下文中一共展示了RhinoDoc类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: RunCommand

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      m_doc = doc;

      m_window = new Window {Title = "Object ID and Thread ID", Width = 500, Height = 75};
      m_label = new Label();
      m_window.Content = m_label;
      new System.Windows.Interop.WindowInteropHelper(m_window).Owner = Rhino.RhinoApp.MainWindowHandle();
      m_window.Show();


      // register the rhinoObjectAdded method with the AddRhinoObject event
      RhinoDoc.AddRhinoObject += RhinoObjectAdded;

      // add a sphere from the main UI thread.  All is good
      AddSphere(new Point3d(0,0,0));

      // add a sphere from a secondary thread. Not good: the rhinoObjectAdded method
      // doesn't work well when called from another thread
      var add_sphere_delegate = new Action<Point3d>(AddSphere);
      add_sphere_delegate.BeginInvoke(new Point3d(0, 10, 0), null, null);

      // handle the AddRhinoObject event with rhinoObjectAddedSafe which is
      // desgined to work no matter which thread the call is comming from.
      RhinoDoc.AddRhinoObject -= RhinoObjectAdded;
      RhinoDoc.AddRhinoObject += RhinoObjectAddedSafe;

      // try again adding a sphere from a secondary thread.  All is good!
      add_sphere_delegate.BeginInvoke(new Point3d(0, 20, 0), null, null);

      doc.Views.Redraw();

      return Result.Success;
    }
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:34,代码来源:ex_dotneteventwatcher.cs


示例2: SelByUserText

 public static Rhino.Commands.Result SelByUserText(RhinoDoc doc)
 {
     // You don't have to override RunCommand if you don't need any user input. In
     // this case we want to get a key from the user. If you return something other
     // than Success, the selection is canceled
     return Rhino.Input.RhinoGet.GetString("key", true, ref m_key);
 }
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:7,代码来源:ex_selbyusertext.cs


示例3: ReplaceHatchPattern

    public static Result ReplaceHatchPattern(RhinoDoc doc)
    {
        ObjRef[] obj_refs;
        var rc = RhinoGet.GetMultipleObjects("Select hatches to replace", false, ObjectType.Hatch, out obj_refs);
        if (rc != Result.Success || obj_refs == null)
          return rc;

        var gs = new GetString();
        gs.SetCommandPrompt("Name of replacement hatch pattern");
        gs.AcceptNothing(false);
        gs.Get();
        if (gs.CommandResult() != Result.Success)
          return gs.CommandResult();
        var hatch_name = gs.StringResult();

        var pattern_index = doc.HatchPatterns.Find(hatch_name, true);

        if (pattern_index < 0)
        {
          RhinoApp.WriteLine("The hatch pattern \"{0}\" not found  in the document.", hatch_name);
          return Result.Nothing;
        }

        foreach (var obj_ref in obj_refs)
        {
          var hatch_object = obj_ref.Object() as HatchObject;
          if (hatch_object.HatchGeometry.PatternIndex != pattern_index)
          {
        hatch_object.HatchGeometry.PatternIndex = pattern_index;
        hatch_object.CommitChanges();
          }
        }
        doc.Views.Redraw();
        return Result.Success;
    }
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:35,代码来源:ex_replacehatchpattern.cs


示例4: SetActiveView

    public static Result SetActiveView(RhinoDoc doc)
    {
        // view and view names
        var active_view_name = doc.Views.ActiveView.ActiveViewport.Name;

        var non_active_views =
          doc.Views
          .Where(v => v.ActiveViewport.Name != active_view_name)
          .ToDictionary(v => v.ActiveViewport.Name, v => v);

        // get name of view to set active
        var gs = new GetString();
        gs.SetCommandPrompt("Name of view to set active");
        gs.AcceptNothing(true);
        gs.SetDefaultString(active_view_name);
        foreach (var view_name in non_active_views.Keys)
          gs.AddOption(view_name);
        var result = gs.Get();
        if (gs.CommandResult() != Result.Success)
          return gs.CommandResult();

        var selected_view_name =
          result == GetResult.Option ? gs.Option().EnglishName : gs.StringResult();

        if (selected_view_name != active_view_name)
          if (non_active_views.ContainsKey(selected_view_name))
        doc.Views.ActiveView = non_active_views[selected_view_name];
          else
        RhinoApp.WriteLine("\"{0}\" is not a view name", selected_view_name);

        return Rhino.Commands.Result.Success;
    }
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:32,代码来源:ex_setactiveview.cs


示例5: RunCommand

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Loop loop = new Loop();
            loop.Run(doc);

            return Result.Success;
        }
开发者ID:KazunoriNakayama,项目名称:programming-for-archi-students-1,代码行数:7,代码来源:ClassesCommand.cs


示例6: DrawMesh

    public static Result DrawMesh(RhinoDoc doc)
    {
        var gs = new GetObject();
        gs.SetCommandPrompt("select sphere");
        gs.GeometryFilter = ObjectType.Surface;
        gs.DisablePreSelect();
        gs.SubObjectSelect = false;
        gs.Get();
        if (gs.CommandResult() != Result.Success)
          return gs.CommandResult();

        Sphere sphere;
        gs.Object(0).Surface().TryGetSphere(out sphere);
        if (sphere.IsValid)
        {
          var mesh = Mesh.CreateFromSphere(sphere, 10, 10);
          if (mesh == null)
        return Result.Failure;

          var conduit = new DrawBlueMeshConduit(mesh) {Enabled = true};
          doc.Views.Redraw();

          var in_str = "";
          Rhino.Input.RhinoGet.GetString("press <Enter> to continue", true, ref in_str);

          conduit.Enabled = false;
          doc.Views.Redraw();
          return Result.Success;
        }
        else
          return Result.Failure;
    }
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:32,代码来源:ex_drawmesh.cs


示例7: ViewportResolution

 public static Result ViewportResolution(RhinoDoc doc)
 {
     var active_viewport = doc.Views.ActiveView.ActiveViewport;
     RhinoApp.WriteLine("Name = {0}: Width = {1}, Height = {2}",
       active_viewport.Name, active_viewport.Size.Width, active_viewport.Size.Height);
     return Result.Success;
 }
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:7,代码来源:ex_viewportresolution.cs


示例8: BakeGeometry

 public void BakeGeometry(RhinoDoc doc, ObjectAttributes att, List<Guid> obj_ids)
 {
     List<Text3d>.Enumerator tag;
     if (att == null)
     {
     att = doc.CreateDefaultAttributes();
     }
     try
     {
     tag = this.m_tags.GetEnumerator();
     while (tag.MoveNext())
     {
         Text3d tag3d = tag.Current;
         Guid id = doc.Objects.AddText(tag3d, att);
         if (!(id == Guid.Empty))
         {
             obj_ids.Add(id);
         }
     }
     }
     finally
     {
        tag.Dispose();
     }
 }
开发者ID:panhao4812,项目名称:ClassLibrary1,代码行数:25,代码来源:Tag.cs


示例9: SelectObjectsInObjectGroups

    public static Result SelectObjectsInObjectGroups(RhinoDoc doc)
    {
        ObjRef obj_ref;
        var rs = RhinoGet.GetOneObject(
          "Select object", false, ObjectType.AnyObject, out obj_ref);
        if (rs != Result.Success)
          return rs;
        var rhino_object = obj_ref.Object();
        if (rhino_object == null)
          return Result.Failure;

        var rhino_object_groups = rhino_object.Attributes.GetGroupList().DefaultIfEmpty(-1);

        var selectable_objects= from obj in doc.Objects.GetObjectList(ObjectType.AnyObject)
                            where obj.IsSelectable(true, false, false, false)
                            select obj;

        foreach (var selectable_object in selectable_objects)
        {
          foreach (var group in selectable_object.Attributes.GetGroupList())
          {
        if (rhino_object_groups.Contains(group))
        {
            selectable_object.Select(true);
            continue;
        }
          }
        }
        doc.Views.Redraw();
        return Result.Success;
    }
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:31,代码来源:ex_selectobjectsinobjectgroups.cs


示例10: CreateMeshFromBrep

    public static Result CreateMeshFromBrep(RhinoDoc doc)
    {
        ObjRef obj_ref;
        var rc = RhinoGet.GetOneObject("Select surface or polysurface to mesh", true, ObjectType.Surface | ObjectType.PolysrfFilter, out obj_ref);
        if (rc != Result.Success)
          return rc;
        var brep = obj_ref.Brep();
        if (null == brep)
          return Result.Failure;

        // you could choose anyone of these for example
        var jagged_and_faster = MeshingParameters.Coarse;
        var smooth_and_slower = MeshingParameters.Smooth;
        var default_mesh_params = MeshingParameters.Default;
        var minimal = MeshingParameters.Minimal;

        var meshes = Mesh.CreateFromBrep(brep, smooth_and_slower);
        if (meshes == null || meshes.Length == 0)
          return Result.Failure;

        var brep_mesh = new Mesh();
        foreach (var mesh in meshes)
          brep_mesh.Append(mesh);
        doc.Objects.AddMesh(brep_mesh);
        doc.Views.Redraw();

        return Result.Success;
    }
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:28,代码来源:ex_createmeshfrombrep.cs


示例11: RunCommand

 protected override Result RunCommand(RhinoDoc doc, RunMode mode)
 {
     RcCore.It.EngineSettings.SaveDebugImages = !RcCore.It.EngineSettings.SaveDebugImages;
     var saving = RcCore.It.EngineSettings.SaveDebugImages ? "Saving" : "Not saving";
     RhinoApp.WriteLine($"{saving} debug images");
     return Result.Success;
 }
开发者ID:mcneel,项目名称:RhinoCycles,代码行数:7,代码来源:TestSaveDebugImagesToggle.cs


示例12: RunCommand

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Plugin.InitialiseCSycles();
            if (doc.Views.ActiveView.ActiveViewport.DisplayMode.Id == Guid.Parse("69E0C7A5-1C6A-46C8-B98B-8779686CD181"))
            {
                var rvp = doc.Views.ActiveView.RealtimeDisplayMode as RenderedViewport;

                if (rvp != null)
                {
                    var getNumber = new GetInteger();
                    getNumber.SetLowerLimit(1, true);
                    getNumber.SetDefaultInteger(rvp.HudMaximumPasses()+100);
                    getNumber.SetCommandPrompt("Set new sample count");
                    var getRc = getNumber.Get();
                    if (getNumber.CommandResult() != Result.Success) return getNumber.CommandResult();
                    if (getRc == GetResult.Number)
                    {
                        var nr = getNumber.Number();
                        RhinoApp.WriteLine($"User changes samples to {nr}");
                        rvp.ChangeSamples(nr);
                        return Result.Success;
                    }
                }
            }

            RhinoApp.WriteLine("Active view isn't rendering with Cycles");

            return Result.Nothing;
        }
开发者ID:mcneel,项目名称:RhinoCycles,代码行数:29,代码来源:ChangeSamples.cs


示例13: Leader

    public static Result Leader(RhinoDoc doc)
    {
        var points = new Point3d[]
        {
          new Point3d(1, 1, 0),
          new Point3d(5, 1, 0),
          new Point3d(5, 5, 0),
          new Point3d(9, 5, 0)
        };

        var xy_plane = Plane.WorldXY;

        var points2d = new List<Point2d>();
        foreach (var point3d in points)
        {
          double x, y;
          if (xy_plane.ClosestParameter(point3d, out x, out y))
          {
        var point2d = new Point2d(x, y);
        if (points2d.Count < 1 || point2d.DistanceTo(points2d.Last<Point2d>()) > RhinoMath.SqrtEpsilon)
          points2d.Add(point2d);
          }
        }

        doc.Objects.AddLeader(xy_plane, points2d);
        doc.Views.Redraw();
        return Result.Success;
    }
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:28,代码来源:ex_leader.cs


示例14: RunCommand

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      // Get the name of the instance definition to rename
      string instance_definition_name = "";
      var rc = RhinoGet.GetString("Name of block to delete", true, ref instance_definition_name);
      if (rc != Result.Success)
        return rc;
      if (string.IsNullOrWhiteSpace(instance_definition_name))
        return Result.Nothing;
     
      // Verify instance definition exists
      var instance_definition = doc.InstanceDefinitions.Find(instance_definition_name, true);
      if (instance_definition == null) {
        RhinoApp.WriteLine("Block \"{0}\" not found.", instance_definition_name);
        return Result.Nothing;
      }

      // Verify instance definition can be deleted
      if (instance_definition.IsReference) {
        RhinoApp.WriteLine("Unable to delete block \"{0}\".", instance_definition_name);
        return Result.Nothing;
      }

      // delete block and all references
      if (!doc.InstanceDefinitions.Delete(instance_definition.Index, true, true)) {
        RhinoApp.WriteLine("Could not delete {0} block", instance_definition.Name);
        return Result.Failure;
      }

      return Result.Success;
    }
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:31,代码来源:ex_deleteblock.cs


示例15: RunCommand

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      var points = new List<Point3d>
      {
        new Point3d(0, 0, 0),
        new Point3d(0, 0, 1),
        new Point3d(0, 1, 0),
        new Point3d(0, 1, 1),
        new Point3d(1, 0, 0),
        new Point3d(1, 0, 1),
        new Point3d(1, 1, 0),
        new Point3d(1, 1, 1)
      };

      RhinoApp.WriteLine("Before sort ...");
      foreach (var point in points)
        RhinoApp.WriteLine("point: {0}", point);

      var sorted_points = Point3d.SortAndCullPointList(points, doc.ModelAbsoluteTolerance);

      RhinoApp.WriteLine("After sort ...");
      foreach (var point in sorted_points)
        RhinoApp.WriteLine("point: {0}", point);

      doc.Objects.AddPoints(sorted_points);
      doc.Views.Redraw();
      return Result.Success;
    }
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:28,代码来源:ex_sortpoints.cs


示例16: CopyGroups

    public static Result CopyGroups(RhinoDoc doc)
    {
        var go = new Rhino.Input.Custom.GetObject();
        go.SetCommandPrompt("Select objects to copy in place");
        go.GroupSelect = true;
        go.SubObjectSelect = false;
        go.GetMultiple(1, 0);
        if (go.CommandResult() != Result.Success)
          return go.CommandResult();

        var xform = Transform.Identity;
        var group_map = new Dictionary<int, int>();

        foreach (var obj_ref in go.Objects())
        {
          if (obj_ref != null)
          {
        var obj = obj_ref.Object();
        var duplicate = doc.Objects.Transform(obj_ref.ObjectId, xform, false);
        RhinoUpdateObjectGroups(ref obj, ref group_map);
          }
        }
        doc.Views.Redraw();
        return Result.Success;
    }
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:25,代码来源:ex_copygroups.cs


示例17: NurbsCurveIncreaseDegree

    public static Result NurbsCurveIncreaseDegree(RhinoDoc doc)
    {
        ObjRef obj_ref;
        var rc = RhinoGet.GetOneObject(
          "Select curve", false, ObjectType.Curve, out obj_ref);
        if (rc != Result.Success) return rc;
        if (obj_ref == null) return Result.Failure;
        var curve = obj_ref.Curve();
        if (curve == null) return Result.Failure;
        var nurbs_curve = curve.ToNurbsCurve();

        int new_degree = -1;
        rc = RhinoGet.GetInteger(string.Format("New degree <{0}...11>", nurbs_curve.Degree), true, ref new_degree,
          nurbs_curve.Degree, 11);
        if (rc != Result.Success) return rc;

        rc = Result.Failure;
        if (nurbs_curve.IncreaseDegree(new_degree))
          if (doc.Objects.Replace(obj_ref.ObjectId, nurbs_curve))
        rc = Result.Success;

        RhinoApp.WriteLine("Result: {0}", rc.ToString());
        doc.Views.Redraw();
        return rc;
    }
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:25,代码来源:ex_nurbscurveincreasedegree.cs


示例18: PickPoint

    public static Result PickPoint(RhinoDoc doc)
    {
        // this creates a point where the mouse is clicked.
        var gp = new GetPoint();
        gp.SetCommandPrompt("Click for new point");
        gp.Get();
        if (gp.CommandResult() != Result.Success)
          return gp.CommandResult();
        var point3d = gp.Point();
        doc.Objects.AddPoint(point3d);
        doc.Views.Redraw();

        // selects a point that already exists
        ObjRef obj_ref;
        var rc = RhinoGet.GetOneObject("Select point", false, ObjectType.Point, out obj_ref);
        if (rc != Result.Success)
          return rc;
        var point = obj_ref.Point();
        RhinoApp.WriteLine("Point: x:{0}, y:{1}, z:{2}",
          point.Location.X,
          point.Location.Y,
          point.Location.Z);
        doc.Objects.UnselectAll();

        // selects multiple points that already exist
        ObjRef[] obj_refs;
        rc = RhinoGet.GetMultipleObjects("Select point", false, ObjectType.Point, out obj_refs);
        if (rc != Result.Success)
          return rc;
        foreach (var o_ref in obj_refs)
        {
          point = o_ref.Point();
          RhinoApp.WriteLine("Point: x:{0}, y:{1}, z:{2}",
        point.Location.X,
        point.Location.Y,
        point.Location.Z);
        }
        doc.Objects.UnselectAll();

        // also selects a point that already exists.
        // Used when RhinoGet doesn't provide enough control
        var go = new GetObject();
        go.SetCommandPrompt("Select point");
        go.GeometryFilter = ObjectType.Point;
        go.GetMultiple(1, 0);
        if (go.CommandResult() != Result.Success)
          return go.CommandResult();
        foreach (var o_ref in  go.Objects())
        {
          point = o_ref.Point();
          if (point != null)
        RhinoApp.WriteLine("Point: x:{0}, y:{1}, z:{2}",
          point.Location.X,
          point.Location.Y,
          point.Location.Z);
        }

        doc.Views.Redraw();
        return Result.Success;
    }
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:60,代码来源:ex_pickpoint.cs


示例19: RunCommand

    /// <summary>
    /// Commmand.RunCommand override
    /// </summary>
    protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, RunMode mode)
    {
        Rhino.Commands.Result rc = Rhino.Commands.Result.Success;

        if (!_bIsLoaded)
        {
          string script = ScriptFromResources(ResourceName, Password);
          if (!string.IsNullOrEmpty(script))
          {
        string macro = string.Format("_-RunScript ({0})", script);
        if (RhinoApp.RunScript(macro, false))
          _bIsLoaded = true;
        else
          rc = Result.Failure;
          }
        }

        if (rc == Result.Success)
        {
          string macro = string.Format("_-RunScript ({0})", EnglishName);
          RhinoApp.RunScript(macro, false);
        }

        return rc;
    }
开发者ID:dalefugier,项目名称:RhinoScriptCommand,代码行数:28,代码来源:RhinoScriptCommand.cs


示例20: RunCommand

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      Rhino.DocObjects.ObjRef objref;
      var rc = RhinoGet.GetOneObject("Select curve", true, ObjectType.Curve,out objref);
      if(rc!= Result.Success)
        return rc;
      var curve = objref.Curve();
      if( curve==null )
        return Result.Failure;

      var gp = new GetPoint();
      gp.SetCommandPrompt("Pick a location on the curve");
      gp.Constrain(curve, false);
      gp.Get();
      if (gp.CommandResult() != Result.Success)
        return gp.CommandResult();

      var point = gp.Point();
      double closest_point_param;
      if (curve.ClosestPoint(point, out closest_point_param))
      {
        RhinoApp.WriteLine("point: ({0}), parameter: {1}", point, closest_point_param);
        doc.Objects.AddPoint(point);
        doc.Views.Redraw();
      }
      return Result.Success;
    }
开发者ID:jackieyin2015,项目名称:rhinocommon,代码行数:27,代码来源:ex_curveclosestpoint.cs



注:本文中的RhinoDoc类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RiakObject类代码示例发布时间:2022-05-24
下一篇:
C# RhinoAutoMocker类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap