Count up counter for consecutive number labeling

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

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

Count up counter for consecutive number labeling

Post by Husky » Wed Oct 21, 2015 9:23 pm

Hello everybody ... :wink:

...I have again a feature request. :shock:

I find myself often in need to use consecutive numbers for any kind of labeling in my drawings. E.g. in drawings with flat pattern to keep track on the next step or for drawings with many detail views, scale views etc. etc. etc.
Husky-2015.10.04-02.png
Husky-2015.10.04-02.png (71.37 KiB) Viewed 10001 times
Husky-2015.10.21-01.png
Husky-2015.10.21-01.png (32.5 KiB) Viewed 10001 times
For this purpose I can use in QCAD the Text tool or the Block Attributes.

Husky-2015.10.04-04.png
Husky-2015.10.04-04.png (149.43 KiB) Viewed 10001 times



Both methods are working regarding this issue on the same way.

Example for the Text tool:
If I use the text tool I get an option bar which can be used to change the numbers.
What means:
Step 1: Open the text tool - set the formation for the text - type "1" for the first Number - OK - click in the drawing to determine the position for this number "1".
Step 2: For the next number (2) I can use the Option field to change the value - what means I have to place the mouse pointer in the value field (Step 3) - delete or overwrite the number with the keyboard keys to replace the "1" with a "2" (Step 3) - determine the position for this new number in the drawing (Step 4) and start over and over for the next 100 (?) numbers.
This over and over "manual number changing" is for me time consuming and distracting - I need to stay focused on my drawing and I think that should be much easier because ..... it's a computer program.

Long story short: My feature request is pretty simple: I would like to have a sort of automatically "Up counting Number" tool as a new tool or maybe even better as an option for an existing tool (Text / Block Attributes).
I think it should work like this:
1. Start the tool or activate an option
2. Tell the tool the first number
3. determine the position for the first number in the drawing
4. the tool counts automatically up to the next number and I can - without any distraction - determine the next number position in the drawing.
just like: Tool, Number, click click click click click click click click click click ...

The tool should be able to handle any initial given number. Start number 1 means the tool will use the 1 and starts further counting with 2, 3, 4, etc
Start number 14 leads to the next counted number 15, 16 , 17 etc
The tool should also have a remember function for the last used number.

Of course - it could be programmed with much more options/functions like up counting / down counting , counting with a fixed prefix/postfix, using numbers / letters (a,b,c,d ..), combination of those etc etc etc but right now I would be more than happy with a simple "automatically up counter function" solution.

