Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to have the user select a surface that will then be thickened. I'm able to run the code and select a surface but then I get AttributeError: 'BRepBody' object has no attribute 'bodies'.
import adsk.core, adsk.fusion, traceback
def run(context) :
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
SurfaceSel = ui.selectEntity('select a surface', 'SurfaceBodies')
if SurfaceSel:
surface = adsk.fusion.BRepBody.cast(SurfaceSel.entity)
des = adsk.fusion.Design.cast(app.activeProduct)
root = des.rootComponent
ui.messageBox('Pass:\n{}'.format(traceback.format_exc()))
# Create thicken feature
thickenFeatures = root.features.thickenFeatures
inputSurfaces = adsk.core.ObjectCollection.create()
bodies = surface.bodies
for body in bodies :
thickenFeatures.add(body)
thickness = adsk.core.ValueInput.createByReal(1.0)
thickenInput = thickenFeatures.createInput(inputSurfaces, thickness, False, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
thickenFeatures.add(thickenInput)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.