News:

When replying to a specific statement be sure to quote the previous post.

Main Menu

Saving file with date and time stamp

Started by Orion20036, August 13, 2011, 10:17:38 PM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Orion20036

I am hoping that Ruby takes off when we get a bit more information on syntax used, and some good examples to get us started. What I am after may also be possible in vbs as well.

I would like to be able to save a file with the date and time appended to the file name, so the the script would have to use the "time.now" function in Ruby, turn it into a text string, and finally append it to the file name being saved.

When the file with the added information is opened , the Ruby script needs to look for the added date stamp information from the file name, remove it and add the new appended date stamp before saving again.

This script would be a good starter and  very useful for most of us who have multiple versions of a drawing.

Is there anybody with enough grasp of Ruby to get us started??.


I have noticed, after running a script that the del  button on the keyboard will not work until you close Turbocad and restart.

Marek

#1
Hi
I wrote it for Dcad, but I think it can works for Tcad like others scripts(I have only TCPro 15 and I could't check it)
May be anyone tell something  to eliminate some problems
I tried to do it with Ruby script and wrote 3 scripts
-stamp1 - gives stamp but only in coordinates x=0, y=0 (we need to move stamp in desired place, or perhaps we need edit and set height font)
-stamp1v2 - gives stamp, we can set x coord, y coord (perhaps we need to edit and set height font)- may be it  doesn't works for ver TC18(problems with Ruby UI for TC)
- stamp1v3 - gives stamp, we have to use Ruby console and  in command line of console call def " ts3(x,y)" - x,y coordinates where we want to place stamp (perhaps we need to edit and set height font)
My problems
-without Dcad/Tcad Ruby documentation I tried to help with Google Sketchup Ruby API, but this gives little
- it seems that  many features and tools can not be yet used in DCAD

I could not determine
- how to set text properties
-how to get coordinates ie center of screen (I would like  to have possibility insert stamp in current area of drawing ( like in pasting)
-how to point with mouse where I want to place stamp
-how to move stamp to created layer ( layer I can create)
Marek

TC Pro 2016, TC Pro 2018, TC Plat 2019,TC Plat 2020,TC Plat 2021,TC Plat 2022,TC Plat 2023,TC Plat 2024, TC Plat 2025
Laptop Asus i7 6500U, dual-core 2,50GHz, NVIDIA GeForce GTX 950M, RAM 12 GB, SSD 480GB
Windows 10 64 bit

Marek

#2
Here is the corrected time stamp. We need to set the approximate coordinates point,  where we want to paste text (later we can move it to another location). I added a line with a possibility to enter your own comments. You can paste the file to the directory .... \ IMSIDesign \ TCWP18 \ Program \ RubyScripts. The first time use in  menu "Scripts / Toggle Ruby Console / Load "- show the place where the script is located. For the next time it should be visible in " Scripts/Ruby/time_stamp2". Clicking here should open a dialog box. At first,  file have to be unzipped .
Marek



Attachment removed. I attach corrected script below. I removed the unnecessary spaces, causing  warnings about spaces in the comments  in Ruby console.
Marek

TC Pro 2016, TC Pro 2018, TC Plat 2019,TC Plat 2020,TC Plat 2021,TC Plat 2022,TC Plat 2023,TC Plat 2024, TC Plat 2025
Laptop Asus i7 6500U, dual-core 2,50GHz, NVIDIA GeForce GTX 950M, RAM 12 GB, SSD 480GB
Windows 10 64 bit

John R

#3
It doesn't seem to work in either V18 or V19. I get the errors below when used in V18 Platinum. I get the same errors if I place the RB file in the RubyScripts folder.

C:\Users\John R\Downloads\stamp1v2a.rb:20: warning: don't put space before argument parentheses
C:\Users\John R\Downloads\stamp1v2a.rb:24: warning: don't put space before argument parentheses
C:\Users\John R\Downloads\stamp1v2a.rb:25: warning: don't put space before argument parentheses
true


Another thing to consider, V18 and V19 use different Ruby software. I believe you can't use code that works in V18 in V19.
John R.

V17—V21, 2015—2025
Designer, Deluxe, (Basic, Expert, Professional), Platinum
RedSDK enabled
Windows 11 Pro (25H2), 64-bit

Marek

#4
Thanks John.
I did not pay attention to it, because I tested some other scripts and it was a lot of comments, and  this script worked. I removed the unnecessary spaces. I ran the script on TCadPro 18.2 and DCAD Pro 3 (Windows 7 64 bit) and it works .
The script can also be run by typing in  editing box  Ruby Console  - ts2 -  and using"enter". Decimal separator is a dot.
Marek
Marek

TC Pro 2016, TC Pro 2018, TC Plat 2019,TC Plat 2020,TC Plat 2021,TC Plat 2022,TC Plat 2023,TC Plat 2024, TC Plat 2025
Laptop Asus i7 6500U, dual-core 2,50GHz, NVIDIA GeForce GTX 950M, RAM 12 GB, SSD 480GB
Windows 10 64 bit

John R

OK, this one works in V18. The text comes in with a 5 inch height, but I don't see any specification for that in the code. I kind of assumed it would insert text at the current size of 0.25 inch. It also wouldn't work until I placed a copy in the RubyScripts folder.

I tried it in V19 and got this: uninitialized constant TC_API::TC_StringArray::Defaults
I have no clue as to what that means.
John R.

V17—V21, 2015—2025
Designer, Deluxe, (Basic, Expert, Professional), Platinum
RedSDK enabled
Windows 11 Pro (25H2), 64-bit

Marek

Also, I have no clue. I have tried in many ways to initialize arrays, but each time the message was the same as with you, or that it is wrong argument list.
Marek

TC Pro 2016, TC Pro 2018, TC Plat 2019,TC Plat 2020,TC Plat 2021,TC Plat 2022,TC Plat 2023,TC Plat 2024, TC Plat 2025
Laptop Asus i7 6500U, dual-core 2,50GHz, NVIDIA GeForce GTX 950M, RAM 12 GB, SSD 480GB
Windows 10 64 bit