thomasa88 / ParametricText

Fusion 360™ add-in for creating Text Parameters in sketches.
MIT License
83 stars 5 forks source link

Feature Request: Integer sequence as parameter #41

Closed dandubya closed 1 year ago

dandubya commented 2 years ago

Is your feature request related to a problem? Please describe. I have one simple body (a cylinder) in my design, and I have used parameterized text to add a number to it. I want to replicate this body ~32 times, and have them automatically numbered from 1-32. Yesterday, I spent 1+ hours manually changing the parameterized text (number) from 1 to 2 to 3 to 4 up to 32, and then exporting each revision as a separate STL.

Describe the solution you'd like I'd like to be able to have each body get a unique number, in sequence.

Having something like {seq} as a parameter would also allow for prefixing or postfixing other text, e.g.: Item.{seq} would yield "item.1", "item.2", etc.

And because some might want the sequence to start on a different value: item.{seq:10.16} could label items as "item.10", "item.11" to "item.16".

Describe alternatives you've considered I've also considered whether I can invoke Fusion 360 headless from a command line, where I could loop through a sequence in a script, and pass the sequence number into the ParameterizedText field, and then export as an STL. This would eliminate the need to create copies of the body in the file. But, it would require writing a script, which maybe not everyone is comfortable doing. If this is possible, though, I'd love to know how!

Additional context

image image

Do not forget to "Subscribe" to the issue if you want updates!

thomasa88 commented 2 years ago

Hi, I think the closest you can get with the current implementation is _.component combined with substrings.

I have not tried this:

  1. Create a component and name it comp1
  2. Set a parametric text on sketch in it: {_.component[4:]}. This will cut away the first 4 letters.
  3. Copy the component and create new components with "Paste New" (here is where things might fall apart)

Regarding scripting input, there is no designed way for ParametricText. There have been ideas of being able to import and export the parameters as a text file, but no official request.

For your use case, maybe you should create the "hello world" script in Fusion (Addins -> Create new python script). And experiment with SketchText and possibly iterating through design.rootComponent (Instances of components are called occurrences. If I remember correctly, you can recurse down into them to find sketches etc.).

design = adsk.core.Application.get().activeProduct

Fusion reference: https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-7B5A90C8-E94C-48DA-B16B-430729B734DC