Page 1 of 2

Convert Drawing Units

Posted: Mon Dec 19, 2016 9:43 pm
by riverbuoy
Hi,

I have read Husky's chat about the new 'Convert To Inch' tool. Looking at the script, Andrew has written it in such a way that it can be used to convert between any units. Therefore I have altered it to do just that.
ConvertUnits.png
ConvertUnits.png (4.34 KiB) Viewed 25063 times
As you can see, I have added two drop-down combo boxes, and a convert button, to the options toolbar. When the tool starts it reads the current drawing units and set the 'From' unit box to that value (in this case Millimeter). The 'To' unit box is set to None. Simply set the units you wish to use and click the convert button.

I have attached a zip file containing a directory called 'ConvertUnit'. Unzip it and put it in the 'scripts/Misc/MiscModify' directory. You will find the command in the menu 'Misc->Modify->Convert Drawing Units'. The two letter shortcut is 'CU'.

I have done some testing of this and it appears to work correctly.

Note: This will only work with version 3.16.0 and above

Perhaps you could let me know what you think (and perhaps do some rigorous testing).

Thanks

riverbuoy

Re: Convert Drawing Units

Posted: Tue Dec 20, 2016 12:14 am
by Husky
Year ............ that is what I'm looking for! :D

I tested this nice little tool a bit and here are my first thoughts: e_surprised
Let me start with a question. Your tool is able to read (nice!) the actual used drawing unit - for what do I need a drop-down field to change the "From" unit?

Ok, the tool works great for new drawings and never closed drawing. Scale for Entities , text, Dim looks absolute ok. A couple test back and forth .... no problems so far!

Then I figured out that the dim scaling isn't anymore proper working after closing and reloading the drawing. What basically means for all stored drawings. I haven't noticed that before but Andrews tool (Convert Drawing to inch) has the same problem and one of the nieces and biggest benefits of a tool like this one is the overall scaling function for everything (incl. text and dims) in a drawing and in already existing drawings.

The undo function works what is important in my opinion but the Zoom Focus is way of after using undo. Yes - that is more or less cosmetic but it would be nice to have the same view on my drawing like before ...

I have to go ............................ playing around with a new tool! :D :D :D

Thanks riverbuoy for looking into this!

Re: Convert Drawing Units

Posted: Tue Dec 20, 2016 4:14 am
by Husky
One additional note:

The unit "None" is often used in CAD drawings - they declare the used unit as text info in that drawing.

If I use this new tool to convert from inch to mm then it will also change the info in Drawing Preferences / General / Drawing Unit into mm. Perfect! The same with all other units ... except "None".

