iCAx开思工具箱

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 26974|回复: 2
打印 上一主题 下一主题

rhino犀牛的二次开发sdk程序代码

[复制链接]
跳转到指定楼层
楼主
发表于 2006-3-9 14:40:24 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
大家有空一起讨论讨论
以下代码是简单的添加新层的功能:
CRhinoCommand::result CCommandAddNewLayer::RunCommand(
        const CRhinoCommandContext& context
        )
  {
    // Get reference to the document's layer table
    CRhinoLayerTable& layer_table = context.m_doc.m_layer_table;


    // Cook up an unused layer name
    ON_wString unused_name;
    layer_table.GetUnusedLayerName( unused_name );


    // Prompt the user to enter a layer name
    CRhinoGetString gs;
    gs.SetCommandPrompt( L"Name of layer to add" );
    gs.SetDefaultString( unused_name );
    gs.AcceptNothing( TRUE );
    gs.GetString();
    if( gs.CommandResult() != CRhinoCommand::success )
      return gs.CommandResult();


    // Was a layer named entered?
    ON_wString layer_name = gs.String();
    layer_name.TrimLeftAndRight();
    if( layer_name.IsEmpty() )
    {
      RhinoApp().Print( L"Layer name cannot be blank.\n" );
      return CRhinoCommand::cancel;
    }


    // Is the layer name valid?
    if( !RhinoIsValidName(layer_name) )
    {
      RhinoApp().Print( L"\"%s\" is not a valid layer name.\n", layer_name );
      return CRhinoCommand::cancel;
    }


    // Does a layer with the same name already exist?
    int layer_index = layer_table.FindLayer( layer_name );
    if( layer_index >= 0 )
    {
      RhinoApp().Print( L"A layer with the name \"%s\" already exists.\n", layer_name );
      return CRhinoCommand::cancel;
    }


    // Create a new layer
    ON_Layer layer;
    layer.SetLayerName( layer_name );


    // Add the layer to the layer table
    layer_index = layer_table.AddLayer( layer );
    if( layer_index < 0 )
    {
      RhinoApp().Print( L"Unable to add \"%s\" layer.\n", layer_name );
      return CRhinoCommand::failure;
    }


    return CRhinoCommand::success;
  }
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 支持支持
沙发
发表于 2009-1-13 21:13:27 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
板凳
发表于 2010-11-21 15:30:09 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

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

本版积分规则

手板模型制作,在线3D打印服务

QQ|小黑屋|手机版|开思工具箱 CAD工具箱_CAM工具箱  

GMT+8, 2024-4-28 12:38 , Processed in 0.016663 second(s), 18 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

快速回复 返回顶部 返回列表