If somebody is able/willing to help with this issue I would really appreciate it (and I'm sure not only me!). :D

If you have any questions or my request needs more clarification .... :wink:

Thank you in advance!
Work smart, not hard: QCad Pro

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

Re: Count up counter for consecutive number labeling

Post by riverbuoy » Fri Dec 04, 2015 7:14 pm

Hi Husky

I remember when drawing architectural plans I used to have to number all the rooms, doors and windows, and some other things also. This would have been easier with a tool like this, so I decided to have a go. I have called this tool 'Counter'. You can start it with the commands 'counter' or 'c12' in the command line, or use the shortcut 'c12'.
The tool has four options, 'Start', 'Incr.', 'Prefix' and 'Suffix'.
CounterOptions.png
CounterOptions.png (2.97 KiB) Viewed 9785 times
The 'Start' box contains the start number, the 'Incr.' box is the amount to add to the start number each time you click a position. This can be positive or negative, so you can count up or down. The 'Prefix' box contains text which will appear before the number, and the 'Suffix' box contains text which will appear after the number. When the tool starts you are prompted with 'Position'. You then pick a point for the text, and the start number is changed to the next number automatically. So you can click, as many times as you wish. When you exit, the command the tool remembers the contents of the boxes.
I decided to enter the numbers as text entities, rather than as a block. The text is added to the current layer.
Now you may wish to change the font, angle and height of the text. To do this, use the 'Text' tool to set the options for the text.
TextOptions.png
TextOptions.png (59.6 KiB) Viewed 9785 times
As you can see from the picture you can change the Angle, Alignment, Font, Height, Bold and Italic options. (Changing the other options will have no effect). You can use the shortcut 'TE' to start the text tool while in the counter command. When you press the 'OK' button the settings are saved to the configuration file, which this tool then uses those settings. When the text tool prompts you for a position, press the right mouse button or press the 'escape' key on the keyboard, to exit the command. You will then be back in the counter tool.
This tool only works with numbers, so it will not do sequences like a,b,c,d......

I have attached a zip file containing a directory named 'Counter'. Extract this directory and place it in the directory 'scripts/Misc/MiscDrawing'. I have placed it here because it is not a standard feature of cad programs that I have used (although you might like to argue that it should be). The menu entry is 'Misc->MiscDrawing->Counter'.

Husky, I hope this meets you requirements?

riverbuoy
Attachments
Counter.zip
(6.72 KiB) Downloaded 267 times

User avatar
J-J
Moderator
Posts: 398
Joined: Tue Mar 24, 2009 9:48 pm

Re: Count up counter for consecutive number labeling

Post by J-J » Fri Dec 04, 2015 11:09 pm

Hi Robert,

I tested your new counter feature, and I think it is great, very nice job :D

After playing with it I thought I'd rather have the icon in the modify tool bar as I keep it displayed all the time, so I tried to move the counter directory accordingly, but apparently the tool remains in the directory you suggested it should be in. Is that set in the script itself?

Thanks again for a useful addition.
JJ

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

Re: Count up counter for consecutive number labeling

Post by Husky » Sat Dec 05, 2015 7:34 am

J-J wrote:After playing with it I thought I'd rather have the icon in the modify tool bar as I keep it displayed all the time, so I tried to move the counter directory accordingly, but apparently the tool remains in the directory you suggested it should be in. Is that set in the script itself?
Hi J-J,

whats about to display an extra Toolbar "Misc Draw" and put it next to your Modify Toolbar?
Husky-2015.12.04-01.png
Husky-2015.12.04-01.png (31.23 KiB) Viewed 9757 times
Work smart, not hard: QCad Pro

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

Re: Count up counter for consecutive number labeling

Post by Husky » Sat Dec 05, 2015 8:04 am

Hello riverbuoy,
riverbuoy wrote:Husky, I hope this meets you requirements?
Yes, absolutely - it serves everything what I need. Thank you so much for spending your time and knowhow on this. I really appreciate that!

I tested your Counter and I'm more than happy with the functionality. It will make my CAD Life much easier and I'm able to stay focused on the important things in my drawings. :wink:



But, one little thing attracted my attention: :shock:
If I put a (e.g.) 2.1 in the "Start" box and need to have a 0.1 in the 'Incr.' box to get at the next click a 2.2 the Counter will spit out an unexpected number with the third click ...
Husky-2015.12.04-02.png
Husky-2015.12.04-02.png (2.64 KiB) Viewed 9757 times
Could that be fixed?
Work smart, not hard: QCad Pro

User avatar
J-J
Moderator
Posts: 398
Joined: Tue Mar 24, 2009 9:48 pm

Re: Count up counter for consecutive number labeling

Post by J-J » Sat Dec 05, 2015 9:45 am

Hi Husky,
whats about to display an extra Toolbar "Misc Draw" and put it next to your Modify Toolbar?
That's what I did at first, but since I do not need the other tools that often, I thought it would be smarter just to have my "personalized" tool bar (I do that in Excel).
No big deal anyway, I have a large screen and I can afford a small extra bar!
I tried also the decimal incrementation, it is the start number that becomes polluted after 3 steps.

Nice work
JJ

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

Re: Count up counter for consecutive number labeling

Post by Husky » Sat Dec 05, 2015 10:00 am

J-J wrote:That's what I did at first, but since I do not need the other tools that often ...
Me too! I've just disabled all "unwanted" tools and have never to deal with them again on the screen - until I change my mind ... :wink:
Husky-2015.12.05-03.png
Husky-2015.12.05-03.png (62.86 KiB) Viewed 9752 times
Work smart, not hard: QCad Pro

User avatar
J-J
Moderator
Posts: 398
Joined: Tue Mar 24, 2009 9:48 pm

Re: Count up counter for consecutive number labeling

Post by J-J » Sat Dec 05, 2015 10:12 am

Hy Husky,
I've just disabled all "unwanted" tools
Good point, I forgot about that :oops:
JJ

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

Re: Count up counter for consecutive number labeling

Post by riverbuoy » Sat Dec 05, 2015 8:19 pm

Hi guys,
Husky wrote: the Counter will spit out an unexpected number with the third click ...
Oops! I didn't catch that. :oops:

I have now hopefully fixed this, and have attached the file 'Counter.js' which contains the fix. Replace the existing file with this one. If you have 'Show trailing zeroes' set in 'Edit->Drawing Preferences -> Dimension->Dimension Settings' then you will see the start number with the number of zeroes set in precision; i.e. 1.1000 for a precision of 4. If trailing zeroes is not set, then it will show only 1.1.

While I was at it, I also changed the alignment of the start and increment boxes to align right, which is more usual for numbers. I also changed the alignment of the Prefix box to align right, but left the Suffix box to align left. Because the Prefix string comes first, I thought it looks better aligned to the right. The attached file 'Counter.ui' contains this change. Replace the existing file with this one if you want this change.

riverbuoy
Attachments
Counter.js
(3.92 KiB) Downloaded 218 times
Counter.ui
(3.09 KiB) Downloaded 229 times

User avatar
J-J
Moderator
Posts: 398
Joined: Tue Mar 24, 2009 9:48 pm

Re: Count up counter for consecutive number labeling

Post by J-J » Sat Dec 05, 2015 10:06 pm

perfect made better, works fine thanks
JJ

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

Re: Count up counter for consecutive number labeling

Post by Husky » Sun Dec 06, 2015 9:15 am

@riverbuoy - I love this new tool!

Works like a charm! :D
Husky-2015.12.05-03.png
Husky-2015.12.05-03.png (7 KiB) Viewed 9718 times
But I'm still facing problems with crazy numbers - maybe the tool should be limited to reasonable terms, I don't know ... :oops:

Start: 1.34 / Incr: 0.001
Husky-2015.12.05-04.png
Husky-2015.12.05-04.png (52.12 KiB) Viewed 9718 times
However - one more question: If I need to have a numerical series like this ...
Husky-2015.12.06-05.png
Husky-2015.12.06-05.png (6.79 KiB) Viewed 9718 times

... do I have the power to tell the tool that I need to have the 2 and the 3 displayed with the zeros? Therefore 2.0 and 3.0 instead of 2 and 3. I played around with the Dimension Settings but without any luck ...
Work smart, not hard: QCad Pro

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

Re: Count up counter for consecutive number labeling

Post by riverbuoy » Sun Dec 06, 2015 10:52 pm

Hi Husky,
Husky wrote:But I'm still facing problems with crazy numbers
I tried this on my computer, and it worked fine. On further investigation this appears to be a problem of precision. I set my precision from 4 to 2 decimal places, and I got the same crazy numbers as you. If you are using an increment of 0.001 you need to set the precision to at least 3 decimal places. So go to 'Edit->Drawing Preferences -> Dimension->Dimension Settings' and set a suitable precision. I keep mine set to 4 decimal places for linear dimensions and 2 decimal places for angular dimensions. Give this a go and let me know if this fixes it.
Husky wrote:... do I have the power to tell the tool that I need to have the 2 and the 3 displayed with the zeros?
This is a fairly simple tool, which could become more complex by adding lots of different options for all sorts of situations. So you could end up continually adding more and more options. I would suggest instead, that when the number is 2, set the suffix box to ".0", and then clear it for the next number. I realise this could become tedious if you have a lot of numbers to enter, but for the moment it is the best I can suggest. Alternatively, you could set the prefix to "2." and set start number to 0, with an increment of 2. When you reach 3, you would need to set the start number back to 0, and the prefix to "3.".

Hope this helps.

riverbuoy

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

Re: Count up counter for consecutive number labeling

Post by Husky » Mon Dec 07, 2015 9:22 am

riverbuoy wrote:This is a fairly simple tool, which could become more complex by adding lots of different options for all sorts of situations. So you could end up continually adding more and more options. I would suggest instead, that when the number is 2, set the suffix box to ".0", and then clear it for the next number. I realise this could become tedious if you have a lot of numbers to enter, but for the moment it is the best I can suggest. Alternatively, you could set the prefix to "2." and set start number to 0, with an increment of 2. When you reach 3, you would need to set the start number back to 0, and the prefix to "3.".

Hope this helps.

riverbuoy
Hi riverbuoy,

yes - you are absolutely right and I'm more than happy to have finally a counter tool which suits perfectly my needs.

Thank you so much!

Husky



@Andrew
Would it be possible to have this new Counter tool permanently implemented in the QCAD "Misc" directory? I would really appreciate it. :wink:
Work smart, not hard: QCad Pro

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

Re: Count up counter for consecutive number labeling

Post by riverbuoy » Mon Dec 07, 2015 11:44 am

Hi Husky,

I have made a very small change to this tool, so now if you switch on 'Show trailing zeroes' and set the precision to 1 you will see a zero at the end of a number:-
1.0, 1.2, 1.4 ... 1.8, 2.0, 2.2 ... 2.8, 3.0 ...
For more decimal places set the precision to the number of decimal places required, and switch on 'Show trailing zeroes'. So for your example 1.34 set the precision to 3:-
1.340, 1.341, 1.342 ... 1.350, 1.351 ... 1.360 ...
Note: If you have existing dimensions in the drawing, they will change to reflect the current precision and 'Show trailing zeroes', so remember to change the precision and trailing zeroes back to their original values when you are finished.

I have attached the file 'Counter.js'. Replace the existing file with this one.

riverbuoy
Attachments
Counter.js
(4.01 KiB) Downloaded 212 times

TSG
Premier Member
Posts: 188
Joined: Thu Oct 08, 2015 9:39 am
Location: Germany, Lower Saxony

Re: Count up counter for consecutive number labeling

Post by TSG » Mon Dec 07, 2015 12:54 pm

Hi riverbuoy,

thanks a lot for this fantastic enhancement.

greets Thomas

Post Reply

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