Skip to content

Commit

Permalink
Merge branch 'v2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasa88 committed Jun 17, 2021
2 parents 480ac5f + ee5fca1 commit 2cb7e6f
Show file tree
Hide file tree
Showing 32 changed files with 1,009 additions and 204 deletions.
20 changes: 20 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Required
version: 2

sphinx:
builder: html
configuration: docs/conf.py
fail_on_warning: true

python:
install:
- requirements: docs/requirements.txt

# name: docs
# channels:
# - conda-forge
# - defaults
# dependencies:
# - sphinx==3.5.4
# - pip:
# - sphinx_rtd_theme==0.5.2
2 changes: 1 addition & 1 deletion ParametricText.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"description": {
"": "Allows using parameters for texts."
},
"version": "2.1.0",
"version": "2.2.0",
"runOnStartup": true,
"supportedOS": "windows|mac",
"editEnabled": true
Expand Down
210 changes: 190 additions & 20 deletions ParametricText.py

Large diffs are not rendered by default.

185 changes: 3 additions & 182 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,198 +4,19 @@

ParametricText is an Autodesk® Fusion 360™ add-in for creating *Text Parameters* in sketches.

Text parameters can be pure text or use parameter values by using a special syntax. There is also a special parameter, that contains information about the document's version and save date.

All parameters are stored within in the document upon save. The texts are always "rendered" in the sketches, so they can be viewed without having the add-in. However, to correctly update the values, the add-in is needed.

![Screenshot](screenshot.png)
![Screenshot](docs/images/screenshot.png)

## Supported Platforms

* Windows
* Mac OS

## Installation

