Anyone able to write a small script please ?

Anyone able to write a small script please ?

info83PHN
Advocate Advocate
965 Views
4 Replies
Message 1 of 5

Anyone able to write a small script please ?

info83PHN
Advocate
Advocate

Hi all. Looking for someone to write a small python script for Fusion 360.

 

Basic spec :

Input Box for text.

Input box for Size.

Static variable for the font to use.

Static variable for 'Height A' and 'Height B'.

Create text for the first character in the text string in the currently open sketch and extrude to height 'A'

Repeat for each letter, alternating between height 'A' and height 'B'

0 Likes
Accepted solutions (1)
966 Views
4 Replies
Replies (4)
Message 2 of 5

jsormaz
Advocate
Advocate

I recommend opening up the documentation (https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-1C665B4D-7BF7-4FDF-98B0-AA7EE12B5AC2) and at least trying to do these things yourself.

 

If you get stuck on specific areas, this forum can be a great resource.

If you are looking for someone to just do the work for you, you may get lucky but more likely you will fall on deaf ears.

There are also plenty of folks on here who are willing to exchange their time/experience for a fee.

 

PS: I get personally bothered by the "small" euphemism. If you are truly aware that it is a "small" task, this implies that you are capable of doing it yourself, in which case why are you here?

Instagram:
@sonsofsormaz
0 Likes
Message 3 of 5

info83PHN
Advocate
Advocate

I have done coding before, but not python. So I do have a basic idea of just what's involved in the task.
Yes, I could probably do it myself if I spend a few hours experimenting, but a seasoned coder would probably know how to do this in well under 30 minutes. I would be happy to pay for that time.

0 Likes
Message 4 of 5

info83PHN
Advocate
Advocate
Accepted solution

actually, I have already found enough to realise that the process I want is not ideal, so am already changing my thoughts and workflow to use 'insert into current design' instead. Thanks anyway

 

0 Likes
Message 5 of 5

kandennti
Mentor
Mentor

Hi @info83PHN .

 

Probably not going to end up in a small script.
We worked on it a bit, but if the workflow has been changed, it is probably unnecessary.


I'm leaving this in case others can use it.

I created a function to get the names of fonts that can be used dynamically.

 

def getFontName() -> list:
    app: adsk.core.Application = adsk.core.Application.get()
    ui = app.userInterface
    des: adsk.fusion.Design = app.activeProduct
    root: adsk.fusion.Component = des.rootComponent

    app.executeTextCommand(u'PTransaction.Start getFontName')

    skt: adsk.fusion.Sketch = root.sketches.add(root.xYConstructionPlane)
    sktTxtIpt: adsk.fusion.SketchTextInput = skt.sketchTexts.createInput2(
        'hoge',
        2.0
    )

    sktTxtIpt.setAsMultiLine(
        adsk.core.Point3D.create(0, 0, 0),
        adsk.core.Point3D.create(10, 5, 0),
        adsk.core.HorizontalAlignments.LeftHorizontalAlignment,
        adsk.core.VerticalAlignments.TopVerticalAlignment,
        0
    )
    sktTxt: adsk.fusion.SketchText = skt.sketchTexts.add(sktTxtIpt)

    sels: adsk.core.Selections = ui.activeSelections
    sels.clear()
    sels.add(sktTxt)

    app.executeTextCommand(u'Commands.Start EditMTextCmd')
    dialogInfo = app.executeTextCommand(u'Toolkit.cmdDialog')
    app.executeTextCommand(u'NuCommands.CancelCmd')
    skt.deleteMe()

    app.executeTextCommand(u'PTransaction.Abort')

    fontInfos = dialogInfo.split('TextFont,')[-1].split('TextExStyle,')[0].split('MenuItems:')[-1].split('\n')
    fonts = [str.strip(t.split(',')[0]) for t in fontInfos]
    return fonts

 

 

It took me about two hours just to do this because I am not proficient enough.
It seems that I am still lacking in study.