Script to add standard offset to sketch lines
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, when making glass in lead, you need to take into account that between each piece of glass is a lead core of 1.2mm. Especially when creating complex designs, this is a pain to calculate by hand. The solution; Fusion;) Now the ideal situation would be to create a sketch with the desired design and then offset every line with 0.6mm to both sides to create the needed space for the lead core.
Unfortunately, the Fusion360's offset function in sketch mode only allows to select continuous lines, where I'm looking to add offsets to all lines of a sketch that are interconnected.
I'm wrapping my head around how to create an API script that adds an offset line to each line in a sketch (that these offset lines sometimes overlap is not a problem for me). Code below is what I have so far, got is working up until getting the lines, but completely stuck at how to create these offset lines. I found some code examples offsets in faces, but none in terms of sketches.
Any help would be very much appreciated. Happy to share my code afterwards for anyone in the same situation:)
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
# Get the root component of the active design.
rootComp = design.rootComponent
# Get the sketch in editing mode
sketch = rootComp.sketches[5]
ui.activeSelections.clear()
ui.activeSelections.add(sketch)
skCmd = ui.commandDefinitions.itemById('SketchActivate')
skCmd.execute()
# Get all sketch lines
lines = sketch.sketchCurves.sketchLines
# Create inputEntities collection and define offset distance
inputEntities = adsk.core.ObjectCollection.create()
distance = adsk.core.ValueInput.createByString('1 cm')
# Loop through lines and add to input entities
for line in lines:
inputEntities.add(lines[0])
# Create offsets for each line
offsetFeatures = features.offsetFeatures
offsetInput = offsetFeatures.createInput(inputEntities, distance, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
offsetFeatures.add(offsetInput)