Fusion 360 has a command ** Points along the path ** .. This is a record of twists and turns trying to achieve this with the Fusion 360 API.
Specify how to create a build point with the Fusion 360 API [** ConstructionPointInput Object **](http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-b3ffae9a-d7d7-48ee- bd66-b1138536767f) is used. The methods in the reference manual that start with ** setBy ** correspond to each command in the UI, so look for "points along the path". ** setByCenter **> Circle / Sphere / Torus Center Point ** setByEdgePlane **> Points on edges and planes //help.autodesk.com/view/NINVFUS/JPN/?guid=GUID-BF8B03C7-6E09-44E3-A641-E310E3E53FF1) ** setByPoint **> [Top Point](https: // help.autodesk.com/view/NINVFUS/JPN/?guid=GUID-0513EE5B-3A28-425E-AE34-E9E0BFF7D8D1) ** setByThreePlanes **> Points through which the three planes pass ** setByTwoEdges **> Two Edges Passing Point //help.autodesk.com/view/NINVFUS/JPN/?guid=GUID-C0483AF3-AD6E-48C5-8BA7-0443C8AB4D65) that···? ?? ?? Is there a method that corresponds to the line along the path? ?? ??
With a command similar to a point along the path [** Plane along the path **](https://help.autodesk.com/view/NINVFUS/JPN/?guid=GUID-4ED5A7DB-8EAE-466E- There is A860-8A8968BDD3F8). For some reason, there seems to be ** ConstructionPlaneInput.setByDistanceOnPath method **. is. Why is there a plane but no points? There is nothing that isn't there, so I decided to reopen and think of an alternative.
Create a plane along the path> Let's use the Fusion 360 API to create the intersection of the plane and the path.
This is the procedure for creating curved points in a sketch.
import adsk.core, adsk.fusion, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
# Get the root component of the active design.
rootComp = design.rootComponent
#
#Add code here
#
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Get the spline in Sketch 1 and assign it to crvPath
#Get sketch 1 in sketch>Get the spline curve in sketch 1
sketch1 = rootComp.sketches.item(0)
crvPath = sketch1.sketchCurves.sketchFittedSplines.item(0)
Use setByDistanceOnPath to create a face along the path. I specify a value from 0 to 1 with 0 as the start point and 1 as the end point, but instead of entering the numerical value directly, ** ValueInput ** / ENU /? Guid = GUID-bdeb52e0-a6af-4909-93e8-3b13acd0e39c) Must be specified in the object.
#Get constructionPlanes object
planes = rootComp.constructionPlanes
#Get ConstructionPlaneInput object
planeInput = planes.createInput()
#Create a plane along the path
distance = adsk.core.ValueInput.createByReal(0.4)
planeInput.setByDistanceOnPath(crvPath, distance)
plane = planes.add(planeInput)
Fusion 360 does not have a command to create a plane-path intersection, but [** Sketch.intersectWithSketchPlane method **](http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-1EB28A55 You can create the intersection of the sketch plane and the curve with -7250-4694-A253-582B395AB234). Even if the specified path is a single curve, it seems that it must be an array. Here we add crvPath
to the array ʻentities` and put it in the argument of the intersectWithSketchPlane method.
#Add new sketch
sketch2 = rootComp.sketches.add(plane)
#Create the intersection of the sketch plane and the path
entities = []
entities.append(crvPath)
skPoints = sketch2.intersectWithSketchPlane(entities)
When I run this script it looks like this
It was nice to be able to do it, but it was a lot of work and it was quite troublesome. I tried to draw and execute this code with a faint expectation that pointInput.setByDistanceOnPath is not listed in the reference and can actually be used ... but I got an error and it didn't work!
# Get construction points
points = rootComp.constructionPoints
# Create construction point input
pointInput = points.createInput()
# Add construction point by distance on path
distance = adsk.core.ValueInput.createByReal(0.4)
pointInput.setByDistanceOnPath(crvPath, distance)
point = points.add(pointInput)
I want it to be implemented in the API as soon as possible!
Recommended Posts