ユーザ用ツール

サイト用ツール


ブール演算

基本コード

rs.BooleanDifference(input0, input1, delete_input=True) # 差
rs.BooleanIntersection(input0, input1, delete_input=True) # 交差
rs.BooleanUnion(input, delete_input=True) # 和

サンプルコード1

2つの球の差を求める

import rhinoscriptsyntax as rs
 
a = []
s0 = rs.AddSphere([0,0,0], 50)
s1 = rs.AddSphere([40,0,0], 40)
 
a.extend(rs.BooleanDifference(s0, s1))

実行結果

サンプルコード2

円柱の表面から複数の球を引き算する

a = []
s0 = rs.AddCylinder([0,0,-50], [0,0,50], 100)
 
DIV_NUM = 12
for i in range(DIV_NUM):
    angle = math.radians(i * 360 / DIV_NUM)
    s1 = rs.AddSphere([100*math.cos(angle),100*math.sin(angle),0], 20)
    s0 = rs.BooleanDifference(s0, s1)
 
a.extend(s0)

実行結果

ブール演算.txt · 最終更新: 2023/01/26 13:14 by jmitani

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki