C#编写依照点批量生成圆球

2
回复
3422
查看
打印 上一主题 下一主题
[复制链接]

微信扫一扫 分享朋友圈

签到天数: 29 天

连续签到: 1 天

[LV.4]三不五时

1
发表于 2016-1-9 18:49:33 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
[AppleScript] 纯文本查看 复制代码
/*
 * 批量圆球
 */ 
using System;
using System.Collections.Generic;
using Rhino;
using Rhino.Commands;
using Rhino.Geometry;
using Rhino.Input;
using Rhino.Input.Custom;
//
//创建批量圆球
namespace MyRhinoPlugIn
{
    [System.Runtime.InteropServices.Guid("d44a4efa-be5d-495f-979c-e353d53be1a1"),
    Rhino.Commands.CommandStyle(Style.ScriptRunner)]
    public class C_MultipleSphere : Command
    {

        public C_MultipleSphere()
        {
            // Rhino only creates one instance of each command class defined in a
            // plug-in, so it is safe to store a refence in a static property.
            Instance = this;
        }

        ///<summary>The only instance of this command.</summary>
        public static C_MultipleSphere Instance
        {
            get;
            private set;
        }

        ///<returns>The command name as it appears on the Rhino command line.</returns>
        public override string EnglishName
        {
            get { return "C_MultipleSphere"; }
        }

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Rhino.DocObjects.ObjRef[] obj;
            double num = 0;
            Result re;
            re = RhinoGet.GetMultipleObjects("请选择放置圆球位置点", true, Rhino.DocObjects.ObjectType.Point, out obj);
            if (re == Result.Cancel)
                return Result.Success;
            re = RhinoGet.GetNumber("请输入圆球半径", true, ref num, 0, 100);
            if (re == Result.Cancel)
                return Result.Success;
            if (obj == null || num == 0)
            {
                RhinoApp.WriteLine("输入参数不正确请查证");
                return Result.Success;
            }
            else
            {
                for (int i = 0; i < obj.Length; i++)
                {
                    Rhino.DocObjects.ObjRef iobj = obj[i];
                    Point p = iobj.Point();
                    doc.Objects.AddSphere(new Sphere(new Point3d(p.Location), num));
                }
            }
            doc.Views.Redraw();
            return Result.Success;
        }
    }
}


参与人数 1M币 +2 参与积分 +1 技术积分 +1 收起 理由
modern + 2 + 1 + 1

查看全部评分总评分 : M币 +2 参与积分 +1 技术积分 +1

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏
收藏0
支持
支持0
反对
反对0
订阅 Rhino 最新资讯
回复

使用道具 举报

签到天数: 192 天

连续签到: 1 天

[LV.7]亲友会员

2
发表于 2016-1-14 08:17:39 | 只看该作者
这个用Monkey写的话我也会,c语言写的没搞过,请问下你用哪个辅助软件写的?
回复 支持 反对

使用道具 举报

签到天数: 29 天

连续签到: 1 天

[LV.4]三不五时

3
 楼主| 发表于 2016-1-15 12:02:59 | 只看该作者
93714292 发表于 2016-1-14 08:17
这个用Monkey写的话我也会,c语言写的没搞过,请问下你用哪个辅助软件写的?

Visual Studio  C#
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

15927211580

周一至周五 9:30-18:00

武汉市武昌区中山路380号201

  • 关注微信公众号

  • 微信咨询客服号

QQ- Archiver- 鄂ICP备12016959号   充值M币 |勋章中心 | ( 鄂ICP备12016959号 )

Powered by Discuz!X3.2© 2001-2013 Comsenz Inc.

金融信息行业协会理事单位 | 信息服务业行业协会会员单位 | 网络信贷服务业企业联盟单位