C#ATIA

↑タイトル詐欺 主にFusion360API 偶にCATIA V5 VBA(絶賛ネタ切れ中)

Sirenテスト-offset

こちらのOffsetモジュール続きです。
Sirenテスト-sweep_vec,sweep_path,loft - C#ATIA

リファレンスマニュアルを見ると、残りはoffset関数だけなのですが、
ソースコードではそれ以外のものも入っていた為、テストしてみました。

#SirenScript
expName = "/SirenTest"
$expIges = ARGV[0] + expName + ".igs"
$expBrep = ARGV[0] + expName + ".brep"
$expDump = ARGV[0] + expName + "_dump.txt"

def wDump(i)
  if i.kind_of?(String)
     open($expDump, "a") {|f| f.write "\r\n" + i}
  end
end

open($expDump, "w") {|f| f.write "start"}

###########
exp_Items=[] #出力面配列

#-offset_geomsurf- 上手く出来ない
fl = Filler.new
[[[0,0,0], [10,0,0]],
 [[10,0,0], [10,10,0]],
 [[10,10,0], [0,10,0]],
 [[0,10,0], [0,0,0]]].each do |pts|
  wDump(pts.to_s)
  fl.add_bound Build.line(pts[0],pts[1]), 0
end
fl.build
wDump(fl.done?.to_s)
target=fl.face
wDump(target.to_s)
#exp_Items<<target
#off_g=Offset.offset_geomsurf(target,1.0)#ng
#off_g=Offset.offset_geomsurf(target,1.0,0.001)#ng
#off_g=Offset.offset_geomsurf(target,1.0.to_f,0.1.to_f)#ng
#wDump(off_g.to_s)
#exp_Items<<off_g


#-offset-
#第一引数:面
#第二引数:オフセット距離
#第三引数:トレランス
fl = Filler.new
[[[10,0,0], [20,0,5]],
 [[20,0,5], [20,10,0]],
 [[20,10,0], [10,10,5]],
 [[10,10,5], [10,0,0]]].each do |pts|
  wDump(pts.to_s)
  fl.add_bound Build.line(pts[0],pts[1]), 0
end
fl.add ([15,5,10])
fl.build
wDump(fl.done?.to_s)
target=fl.face
exp_Items<<target
off=Offset.offset(target,1,0.01)
#off=Offset.offset(target,1.0,0.001,0,false,false,0,false)#ng
wDump(off.to_s)
exp_Items<<off


#-offset_shape- 上手く出来ない
#第一引数:面
#第二引数:オフセット距離
#第三引数:トレランス
fl = Filler.new
[[[20,0,0], [30,0,5]],
 [[30,0,5], [30,10,0]],
 [[30,10,0], [20,10,5]],
 [[20,10,5], [20,0,0]]].each do |pts|
  wDump(pts.to_s)
  fl.add_bound Build.line(pts[0],pts[1]), 0
end
fl.add ([25,5,10])
fl.build
wDump(fl.done?.to_s)
target=fl.face
#exp_Items<<target
#off_s=Offset.offset_shape(target,1,0.1)#ng
#off_s=Offset.offset_shape(target,1.0,0.001,0,false,false,0)#ng
#wDump(off_s.to_s)
#exp_Items<<off_s


#-offset_pipe- 上手く出来ない
profile=Build.circle3p([0,10,0],[10,20,0],[0,30,0])
wDump(profile.to_s)
#exp_Items<<profile
path=Build.wire([Build.line([0,20,0],[0,20,30])],0.001)
wDump(path.to_s)
#exp_Items<<path
#off_p=Offset.offset_pipe(profile,path)#ng
#wDump(off_p.to_s)
#exp_Items<<off_p

com = Build::compound [*exp_Items]
###########

IGES.save [com] , $expIges
BRepIO::save com , $expBrep
wDump("end")

コメントだらけなのですが、結局offset関数のみ出来ました。
リファレンスマニュアルに記載されていない以上、未対応と受け止めて
おきます。

唯一出来上がったものがこちらです。(色はCATIAで付けています)
f:id:kandennti:20160315124308p:plain
オレンジが元の面、青が1mmオフセットした面です。
試しに、CATIAで1mmオフセットした面(赤)だと、
f:id:kandennti:20160315124323p:plain
こんな感じです。
面の境界部分が、かなり異なります。(単純な平面でも同様でした)
offset関数は4~8までのオプション引数があるようなので(上手く行き
ませんでしたが)、第四引数のModeで調整できるのかな?
と思ったのですが。