【Fusion360API】 Simple-Extrudes 简

2018-03-27  本文已影响55人  孝吾
实现效果

在坐标原点创建一个半径为2cm高为5cm的圆柱

# -*- coding: utf-8 -*-
"""
Created on Tue Mar 27 16:02:30 2018

@author: xiaowu
"""

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try: 
        app = adsk.core.Application.get()
        ui = app.userInterface
        #create new documents.创建一个新的文件
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)

        design = app.activeProduct

        # Get the root component of the active design.
        rootComp = design.rootComponent

        # Create a new sketch on the xy plane.在XY平面创建草图
        sketches = rootComp.sketches
        xyPlane = rootComp.xYConstructionPlane
        sketch = sketches.add(xyPlane)

        # Draw a circle.创建一个圆
        circles = sketch.sketchCurves.sketchCircles
        circle1 = circles.addByCenterRadius(adsk.core.Point3D.create(0, 0, 0), 2)

        # Get the profile defined by the circle.*可以理解为选中这个圆吧。
        prof = sketch.profiles.item(0)

        # Define that the extent is a distance extent of 5 cm.设置拉伸高度5CM
        distance = adsk.core.ValueInput.createByReal(5)

        # Create the extrusion.
        extrudes = rootComp.features.extrudeFeatures
        ext = extrudes.addSimple(prof, distance, adsk.fusion.FeatureOperations.NewComponentFeatureOperation)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

官方传送门: https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-20302b02-fd08-11e4-b923-3417ebd3d5be

上一篇 下一篇

猜你喜欢

热点阅读