Convert Drawing Units

This forum is for 'Work-in-Progress' QCAD user developed script Add Ons and Plug-ins.

Please use this forum to request/submit your script Add-Ons & Plug-in idea's.

Moderators: andrew, Husky, J-J

riverbuoy
Senior Member
Posts: 107
Joined: Thu Oct 03, 2013 5:37 pm

Convert Drawing Units

Post by riverbuoy » Mon Dec 19, 2016 9:43 pm

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 4882 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
Attachments
ConvertUnit.zip
(6.58 KiB) Downloaded 108 times

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 2145
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Convert Drawing Units

Post by Husky » Tue Dec 20, 2016 12:14 am

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!
Work smart, not hard: QCad Pro

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 2145
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Convert Drawing Units

Post by Husky » Tue Dec 20, 2016 4:14 am

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.
Work smart, not hard: QCad Pro

riverbuoy
Senior Member
Posts: 107
Joined: Thu Oct 03, 2013 5:37 pm

Re: Convert Drawing Units

Post by riverbuoy » Tue Dec 20, 2016 4:55 pm

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
Attachments
ConvertUnit.js
(5.47 KiB) Downloaded 90 times

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 2145
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Convert Drawing Units

Post by Husky » Tue Dec 20, 2016 8:08 pm

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
Work smart, not hard: QCad Pro

User avatar
andrew
Site Admin
Posts: 5636
Joined: Fri Mar 30, 2007 6:07 am

Re: Convert Drawing Units

Post by andrew » Wed Dec 21, 2016 3:34 pm

I've added this to the Edit menu for the next release, thanks riverbuoy!

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

User avatar
andrew
Site Admin
Posts: 5636
Joined: Fri Mar 30, 2007 6:07 am

Re: Convert Drawing Units

Post by andrew » Wed Dec 21, 2016 4:11 pm

I've changed the icon a bit to avoid confusion with the tool to scale the drawing. Hope you don't mind.

riverbuoy
Senior Member
Posts: 107
Joined: Thu Oct 03, 2013 5:37 pm

Re: Convert Drawing Units

Post by riverbuoy » Wed Dec 21, 2016 5:13 pm

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
Attachments
ConvertUnit.js
(5.63 KiB) Downloaded 93 times

User avatar
andrew
Site Admin
Posts: 5636
Joined: Fri Mar 30, 2007 6:07 am

Re: Convert Drawing Units

Post by andrew » Wed Dec 21, 2016 6:57 pm

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

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 2145
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Convert Drawing Units

Post by Husky » Wed Dec 21, 2016 7:37 pm

riverbuoy wrote:Anyway, i am signing off for Christmas. Happy holidays to everyone. :D :D :D
Thanks riverbuoy. Happy holidays too! :D
Work smart, not hard: QCad Pro

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 2145
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Convert Drawing Units

Post by Husky » Wed Feb 15, 2017 8:45 am

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 4742 times
Husky-2017.02.14-08.png
Husky-2017.02.14-08.png (3.8 KiB) Viewed 4742 times
... the final click for the position is OK.
Work smart, not hard: QCad Pro

User avatar
andrew
Site Admin
Posts: 5636
Joined: Fri Mar 30, 2007 6:07 am

Re: Convert Drawing Units

Post by andrew » Wed Feb 15, 2017 8:47 am

Thanks for the report.
I cannot reproduce this behavior here.
Can you please attach your DXF file, thanks.

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 2145
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Convert Drawing Units

Post by Husky » Wed Feb 15, 2017 9:15 am

Sure, this is a mm to meter converted dxf
test cover dim.dxf
(99.79 KiB) Downloaded 83 times
Try a Horizontal Dim, click the first point and watch the preview. Maybe you have to zoom out ...
Work smart, not hard: QCad Pro

User avatar
andrew
Site Admin
Posts: 5636
Joined: Fri Mar 30, 2007 6:07 am

Re: Convert Drawing Units

Post by andrew » Wed Feb 15, 2017 9:32 am


User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 2145
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Convert Drawing Units

Post by Husky » Wed Feb 15, 2017 8:31 pm

Works beautiful - thank you very much! :D
Work smart, not hard: QCad Pro

Post Reply

Return to “QCAD 'Script Add-On & Plug-in challenge' - Work in Progress”