Download the add-in from the [Releases](https://github.com/thomasa88/ParametricText/releases) page.

Unpack it into `API\AddIns` (see [How to install an add-in or script in Fusion 360](https://knowledge.autodesk.com/support/fusion-360/troubleshooting/caas/sfdcarticles/sfdcarticles/How-to-install-an-ADD-IN-and-Script-in-Fusion-360.html)).

Make sure the directory is named `ParametricText`, with no suffix.

## Usage

Please see the [Demo video](https://knowledge.autodesk.com/support/fusion-360/learn-explore/caas/screencast/Main/Details/3d4a64a7-37b3-4551-83c4-a93a4d96bca7.html) for a quick overview of ParametricText.

To parameterize texts, create sketches with Text features. Make sure to enter some dummy text, to make the Text features easier to select. Also, since Fusion 360™ resets some text settings when a text is modified by an add-in, it is recommended to not position the text in any way until it has been assigned a text parameter.

Open the *Modify* menu under e.g. the *SOLID* tab and click *Change Text Parameters*.

Use the `+` and `x` buttons to add and remove rows from the table.

To specify what sketch texts to affect, click the desired row and then select the sketch texts in the design. Use the clear button (![](resources/clear_selection/16x16.png)) to clear the selections.

Enter the text in the text field. The text can contain values from parameters. See [Parameters](#parameters).

The various buttons with braces (`{}`) allows for quickly inserting parameters.

Enabling *Run Compute All automatically* will make ParametricText run *Compute All* every time text parameters are updated. This can be needed for geometry depending on the texts to be redrawn.

Press OK to save the changes.

The add-in can be temporarily disabled using the *Scripts and Add-ins* dialog. Press *Shift+S* in Fusion 360™ and go to the *Add-Ins* tab.

## Parameters

ParametricText has basic support for including parameter values using [Python Format Specifiers](https://docs.python.org/3/library/string.html#formatspec). By writing `{parameter}`, the text is substituted by the parameter value. E.g., if the parameter *d10* has the value 20, `{d10}` becomes `20.0`.

The special parameter `_` gives access to special values, such as document version.

`_.date` supports [Python strftime()](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes) formatting. E.g., `{_.date:%Y}` will show the year that the document was saved.

### Available Parameter Expressions

The following table shows the parameter values that can be used in ParametricText. *parameter* represents any numerical parameter defined in Fusion 360™, such as `d39` or `length`.

| Field Value (within `{}`) | Description | Example Result |
| -------------------------------------- | ------------------------------------------------------------ | ------------------ |
| `_.version` | Document version | `24` |
| `_.file` | Document filename | `Crank` |
| `_.component` | Name of the component which the Sketch belongs to | `Handle` |
| `_.sketch` | Name of the sketch. Makes it possible to edit texts directly in the Browser. | `Sketch4` |
| `_.date` | Document save date | `2020-09-27` |
| *`parameter`* or *`parameter`*`.value` | Parameter value | `10.0` |
| *`parameter`*`.comment` | Parameter comment | `Width of the rod` |
| *`parameter`*`.expr` | Parameter expression, as entered by the user | `5 mm + 10 mm` |
| *`parameter`*`.unit` | Parameter unit | `mm` |

### Parameter Substrings

Parameter values that are textual (`_.file`, `_.component`, *`parameter`*`.comment`) can be cut into substrings using the Python slice notation: `[start:stop]` (the `step` option is not supported).
## Documentation

The range is left-inclusive and right-exclusive, meaning that a range of `[2:4]` will give the characters at index `2` and `3`, but not `4`.

The character position is zero-indexed, which means that the first character will be number `0`.

Note: The length of numberic parameters can be adjusted using the Python Format Specifiers, as shown in a later section.

| Field Value (within `{}`) | Description | Example Result |
| ---------------------------- | ----------------------------------------------------- | -------------- |
| `_.file[0:3]` | First three characters (0 through 2) of the filename. | `Cra` |
| `_.component[2]` | Character `2` (the third character in the string) | `n` |
| *`parameter`*`.comment[-3:]` | The last three characters of the parameter comment | `rod` |
| *`parameter`*`.comment[6:]` | All characters from index `6`. | `of the rod` |

### Parameter Usage Examples

The following table shows examples on how to access values and format parameters.

| Value | Result |
| ----------------------- | ------------------------------------------------- |
| `{d1:.3f} {d1.unit}` | `15.000 mm` (3 decimal places) |
| `{d1:03.0f}` | `015` (Float/decimal zero-padded to three digits) |
| `{width:.0f}` | `6` (No decimal places) |
| `{width.expr}` | `6 mm` |
| `{height.expr}` | `2 mm + width` |
| `{height.comment}[0:5]` | `The h` |

### Special Parameter Usage Examples

The following table shows examples of using the special parameter `_`.

| Value | Result |
| ----------------------- | ------------------------------------------------------------ |
| `{_.version}` | `5` |
| `v{_.version:03}` | `v005` (Integer zero-padded to three digits) |
| `{_.file}` | `Crank` |
| `{_.file} v{_.version}` | `Crank v5` |
| `{_.component}` | `Handle` |
| `{_.sketch}` | `My description` |
| `{_.date}` | `2020-09-27` (Current date, in ISO 8601 format) |
| `{_.date:%m/%d/%Y}` | `09/27/2020` (Month, day, year) |
| `{_.date:%U}` | `40` (Current week, that starts on a Sunday) |
| `W{_.date:%W}` | `39` (Current week, that starts on a Monday, prefixed with "W") |
| `{_.date:%H:%M}` | `14:58`<sup>1</sup> (Hour, second) |

<sup>1</sup> Note: The time of day is "unstable". The time of day will be set a few seconds before the save time, when saving, and on the next change of text parameters, the time will jump to the correct save time.

## Known Limitations

* *Compute All* does currently not update the text parameters.
* `{` and `}` cannot be entered in string inputs in Fusion 360™ on keyboards where they require *Alt Gr* to be pressed.
* Workaround is to use the `{}` button.
* The mouse pointer must be moved before clicking on the same sketch text again, to select/unselect.
* `_.file` does not update on file rename/copy.
* Workaround is to open the *Change Text Parameters* and click *OK* in the new document.

## Migrating from Version 1.x to 2.x

A new storage format was introduced in version 2, to accommodate new features. If you load a document created with the old version, you will be prompted to update the text parameters to the new version.

After updating the text parameters, they can no longer be edited with the old version.

It is recommended to save the document before doing the update, to have a backup.

## Reporting Issues

Please report any issues that you find in the add-in on the [Issues](https://github.com/thomasa88/ParametricText/issues) page.

For better support, please include the steps you performed and the result. Also include copies of any error messages.

## Author

This add-in is created by Thomas Axelsson.

## License

This project is licensed under the terms of the MIT license. See [LICENSE](LICENSE).
https://parametrictext.readthedocs.io/en/stable/

## More Fusion 360™ Add-ins

[My Fusion 360™ app store page](https://apps.autodesk.com/en/Publisher/PublisherHomepage?ID=JLH9M8296BET)

[All my add-ins on Github](https://github.com/topics/fusion-360?q=user%3Athomasa88)

## Changelog

* v 2.1.0
* Fix Fusion 360 crash in non-parametric mode, by not calling *Compute All* in non-parametric mode.
* Only run automatic *Compute All* if there are any text parameters that have been updated.
* Text substrings using Python slice operator.
* Add `_.sketch`
* v 2.0.0
* Rewritten selection engine.
* Handle selection of texts in multi-occurrence components better.
* "Inherit" sketch parameters when pasting using *Paste New*.
* New parameter values: `_.component`, `_.file`
* Storage format version 2, to handle the new selection engine.
* Only one Undo item for text updates (not applicable to document save).
* Show count of texts selected in each sketch.
* Option to run *Compute All* automatically, to force features to update.
* Detect missing *thomasa88lib* helper library.
* Quick buttons for prepending braces and appending common parameters.
* v 1.1.0
* `_.date` for retrieving document save date.
* Workaround for [Fusion 360™ bug](https://forums.autodesk.com/t5/fusion-360-api-and-scripts/cannot-select-shx-fonts-on-sketchtext-object/m-p/9606551) when using Autodesk® SHX fonts.
* Informative error when a text has a negative angle.
* Don't re-evaluate texts when the Change Parameters dialog is closed without any changes.
* Handle unit-less parameter values.
* v 1.0.1
* Fix error when using `_.version` in documents that have never been saved.
* Redesign logo to comply with app store.
* v 1.0.0
* Out of beta!
* v 0.2.1
* Set table height to 10 rows.
* Fix #1. Handle unsaved documents.
* v 0.2.0
* Basic support for Python format specifiers.
* *Insert braces* button.
* Selection tooltip, to show all selections when the text is truncated.
* Hide "select control". Integrate clear button into table.
* Use correct unit/scaling when showing parameter value.
* Quick reference in dialog.
* v 0.1.1
* Enable *Run on Startup* by default.
* v 0.1.0
* First beta release
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_build
venv
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 changes: 14 additions & 0 deletions docs/_static/home-logo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.icon-home::before {
display: inline-block;
content: "";
width: 32px;
height: 32px;
/* Using bitmap logo to always get correct rendering */
background: url(logo_32x32.png);
position: relative;
top: 10px;
}

.wy-side-nav-search .icon-home::before {
margin-left: -16px;
}
1 change: 1 addition & 0 deletions docs/_static/logo_32x32.png
14 changes: 14 additions & 0 deletions docs/_static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.kbd:not(.compound) {
padding: .2rem .4rem;
font-size: 87.5%;
border-radius: .2rem;
color: #212121;
background-color: #f2f2f2;
border: 1px solid #cbcbcb;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.2),inset 0 0 0 2px #fff;
}

.guilabel {
background-color: initial !important;
border-color: #888 !important;
}
1 change: 1 addition & 0 deletions docs/_static/video.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<iframe width="640" height="680" src="https://screencast.autodesk.com/Embed/Timeline/3d4a64a7-37b3-4551-83c4-a93a4d96bca7" frameborder="0" allowfullscreen webkitallowfullscreen></iframe>
11 changes: 11 additions & 0 deletions docs/_static/wrapping-tables.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* override table width restrictions */
.wy-table-responsive table td, .wy-table-responsive table th {
/* !important prevents the common CSS stylesheets from
overriding this as on RTD they are loaded after this stylesheet */
white-space: normal !important;
vertical-align: top !important;
}

.wy-table-responsive {
overflow: visible !important;
}
5 changes: 5 additions & 0 deletions docs/_templates/breadcrumbs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{%- extends "sphinx_rtd_theme/breadcrumbs.html" %}

{# Remove "View Page Source" top right link #}
{% block breadcrumbs_aside %}
{% endblock %}
22 changes: 22 additions & 0 deletions docs/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{%- extends "sphinx_rtd_theme/layout.html" %}

{% block navigation %}
{{ super() }}

<style>
.badge-item {
padding: .4045em 1.618em;
font-size: 90%;
margin-top: 25px;
line-height: 18px;
}
</style>

{# App store badge #}
<div class="badge-item">
<a href="https://apps.autodesk.com/FUSION/en/Detail/Index?id=2114937992453312456&amp;appLang=en&amp;os=Win64" target="_blank" title="Open in App store">
<img src="https://badgen.net/runkit/thomasa88/autodesk-rating-badge/branches/master/2114937992453312456">
</a>
</div>

{% endblock %}
15 changes: 15 additions & 0 deletions docs/about.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Author & License
================

Author
------

This add-in is created by Thomas Axelsson.

License
-------

This project is licensed under the terms of the MIT license.

.. literalinclude:: ../LICENSE
:language: none
8 changes: 8 additions & 0 deletions docs/addins.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
More Fusion 360™ Add-ins
========================

`My Fusion 360™ app store
page <https://apps.autodesk.com/en/Publisher/PublisherHomepage?ID=JLH9M8296BET>`__

`All my add-ins on
Github <https://github.com/topics/fusion-360?q=user%3Athomasa88>`__
Loading

0 comments on commit 2cb7e6f

Please sign in to comment.