以下の内容はhttps://end0tknr.hateblo.jp/entry/20250515/1747296784より取得しました。


fusion360 python apiで 2個のコンポーネントをジョイント(結合)

↓こう書くと、↑こう表示されます

import adsk.core, adsk.fusion, traceback, math

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface

        # 新しいドキュメント
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        design = adsk.fusion.Design.cast(app.activeProduct)
        rootComp = design.rootComponent
        allOccs = rootComp.occurrences
        center = adsk.core.Point3D.create(0, 0, 0)

        # 円柱1作成
        subOcc0 = allOccs.addNewComponent(adsk.core.Matrix3D.create())
        subComp0 = subOcc0.component
        sketch0 = subComp0.sketches.add(subComp0.xZConstructionPlane)
        sketch0.sketchCurves.sketchCircles.addByCenterRadius(center, 2.5)
        prof0 = sketch0.profiles.item(0)
        extrude0 = subComp0.features.extrudeFeatures.addSimple(
            prof0,
            adsk.core.ValueInput.createByString("5 mm"),
            adsk.fusion.FeatureOperations.NewBodyFeatureOperation
        )

        # 円柱2作成
        subOcc1 = allOccs.addNewComponent(adsk.core.Matrix3D.create())
        subComp1 = subOcc1.component
        sketch1 = subComp1.sketches.add(subComp1.xZConstructionPlane)
        sketch1.sketchCurves.sketchCircles.addByCenterRadius(center, 0.5)
        prof1 = sketch1.profiles.item(0)
        extrude1 = subComp1.features.extrudeFeatures.addSimple(
            prof1,
            adsk.core.ValueInput.createByString("50 mm"),
            adsk.fusion.FeatureOperations.NewBodyFeatureOperation
        )

        # 接触面の取得とJointGeometry作成
        topFace1 = extrude0.endFaces.item(0)    # 円柱1の上面
        bottomFace2 = extrude1.endFaces.item(0) # 円柱2の底面

        geom0 = adsk.fusion.JointGeometry.createByPlanarFace(
            topFace1, None, adsk.fusion.JointKeyPointTypes.CenterKeyPoint
        )
        geom1 = adsk.fusion.JointGeometry.createByPlanarFace(
            bottomFace2, None, adsk.fusion.JointKeyPointTypes.CenterKeyPoint
        )

        # === RigidJoint作成 ===
        jointInput = rootComp.joints.createInput(geom1, geom0)
        jointInput.isFlipped = True  # 反転ON
        jointInput.setAsRigidJointMotion()
        rootComp.joints.add(jointInput)

    except Exception as e:
        if ui:
            ui.messageBox(f'Failed:\n{traceback.format_exc()}')



以上の内容はhttps://end0tknr.hateblo.jp/entry/20250515/1747296784より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14