If I "convert" a "None" drawing to mm then the unit will not be changed below Drawing Preferences. I think mathematically correct but now this drawing has a named unit and I think it should be changed below Drawing Preferences to mm. QCad will use this info (if I'm correct???) to convert Library items and the content in the clipboard to insert / copy/past them into a drawing with a different target unit.

Re: Convert Drawing Units

Posted: Tue Dec 20, 2016 4:55 pm
by riverbuoy
Hi Husky,

Thanks for your testing and feedback.
Husky wrote:Let me start with a question. Your tool is able to read (nice!) the actual used drawing unit - for what do I need a drop-down field to change the "From" unit?
Good question. I can't think of a single reason why you would need to change the 'From' unit, but, experience tells me that someone might have a use for this, or they may just want to do something daft. :D
Anyway, something at the back of my head is telling me not to change this. :?
Husky wrote:Then I figured out that the dim scaling isn't anymore proper working after closing and reloading the drawing. What basically means for all stored drawings. I haven't noticed that before but Andrews tool (Convert Drawing to inch) has the same problem and one of the nieces and biggest benefits of a tool like this one is the overall scaling function for everything (incl. text and dims) in a drawing and in already existing drawings.
You are correct. The scale factor for dimension text is not being adjusted once the drawing has been saved. I have changed this so that the scale is adjusted correctly. I have attached the changed file (ConvertUnit.js). Replace the existing file in 'scripts/Misc/MiscModify/ConvertUnit'.
Husky wrote:The undo function works what is important in my opinion but the Zoom Focus is way of after using undo. Yes - that is more or less cosmetic but it would be nice to have the same view on my drawing like before ...
When you convert the units, the tool automatically adjusts the view, but 'Undo' does not. What I would suggest is you use the menu option 'View->Zoom->Previous zoom' (shortcut 'ZV').
Husky wrote:The unit "None" is often used in CAD drawings - they declare the used unit as text info in that drawing.
If either unit is 'None', then this tool does not do anything, as it (meaning me) doesn't know what to do. :roll:

I hope this explains everything.

Regards

riverbuoy

Re: Convert Drawing Units

Posted: Tue Dec 20, 2016 8:08 pm
by Husky
riverbuoy wrote:I hope this explains everything.
Yes it does and I (we?) have to thank you again!!!! :D :D :D

Happy Holidays! :wink:

Husky

Re: Convert Drawing Units

Posted: Wed Dec 21, 2016 3:34 pm
by andrew
I've added this to the Edit menu for the next release, thanks riverbuoy!

https://github.com/qcad/qcad/tree/maste ... onvertUnit

Re: Convert Drawing Units

Posted: Wed Dec 21, 2016 4:11 pm
by andrew
I've changed the icon a bit to avoid confusion with the tool to scale the drawing. Hope you don't mind.

Re: Convert Drawing Units

Posted: Wed Dec 21, 2016 5:13 pm
by riverbuoy
Hi,

I have discovered a weird bug. I am using the tool matrix, rather than the standard toolbar, and after clicking the convert button, the focus is set to the filter box at the top of the tool matrix. Therefore I have changed it so that the tool changes the focus to the drawing just before terminating.

Secondly, there is just an outside chance that the dimension text might be scaled twice. This is because of the order in which I have done things, so I have changed the order to avoid this.

I have attached the changed file (ConvertUnit.js). Replace the existing file in 'scripts/Misc/MiscModify/ConvertUnit'.
andrew wrote:I've changed the icon a bit to avoid confusion with the tool to scale the drawing. Hope you don't mind.
Hi Andrew. I don't mind a bit. Designing icons has never been my strongest suit, and you have come up with a much better icon.

Anyway, i am signing off for Christmas. Happy holidays to everyone. :D :D :D

Regards

riverbuoy

Re: Convert Drawing Units

Posted: Wed Dec 21, 2016 6:57 pm
by andrew
OK, thanks for the update. I've merged the changes:
https://github.com/qcad/qcad/tree/maste ... onvertUnit

You too have a great time off! Merry Christmas! :D

Re: Convert Drawing Units

Posted: Wed Dec 21, 2016 7:37 pm
by Husky
riverbuoy wrote:Anyway, i am signing off for Christmas. Happy holidays to everyone. :D :D :D
Thanks riverbuoy. Happy holidays too! :D

Re: Convert Drawing Units

Posted: Wed Feb 15, 2017 8:45 am
by Husky
Hi Guys,

I noticed a weird behavior after converting the unit to a "bigger" unit like mm to meter. The preview of the Extension Iine is way of. Is that fixable?

Dim on the same rectangle before and after converting from mm to meter ...
Husky-2017.02.14-07.png
Husky-2017.02.14-07.png (6.2 KiB) Viewed 24924 times
Husky-2017.02.14-08.png
Husky-2017.02.14-08.png (3.8 KiB) Viewed 24924 times
... the final click for the position is OK.

Re: Convert Drawing Units

Posted: Wed Feb 15, 2017 8:47 am
by andrew
Thanks for the report.
I cannot reproduce this behavior here.
Can you please attach your DXF file, thanks.

Re: Convert Drawing Units

Posted: Wed Feb 15, 2017 9:15 am
by Husky
Sure, this is a mm to meter converted dxf
test cover dim.dxf
(99.79 KiB) Downloaded 800 times
Try a Horizontal Dim, click the first point and watch the preview. Maybe you have to zoom out ...

Re: Convert Drawing Units

Posted: Wed Feb 15, 2017 9:32 am
by andrew

Re: Convert Drawing Units

Posted: Wed Feb 15, 2017 8:31 pm
by Husky
Works beautiful - thank you very much! :D