Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Using inches and other units #7

Open
sahil48 opened this issue Jun 24, 2020 · 13 comments
Open

[feature] Using inches and other units #7

sahil48 opened this issue Jun 24, 2020 · 13 comments

Comments

@sahil48
Copy link

sahil48 commented Jun 24, 2020

Is there a way to set unit to inches?

@formatc1702
Copy link
Collaborator

I'd like to implement this in the future, but it's not a top priority right now.
The question is, what units would you accept as inputs, how are they stored internally (personally, I'd convert everything to meters internally) and what unit is used for BOM output?
I will keep it in mind.

@sahil48
Copy link
Author

sahil48 commented Jun 27, 2020

Internally, and as output, we do and would continue to use inches because our products are designed in customary units, and wires and the components they are routed with correspond better to one another when they use the same units. We design and manufacture our products in the US, and components from machine shops are not only less expensive, but more readily available in customary units. Even our existing automated wire cutter Programsis set up in inches.

The only time we use metric is when adding holes and screws for mounting motors or power supplies, which are usually in metric units. Area is less significant to me, so I wouldn’t mind leaving out area from the output when inches is used.

@kvid
Copy link
Collaborator

kvid commented Jun 27, 2020

I guess @formatc1702 is thinking about internally in his WireViz Python code, not internally in the users organization, and also input and output files related to this WireViz tool.

@sahil48
Copy link
Author

sahil48 commented Jun 27, 2020

Okay, that would make sense. In the source code, I would imagine metric would be easier to reason with.

@formatc1702
Copy link
Collaborator

I guess @formatc1702 is thinking about internally in his WireViz Python code, not internally in the users organization, and also input and output files related to this WireViz tool.

correct.

@chrisalbertson
Copy link

chrisalbertson commented Jun 27, 2020 via email

@aakatz3
Copy link
Contributor

aakatz3 commented Jun 27, 2020

In electronics, while I rarely see inches, I do constantly see mils (thousandths of an inch). While I haven't looked through all of the code extensively, I didn't see anywhere that the exact length of the wire matters right now. Maybe it could be kept unitless, and the unit suffix could be tacked on at the output stage? That's the nicest solution IMO, because it is the most portable, should one need to define custom units.

@kvid
Copy link
Collaborator

kvid commented Jun 27, 2020

I agree with @aakatz3 , but it requires that all cables of the same type use the same length unit to avoid any unit conversion calculations when calculating the total length of each cable type. I guess most users can live with that.

@chrisalbertson
Copy link

chrisalbertson commented Jun 27, 2020 via email

@njhurst
Copy link

njhurst commented Jun 28, 2020

Rounding is not a problem - we already round most numbers, as we use 0.1s of a mm which are not exactly representable. I don't think it is sensible to go down the multiunit pathway, that caused endless pain in inkscape with almost no return on investment. Instead, represent everything internally as mm, and convert at display time. Python's default float type is accurate to 1 part in 1000000000000000 or so.

Don't go unitless either, that way also lies madness, as you see with the random frustration when importing STLs or DXFs between tools. Stick to a real unit with a physical size and be clear about so that we avoid confusion. Honestly inches are mostly a convenience for humans, so we should leave them purely for rendering. (And remember that the inch is defined from the mm; you know, if we switched to 0.1microns we'd be able to represent mm and thous exactly).

@formatc1702 formatc1702 changed the title Can units be in inches? [feature] Using inches and other units Jun 28, 2020
@slightlynybbled
Copy link
Contributor

I have successfully utilized pint in the past for storing and reading units. If you are going to start saving units, pint is as good as anything.

Package is stable, maintained, and pure python.

@zombielinux
Copy link
Contributor

+1 for inches/feet. We use them ALL the time for our harnesses.

The BOM output already has a column for unit.

stevegt added a commit to stevegt/WireViz that referenced this issue Oct 5, 2020
- partial fix for wireviz#7
- based on and closes wireviz#161 and wireviz#162
kvid pushed a commit to kvid/WireViz that referenced this issue Oct 5, 2020
- partial fix for wireviz#7
- based on and closes wireviz#161 and wireviz#162
kvid pushed a commit to kvid/WireViz that referenced this issue Oct 5, 2020
- partial fix for wireviz#7
- based on and closes wireviz#161 and wireviz#162
kvid pushed a commit to kvid/WireViz that referenced this issue Nov 15, 2020
- partial fix for wireviz#7
- based on and closes wireviz#161 and wireviz#162
kvid pushed a commit to kvid/WireViz that referenced this issue Nov 16, 2020
- partial fix for wireviz#7
- based on and closes wireviz#161 and wireviz#162
@kvid kvid mentioned this issue Nov 16, 2020
formatc1702 added a commit that referenced this issue Nov 16, 2020
@formatc1702
Copy link
Collaborator

FYI, everyone interested: Support for custom units has been added to the dev branch in #196;
auto-parsing (length: 5 in yielding length: 5 and length_unit: in, analogous to how wire gauge works) will follow in #198 soon.

Be aware that units are treated purely as labels, no conversion has been implemented, and units need to match in order to be added together during BOM generation.
So if you have two identical wires, and specify one as length: 1 m and the other as length: 39.3 in, their lengths will not be added together in the BOM, and they will show up as separate items.

I will leave this issue open in case we decide to tackle actual unit conversion in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants