Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Text Extrusion multiple times

2 REPLIES 2
Reply
Message 1 of 3
chip.cox
115 Views, 2 Replies

Text Extrusion multiple times

Is there a limitation that prevents the same profile from being extruded twice or prevents it from being extruded once as a join and again as a cut?  I have a sketch profile of the letter 'B' lets say.  I have a 10mm external dimension square hollow box 4mm thick top wall.  I want to extrude the text so it is raised text on the outside of the box, and inset text on the inside.  I do this in the GUI with two extrude statements.  One as a join with a distance of 12 and one as a cut with a distance of 8.  However, when I do it with the API, I get an invalid argument on the second call to extrude.  

 

 

 

extrudes = root.features.extrudeFeatures

#extrude external box
distance=adsk.core.ValueInput.createByReal(10/10) exExt=extrudes.addSimple(ProBox,distance,adsk.fusion.FeatureOperations.NewBodyFeatureOperation)

#extrude text to create raised text on outside of box
distance=adsk.core.ValueInput.createByReal(12/10)         exTxt=extrudes.addSimple(ProText,distance,adsk.fusion.FeatureOperations.JoinFeatureOperation)

#extrude hex shape to hollow out the box.
distance=adsk.core.ValueInput.createByReal(5/10)                exhex=extrudes.addSimple(ProHex,distance,adsk.fusion.FeatureOperations.CutFeatureOperation)

#extrude character cutting into the top but not getting to the outside.
distance=adsk.core.ValueInput.createByReal(8/10)               exTxt2=extrudes.addSimple(ProText,distance,adsk.fusion.FeatureOperations.CutFeatureOperation)

ui.messageBox('Done')

 

 

2 REPLIES 2
Message 2 of 3
kandennti
in reply to: chip.cox

Hi @chip.cox .

 

I don't understand what you mean by the question, but I tried.

I tried to simplify the problem by only extruding the letters twice.

From the text, I interpreted the goal to look like the image below.

1.png

By setting the direction of extrusion to a negative value the second time, the shape of the image above was obtained.

# Fusion360API Python script

import traceback
import adsk
import adsk.core
import adsk.fusion

def run(context):
    ui = adsk.core.UserInterface.cast(None)
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface
        des: adsk.fusion.Design = app.activeProduct
        root: adsk.fusion.Component = des.rootComponent

        skt: adsk.fusion.Sketch = root.sketches[0]
        ProText: adsk.fusion.SketchText = skt.sketchTexts[0]


        extrudes = root.features.extrudeFeatures

        distance = adsk.core.ValueInput.createByReal(12/10)
        exTxt = extrudes.addSimple(
            ProText,
            distance,
            adsk.fusion.FeatureOperations.JoinFeatureOperation
        )

        distance = adsk.core.ValueInput.createByReal(8/10 * -1)
        exTxt2 = extrudes.addSimple(
            ProText,
            distance,
            adsk.fusion.FeatureOperations.CutFeatureOperation
        )

        ui.messageBox('Done')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

I have also attached the f3d file I tested of the image.

Message 3 of 3
chip.cox
in reply to: kandennti

I got it to work, but I had to add a second sketch profile of the text being extruded.  See the attached F3d below.  I think I read somewhere that the profile is "destroyed" when it's extruded.  That may be what's happening here.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report