Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

Using User Parameter values in in Sketch Text...

andyAWMXG
Contributor

Using User Parameter values in in Sketch Text...

andyAWMXG
Contributor
Contributor

Hi Folks,

First of all apologies if I'm in the wrong forum or this has been asked before, I've only been playing with F360 for a couple of months and am still learning, and I searched without finding anything relevant...

I'm currently using F360 to design and occasionally 3D print jigs to help me with my woodworking. I try and make the designs scaleable using the maths and functions available for use with parameters but can't figure out how to use the content of a parameter in sketch text.

For example I have a user parameter "30", named "radius" which is used as the radius of an arc. It would be really useful if the content of parameter could also be used as the content of text in a sketch. This could be extruded into the model and included in a print.

This way one user parameter change for "radius" would also be reflected in any text using "radius" with some sort of delimiter to indicate the content is from the user parameters.

Is something like this even possible?

Thanks for any help/advice, and apologies again if I've missed something relevant.

 

TTFN

Andy B.
1 Like
Reply
Accepted solutions (2)
4,015 Views
6 Replies
Replies (6)

kandennti
Mentor
Mentor
Accepted solution

 Hi @andyAWMXG .

 

I tried it because I never tried it.

 

1) Open the f3d file included in the attached file.
2) Execute Addin of attached file.
3) Correct the "radius" value of the user parameter.

1.png
4) When you press the OK button, the text of the "jigs_mark" sketch is changed and the shape is also corrected.

1 Like

kandennti
Mentor
Mentor
Accepted solution

Attachment file Addin works as it is, but there was a part that I forgot.

Adding it may make things a bit lighter.

class CommandHandler(adsk.core.ApplicationCommandEventHandler):
・・・
    def update_jigs_mark(self):
・・・
            # skt
            skt :adsk.fusion.Sketch = root.sketches.itemByName('jigs_mark')
            txt :adsk.fusion.SketchText = skt.sketchTexts.item(0)
            txt.text = '{:.1f}'.format(um.convert(prm.value, um.internalUnits, prm.unit))

            _last_radius = prm.value

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

andyAWMXG
Contributor
Contributor

Wow! many thanks for the quick reply, the code does pretty much exactly what I needed...

All I need to do now is figure out how it works under the hood!

Guess its time to go brush up on my Python, its been a few years...

 

TTFN

Andy B.
0 Likes

kandennti
Mentor
Mentor

I wrote the code but didn't come up with such an idea.
It was a good experience for me too.

 

In addition, this one only adds a little function to this one.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/events-handlers-for-sketch-selections-and-... 

 Thanks also to @william-c-anderson .

 

0 Likes

andyAWMXG
Contributor
Contributor

Dam! - this is so close...

 

The add in doing exactly what i asked for but I have one tiny problem (my fault - sorry!)

 

The text being changed is actually cut into the underside of the model and when the new text is rendered (is that the right word?) it needs to be horizontally flipped, can this be done in the code as well?

 

Apologies for being a pain!

TTFN

Andy B.
0 Likes

kandennti
Mentor
Mentor

Probably the same problem here.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/why-the-text-is-mirrored-and-upside-down/t... 


I haven't looked into it, but I think the orientation of the sketchtext will be affected by the vector of the sketch's support surface.
As far as you can see the help, I think that the sketchtext can only change the angle.
https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-265d4bb3-2e68-4edf-bd57-bb4d4204beb0 

 

For me, I think that only the text model is created on XYPlane and moved.

0 Likes