ChatGPT Script Issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Let me preface this with I am pretty bad with python coding. I was messing around with ChatGPT to make a script in fusion that creates an exfruded profile of text based off of user input of the text and font size, and can't seem to figure out what the error is or why it is not working. Any help is greatly appreciated.
import adsk.core, adsk.fusion
# Function to create a profile
def create_profile(name, font_size):
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
# Get the active component
root_comp = design.activeComponent
sketches = root_comp.sketches
extrudes = root_comp.features.extrudeFeatures
# Create a sketch on the XY plane
sketch = sketches.add(root_comp.xYConstructionPlane)
# Prompt the user for input
name_input = ui.inputBox("Enter a name for the profile:", "Name", name)
if name_input[0]:
name = name_input[0]
font_size_input = ui.inputBox("Enter the font size:", "Font Size", font_size)
if font_size_input[0]:
font_size = float(font_size_input[0])
# Create text
text_point = adsk.core.Point3D.create(0, 0, 0)
text_entity = sketch.sketchTexts.add(name, text_point, False)
# Set text style
text_entity.fontName = "Lucida Calligraphy Italic"
text_entity.textHeight = font_size
# Extrude the profile
prof = sketch.profiles.item(0)
ext_input = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
ext_input.setDistanceExtent(adsk.core.ValueInput.createByString("1 cm"))
ext = extrudes.add(ext_input)
ui.messageBox("Profile created successfully.")
# Call the create_profile function
create_profile("", 12)