zoukankan      html  css  js  c++  java
  • sketchup ruby编程之绘制梯段

    绘制梯段,首先定义一个绘制梯段的函数,然后,在插件下增加一个”绘制“命令,已激活插件。

    UI.menu("PlugIns").add_item("Draw stairs") {
      UI.messagebox("I'm about to draw stairs!")
      draw_stairs
    }
    def draw_stairs
      stairs = 10
      rise = 8
      run = 12
      width = 100
      thickness = 3
      model = Sketchup.active_model
      entities = model.entities
      for step in 1..stairs
        x1 = 0
        x2 = width
        y1 = run * step
        y2 = run * (step + 1)
        z = rise * step
        pt1 = [x1, y1, z]
        pt2 = [x2, y1, z]
        pt3 = [x2, y2, z]
        pt4 = [x1, y2, z]
        new_face = entities.add_face pt1, pt2, pt3, pt4
        new_face.pushpull thickness
      end
    end

    首先定义四个变量,阶梯数,阶梯间隔,踏步宽度,踏步长度,添加面,然后推拉,完成一个踏步的绘制,,利用一个for循环,来完成全部踏步的绘制。

    sketchup中利用ruby编程绘制台阶

    原来ruby中的for循环是这个样子的,用到add_face和pushpull方法,以及如何添加新的菜单命令。

  • 相关阅读:
    Spring AOP
    Spring Bean的生命周期
    MySQL中的SQL的常见优化策略
    垃圾收集器
    JWT
    Zookeeper
    RabbitMQ原理介绍
    kafka 安装配置
    kafka 简介
    ELK logstash 各种报错
  • 原文地址:https://www.cnblogs.com/bimgoo/p/2956430.html
Copyright © 2011-2022 走看看