C#ATIA

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

押し出しのスピードテスト3

こちらの続きのような感じです。
押し出しのスピードテスト2 - C#ATIA
が、実質こちらの続きです。
押し出しのスピードテスト1 - C#ATIA

個人的にはFusion360でのスケッチ操作は、isComputeDeferredのOffが
最速だろうと思っています。

先日気になったこちら
Super slow run time - C#ATIA
Ekins氏もスケッチに関してはisComputeDeferredの効果が大きい事を
記載しています。
但し、今回のテストのように3Dの立方体を作成する場合は
「スケッチ → 押し出し」する必要が無い為、TemporaryBRepManagerを
使用した方が格段に早いとJesusFreke氏が記載している と解釈しました。
(スケッチはオーバーヘッドがドでかい)

で、TemporaryBRepManagerを利用し、同等の立方体を作成するコードを
作りました。

#test6-TemporaryBRepManagerで直接Box作成
def test6(comp,pnts,height):
    
    #DirectDesignType
    des = comp.parentDesign
    des.designType = adsk.fusion.DesignTypes.DirectDesignType
    bodies = comp.bRepBodies
    
    #TemporaryBRepManager
    tmpBrep = adsk.fusion.TemporaryBRepManager.get()
    
    pnt3D = adsk.core.Point3D
    l_Dir = adsk.core.Vector3D.create(1.0, 0.0, 0.0)
    w_Dir = adsk.core.Vector3D.create(0.0, 1.0, 0.0)
    obb3D = adsk.core.OrientedBoundingBox3D
    
    for ((x1,y1,z1),(x2,y2,z2)) in pnts:
        obb = obb3D.create(pnt3D.create((x1+x2)*0.5,(y1+y2)*0.5,(z1+z2)*0.5), 
                           l_Dir,
                           w_Dir,
                           height,
                           height,
                           height
                           )
    
        bodies.add(tmpBrep.createBox(obb))
        
    return inspect.getframeinfo(inspect.currentframe())[2]

念の為、前回最速だったTest3の結果はこちら

test3-time:1.13s
test3-time:1.12s
test3-time:1.14s
test3-time:1.12s
test3-time:1.12s

今回のものがこちら

test6-time:0.13s
test6-time:0.13s
test6-time:0.13s
test6-time:0.13s
test6-time:0.13s

桁違いに早いです。但し欠点もあります。
TemporaryBRepManagerを利用する場合、ダイレクトモードである必要が有ります。
利用の仕方しだいですな。