のりーのアトリエ

家具屋・FP。思いついたことをつらつらと綴っています。主にfusion360のパラメトリックモデリングについて、ずっと書き続けます

python×fusion360 number_derumiというアドインを作ってみる。

number_derumi

 

アドインの名前も機能もいきあたりばったりで、意外と良いプログラムが出来上がりました。

いつも、ボディのサイズや場所の確認ばかりしているので、その数値をmessageboxに出します。

 

是非、動画を見て勉強してくださいね~。

ぶつぶつ言いながら作ってます。まさにいつもの職場風景。

 

どちらかというと、初心者の方に、コードを一行ずつ実行しながら進めていく様子を見ていただきたいなあと思います。1行かけたら大体いけます!

 

追記:

yとzが逆でした。

終点も追加しました。

 

ソースコード本体部分、貼っておきます。若干修正かかってます。

    app = adsk.core.Application.get()
    ui = app.userInterface
    design = adsk.fusion.Design.cast(app.activeProduct)
    try:
        filter = "Bodies"
        ent1 = ui.selectEntity("bodyをクリックしてね"filter).entity
        maxP = ent1.boundingBox.maxPoint
        minP = ent1.boundingBox.minPoint   
        ent_comp_name = ent1.parentComponent.name.split(" v")[0]
        x1= abs(round(minP.x,2)*10)
        y1= abs(round(maxP.z,2)*10)
        z1= abs(round(maxP.y,2)*10)
        x2=abs(round(maxP.x,2)*10)
        y2=abs(round(minP.z,2)*10)
        z2=abs(round(minP.y,2)*10)
        width= round(maxP.x - minP.x,2)*10
        height= round(maxP.z - minP.z,2)*10
        depth= round(maxP.y - minP.y,2)*10
        ui.messageBox("名前_{}\nwcl : {}\nhcl : {}\ndcl : {}\nwidth : {}\nheight : {}\ndepth : {}\nw2 : {}\nh2 : {}\nd2 : {}".format(ent_comp_name,x1,y1,z1,width,height,depth,x2,y2,z2))#ent + x1 + y1 + z1 +width + height + depth)