Message 1 of 2

Not applicable
04-11-2020
07:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm still new to scripting and python but i have the basic understanding, but iv been struggling to offset and/or extrude a sketch. iv tried sample codes but cant quite understand what to change to suit the fact that i want to change a existing sketch
can anyone help me with links, code downloads, recommendations, tips, etc
this is all i have been able to get working currently in python:
import adsk.core, adsk.fusion, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
# Create a document.
doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
# Get the root component of the active design
rootComp = design.rootComponent
# Get extrude features
extrudes = rootComp.features.extrudeFeatures
# Create sketch
sketches = rootComp.sketches
sketch = sketches.add(rootComp.xZConstructionPlane)
sketchCircles = sketch.sketchCurves.sketchCircles
centerPoint = adsk.core.Point3D.create(0, 0, 0)
circle = sketchCircles.addByCenterRadius(centerPoint, 5.0)
# Get the profile defined by the circle
prof = sketch.profiles.item(0)
# Create another sketch
sketchVertical = sketches.add(rootComp.yZConstructionPlane)
sketchCirclesVertical = sketchVertical.sketchCurves.sketchCircles
centerPointVertical = adsk.core.Point3D.create(0, 1, 0)
cicleVertical = sketchCirclesVertical.addByCenterRadius(centerPointVertical, 0.5)
# Get the profile defined by the vertical circle
profVertical = sketchVertical.profiles.item(0)
# Extrude Sample 1: A simple way of creating typical extrusions (extrusion that goes from the profile plane the specified distance).
# Define a distance extent of 5 cm
distance = adsk.core.ValueInput.createByReal(5)
extrude1 = extrudes.addSimple(prof, distance, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
# Get the extrusion body
body1 = extrude1.bodies.item(0)
body1.name = "simple"
# Get the state of the extrusion
health = extrude1.healthState
if health == adsk.fusion.FeatureHealthStates.WarningFeatureHealthState or health == adsk.fusion.FeatureHealthStates.ErrorFeatureHealthState:
message = extrude1.errorOrWarningMessage
# Get the state of timeline object
timeline = design.timeline
timelineObj = timeline.item(timeline.count - 1);
health = timelineObj.healthState
message = timelineObj.errorOrWarningMessage
except:
if ui:
ui.messa
Tristan
Solved! Go to Solution.