Finally, I created 2 more codes. If one of them does not work, there is nothing else I can do.
Option 1
import adsk.core, adsk.fusion, traceback, math
def create_and_extrude_panel():
app = adsk.core.Application.get()
design = adsk.fusion.Design.cast(app.activeProduct)
if not design:
ui.messageBox('It is not supported in the current workspace. Please change to the MODEL workspace and try again.')
return
# Create a new component for the panel.
root_comp = design.rootComponent
new_comp = root_comp.occurrences.addNewComponent(adsk.core.Matrix3D.create())
panel_comp = new_comp.component
# Create a new sketch for the panel profile.
sketches = panel_comp.sketches
xy_plane = panel_comp.xYConstructionPlane
panel_sketch = sketches.add(xy_plane)
# Define the corners of the panel profile.
corner1 = adsk.core.Point3D.create(0, 0, 0)
corner2 = adsk.core.Point3D.create(0, 1588, 0)
corner3 = adsk.core.Point3D.create(200, 1717, 0)
corner4 = adsk.core.Point3D.create(200, 0, 0)
# Create lines connecting the corners to form the panel profile.
lines = panel_sketch.sketchCurves.sketchLines
# Define the angles between the lines.
angle1 = math.radians(123)
angle2 = math.radians(57)
# Create the lines with the specified angles.
line1 = lines.addByTwoPoints(corner1, corner2, angle1)
line2 = lines.addByTwoPoints(corner2, corner3, angle2)
line3 = lines.addByTwoPoints(corner3, corner4)
line4 = lines.addByTwoPoints(corner4, corner1)
# Extrude the panel profile to create a solid body.
bodies = panel_comp.bRepBodies
panel_body = bodies.add(panel_sketch, adsk.fusion.FeatureOperation.NewBody)
return panel_comp
# Call the function to create and extrude the panel.
panel_comp = create_and_extrude_panel()
Option 2
import adsk.core, adsk.fusion, traceback, math
def create_and_extrude_panel():
app = adsk.core.Application.get()
design = adsk.fusion.Design.cast(app.activeProduct)
if not design:
ui.messageBox('It is not supported in the current workspace. Please change to the MODEL workspace and try again.')
return
# Create a new component for the panel.
root_comp = design.rootComponent
new_comp = root_comp.occurrences.addNewComponent(adsk.core.Matrix3D.create())
panel_comp = new_comp.component
# Create a new sketch for the panel profile.
sketches = panel_comp.sketches
xy_plane = panel_comp.xYConstructionPlane
panel_sketch = sketches.add(xy_plane)
# Define the corners of the panel profile.
corner1 = adsk.core.Point3D.create(0, 0, 0)
corner2 = adsk.core.Point3D.create(0, 1588, 0)
corner3 = adsk.core.Point3D.create(200, 1717, 0)
corner4 = adsk.core.Point3D.create(200, 0, 0)
# Create lines connecting the corners to form the panel profile.
lines = panel_sketch.sketchCurves.sketchLines
# Define the angles between the lines.
angle1 = math.radians(123)
angle2 = math.radians(57)
# Create the lines with the specified angles.
line1 = lines.addByTwoPoints(corner1, corner2, angle1)
line2 = lines.addByTwoPoints(corner2, corner3, angle2)
line3 = lines.addByTwoPoints(corner3, corner4, angle1)
line4 = lines.addByTwoPoints(corner4, corner1, angle2)
# Extrude the panel profile to create a solid body.
bodies = panel_comp.bRepBodies
panel_body = bodies.add(panel_sketch, adsk.fusion.FeatureOperation.NewBody, 50, adsk.fusion.BodyAppearance.Smooth)
return panel_comp
# Call the function to create and extrude the panel.
panel_comp = create_and_extrude_panel()
Mustafa Furkan Özel
Project - R&D Manager
LinkedIn