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)
fusion360 x python 第一回 fusion360とpythonで何が出来るんじゃろ編。
fusion360 x python 第2回 サンプルスクリプト&スクリプトとアドイン編
fusion360 x python 第3回 プログラムを実行する準備とVScodeの日本語化。知らなかったら、ちっとも動きま編
fusion360×python 第4回 サンプルプログラムの解説!
fusion360×python 第五回、サンプルプログラム「Bottle」のなんとなくの解説
fusion360×python 第六回 sample 押出について改め、sampleのプログラムのコピペ・実行。リファレンスサイト、フォーラムご紹介