Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to get user input than use that input to specify extrude distance in a script. If you could change this script, please do, i'm thinking i can then use it as an example. Thank you in advance. See below.
#Author:
#Extrudes closed object of lines
import adsk.core, adsk.fusion, traceback
def run(context😞
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
#design = app.activeProduct
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
# Get the root component of the active design.
rootComp = design.rootComponent
# Create a new sketch on the xz plane (Front plane).
sketches = rootComp.sketches;
xzPlane = rootComp.xZConstructionPlane
sketch = sketches.add(xzPlane)
# Draw two connected lines.
lines = sketch.sketchCurves.sketchLines;
line1 = lines.addByTwoPoints(adsk.core.Point3D.create(0, 0, 0), adsk.core.Point3D.create(0, 7.62, 0))
line2 = lines.addByTwoPoints(line1.endSketchPoint, adsk.core.Point3D.create(-.635, 7.62, 0))
line3 = lines.addByTwoPoints(line2.endSketchPoint, adsk.core.Point3D.create(-.635, .635, 0))
line4 = lines.addByTwoPoints(line3.endSketchPoint, adsk.core.Point3D.create(-5.08, .635, 0))
line5 = lines.addByTwoPoints(line4.endSketchPoint, adsk.core.Point3D.create(-5.08, 0, 0))
line6 = lines.addByTwoPoints(line5.endSketchPoint, adsk.core.Point3D.create(0, 0, 0))
# Get the profile defined by the sketch. FOR EXTRUDE
prof = sketch.profiles.item(0)
# Create an extrusion input
extrudes = rootComp.features.extrudeFeatures
extInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
# Define Extrude distance.
distance = adsk.core.ValueInput.createByReal(30.48)
extInput.setDistanceExtent(False, distance)
# Create the extrusion.
ext = extrudes.add(extInput)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.