Automatically Update Version Number Embossed On Part

Automatically Update Version Number Embossed On Part

GeneralFault
Contributor Contributor
4,035 Views
11 Replies
Message 1 of 12

Automatically Update Version Number Embossed On Part

GeneralFault
Contributor
Contributor

I had a problem that I figured a few people may have come across. I'm too lazy to do a proper forum search (so forgive me if there is a better solution), but I'm not too lazy to write a script. Besides, this was a good opportunity to get familiar with the API. 

This addin will look for all sketches named "Version Number" and replace the text in any sketch-texts with the version number and part number of the component it is on.

I've only put a few minutes into this. So please feel free to improve upon it and re-share!

 

4,036 Views
11 Replies
Replies (11)
Message 2 of 12

OrvillePirlot
Contributor
Contributor

I felt free to update your code so now I am resharing 🙂

 

I incorporated a check to update the version to V1 when you are saving for the first time. This way you should never get an error because of non-existing datafiles, unsaved rootcomponents etc. I also commented out the ui display because it annoyed me. I just wanted it to update without having to click anywhere.

 

Again, feel free to improve and re-share!

 

Message 3 of 12

AbeFM
Contributor
Contributor

OMG thanks for this!

 

Keeping the part name in there can make the label a little unwieldly, I might break this into a pair of scripts (or extend it) to have "Version Number" and "Part Name" as two separate bits. But the underlying script you posted is making all the difference!

 

Thanks!

Message 4 of 12

AbeFM
Contributor
Contributor

...my first time using Python, but it wasn't much of an edit so it worked out.

 

I'm attaching a further extended version:

 

'Version Number':  ("V%s %s" % (version, currentPartnumber))

as before

 

'Version Only': ("V%s" % version)

Just VXX

 

'PartNumber Only'

currentPartnumber

 

Message 5 of 12

OrvillePirlot
Contributor
Contributor

I have been using this script for a while now, fixing some bugs, adding some features like ignore linked components and add dates, etc.

 

So for whoever it helps feel free: https://github.com/Orvillebe/Fusion360Scripting

 

Cheers,

Orville

Message 6 of 12

AbeFM
Contributor
Contributor

There's a lot there, it looks pretty interesting.

 

I'm not sure if I'm missing a set of instructions, or you're supposed to figure it all out from reading the code. I'd like to know how to add the button in, and I'd like to know how to set what's being drawn. Adding a simple method to create the text and put it on a face is super useful. Generally the process of making the sketch, getting the right font, getting it to fit on the face, doing the extrude, etc adds up, so I'm looking forward to this.

 

Is there any form of documentation? Either way, thanks for sharing.

Message 7 of 12

OrvillePirlot
Contributor
Contributor

Hi @AbeFM 

 

I added a small README with some more info on how to use it here https://github.com/Orvillebe/Fusion360Scripting/tree/master/AddIns/StampButton

 

At the moment I created it to be used specifically together with the updateOnSave addins (see https://github.com/Orvillebe/Fusion360Scripting/tree/master/AddIns) But this could be changed (see POSSIBLE CHANGES in README)

 

If you would like to change it to be used independently then the following could be useful to know.

 

This part (below) decides what the user gets to chose from, so if you would want to be able to let the user chose other inputs to stamp you should change this part. Maybe change it to a textInput for free text.

            #Dropdown of parameters
            dropDownInput = inputs.addDropDownCommandInput("selectedParameter", "Parameter", adsk.core.DropDownStyles.TextListDropDownStyle)
            dropDownItems = dropDownInput.listItems
            dropDownItems.add("Version Number", True)
            for parameter in design.userParameters:
                dropDownItems.add(parameter.name, False)

You would need to do the same thing for inputs like font, size and depth if you would want you user to choose them. Have a look into this if you want to add other inputs for the user: http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-8B9041D5-75CC-4515-B4BB-4CF2CD5BC359

 

The font, size and depth are hardcoded at the moment because they do not matter for my use case. If you would like to change that you need to update the StampOnPlanarFace method.

        #create sketch and text to stamp
        stamp = self.writeOnPlanarFace(selectedFace, stamp)

        #stamp the text
        extrudes = stamp.parentSketch.parentComponent.features.extrudeFeatures
        extrudeInput = extrudes.createInput(stamp, adsk.fusion.FeatureOperations.CutFeatureOperation)
        distance = adsk.core.ValueInput.createByReal(-0.04)
        extrudeInput.setDistanceExtent(False, distance)
        extrudes.add(extrudeInput)

 

I will probably add the depth as a user input somewhere in the future (with a default value). But I am not sure when I am going to do this. I am also still looking into fitting the stamp snugly onto the face. At the moment I am using a point of which I am certain it will be on the face but if the face is small and the stamp big, the end sometimes falls off. Easy to fix by dragging but still a bit annoying. I had a look into bounding boxes which works perfectly for rectangular shapes but for other shapes not so much. Still the stamp drags easily around.

 

Hope this helps. Feel free to ask otherwise.

 

Cheers,

Orville

 

Message 8 of 12

GeneralFault
Contributor
Contributor

I love where you have taken this @OrvillePirlot  and @AbeFM!  And thank you for publishing your work on GitHub @OrvillePirlot. Outstanding!

Message 9 of 12

s_a_archer
Community Visitor
Community Visitor

This is great! Thanks so much @OrvillePirlot for sharing this. Solved my problem.

 

Steve

0 Likes
Message 10 of 12

varazir
Explorer
Explorer

Thanks @OrvillePirlot 

 

Can this be changed to use emboss? 

0 Likes
Message 11 of 12

OrvillePirlot
Contributor
Contributor

Hello,

 

It probably could. I have to be honest and say that I haven't looked at this in a long time. But feel free to change it.

 

I still want to update it myself in the future but at the moment I cannot get to it because of different priorities.

 

Cheers,

Orville

0 Likes
Message 12 of 12

janos_von-gencsy
Observer
Observer

Hi, just to inform anyone else stumbling upon this forum post: An up to date add in with documentation exists on the Autodesk App Store: https://apps.autodesk.com/FUSION/en/Detail/Index?id=2114937992453312456 

I hope Autodesk includes this feature natively in a future version.
Cheers