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: 

Automatically Update Version Number Embossed On Part

10 REPLIES 10
Reply
Message 1 of 11
GeneralFault
2365 Views, 10 Replies

Automatically Update Version Number Embossed On Part

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!

 

10 REPLIES 10
Message 2 of 11

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 11
AbeFM
in reply to: GeneralFault

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 11
AbeFM
in reply to: AbeFM

...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 11
OrvillePirlot
in reply to: AbeFM

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 11
AbeFM
in reply to: OrvillePirlot

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 11
OrvillePirlot
in reply to: AbeFM

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 11

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

Message 9 of 11
s_a_archer
in reply to: GeneralFault

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

 

Steve

Message 10 of 11
varazir
in reply to: OrvillePirlot

Thanks @OrvillePirlot 

 

Can this be changed to use emboss? 

Message 11 of 11
OrvillePirlot
in reply to: varazir

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

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report