My first script - Doesn't seem to work??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
Trying to create a simple cube via the following script, buyt all it seems to do is create a line in the sketch that is 1000mm long!
What am I missing?
___________________
import adsk.core
import adsk.fusion
import traceback
def create_cube():
app = adsk.core.Application.get()
design = app.activeProduct
root = design.rootComponent
# Define cube dimensions
width = 100 # mm
length = 200 # mm
depth = 25 # mm
# Create a new sketch on the XY plane
sketches = root.sketches
xy_plane = root.xYConstructionPlane
sketch = sketches.add(xy_plane)
# Create a rectangle in the sketch
sketch_lines = sketch.sketchCurves.sketchLines
point1 = adsk.core.Point3D.create(0, 0, 0)
point2 = adsk.core.Point3D.create(width, 0, 0)
point3 = adsk.core.Point3D.create(width, length, 0)
point4 = adsk.core.Point3D.create(0, length, 0)
lines = sketch_lines.addByTwoPoints(point1, point2)
lines.addByTwoPoints(point2, point3)
lines.addByTwoPoints(point3, point4)
lines.addByTwoPoints(point4, point1)
# Create an extrusion feature from the sketch
extrudes = root.features.extrudeFeatures
profile = sketch.profiles.item(0)
extrude_input = extrudes.createInput(profile, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
# Set the extrusion distance
extrude_input.setDistanceExtent(False, adsk.core.ValueInput.createByReal(depth))
extrude = extrudes.add(extrude_input)
try:
create_cube()
except Exception as e:
print('Failed: {}'.format(traceback.format_exc()))
Harrison Classic Boats
Win 10 / I7-11700K @ 4.9GHz / 64Gb RAM / SSD's