Fusion360
Fusion360とは
Autodeskの提供する3D CAD。年間10万ドル売り上げ以下は "Sign up as a Start-up or Enthusiast(Free)" というオプションでサインアップすれば無料。
チュートリアルも充実していてすぐに使える。
リンク
- 本家
- いそっぷ3DCAD塾_Fusion360コマンド解説テキスト(マニュアル)配布 個人の方の書いたマニュアル。すばらしい。後々、書店で選んだ書籍がこの方の本で、好みに合ってたんだなあと再確認。
API
C++, Python, Javascriptが使えるようだ。まあPython一択だろう普通。。
スクリプトとアドインがあって、スクリプトは呼び出し時だけ実行、アドインは組み込みコマンドとして機能する。APIに違いはないが、UIをいじる等でアドインの方が便利なことがある。
Python を編集しようとしたらSpyderをインストールしやがった。乱暴な。しかしターミナルもあるしオートコンプリートも使えるので便利かも。
定番の3x3キューブ生成をスクリプトで書いてみた。 サンプルをまねして、スケッチを書いて押し出し、という手順で書いたが もっと楽なやり方があるはず。
# -*- coding: utf-8 -*- #Author-Tatsuji Ashitani #Description-create 3x3 cubes import adsk.core, adsk.fusion, traceback # おまじない app = adsk.core.Application.get() ui = app.userInterface product = app.activeProduct design = adsk.fusion.Design.cast(product) rootComp = design.rootComponent def createComponent(): # あたらしいコンポーネントを作成 allOccs = rootComp.occurrences newOcc = allOccs.addNewComponent(adsk.core.Matrix3D.create()) return newOcc.component def createBox(component, origin, size): # スケッチを作成。いわゆる地面はxz Plane sketches = component.sketches xzPlane = component.xZConstructionPlane sketch = sketches.add(xzPlane) # 四角を作成。xz plane にxy座標で書くとxz planeに描かれる lines = sketch.sketchCurves.sketchLines; recLines = lines.addTwoPointRectangle(adsk.core.Point3D.create(origin[0], origin[1], origin[2]), adsk.core.Point3D.create(origin[0]+size, origin[1]+size, origin[2])) # 押し出し extrudes = component.features.extrudeFeatures prof = sketch.profiles[0] extInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation) distance = adsk.core.ValueInput.createByReal(size) extInput.setDistanceExtent(False, distance) extrudes.add(extInput) def run(context): ui = None try: cubeSize = 5 cubeRep = 3 for x in range(cubeRep): for y in range(cubeRep): for z in range(cubeRep): newComp = createComponent() createBox(newComp, [x*cubeSize,y*cubeSize,z*cubeSize], cubeSize) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
閉曲面をもっと自由に書くときはこんなかんじで。
# 四角の準備。xz plane基準でxyに描画するので、xz planeに描かれる(ややこしい) points = [ [0,0,0], [size,0,0], [size,size,0],[0,size,0]] # 単位はcm? vertices = [] for p in points: vertices.append(adsk.core.Point3D.create(p[0]+origin[0],p[1]+origin[1],p[2]+origin[2])) # 閉曲面を作成 points_number=len(points) for i in range(0, points_number): sketch.sketchCurves.sketchLines.addByTwoPoints(vertices[(i+1) %points_number], vertices[i])