TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
The purpose of these forums is to discuss TurboCAD.  Please keep the discussion of other products to compatibility issues or how the other software’s can be used with TurboCAD.


Saving file with date and time stamp
Read 4138 times
* August 13, 2011, 10:17:38 PM
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.
« Last Edit: August 13, 2011, 10:20:33 PM by Michael Geraghty »

Logged


* August 28, 2011, 11:06:33 AM
#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)
« Last Edit: August 28, 2011, 11:09:09 AM by Marek »

Logged
Marek

TurboCAD Pro 2016, TurboCAD Pro 2017
Laptop Asus i7 6500U, dual-core 2,50GHz, NVIDIA GeForce GTX 950M, RAM 12 GB, SSD 480GB
Windows 10 64 bit


* September 03, 2012, 11:19:45 AM
#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.
« Last Edit: September 06, 2012, 09:03:58 AM by Marek »

Logged
Marek

TurboCAD Pro 2016, TurboCAD Pro 2017
Laptop Asus i7 6500U, dual-core 2,50GHz, NVIDIA GeForce GTX 950M, RAM 12 GB, SSD 480GB
Windows 10 64 bit


* September 05, 2012, 11:18:50 PM
#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.
« Last Edit: September 05, 2012, 11:23:08 PM by John R »

Logged
John R.

V17—V21, 2015, 2016, 2017
Designer, Deluxe, Basic, Platinum
RedSDK enabled
Windows 10, 64-bit


* September 06, 2012, 05:28:27 AM
#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
« Last Edit: September 06, 2012, 07:12:39 AM by Marek »

Logged
Marek

TurboCAD Pro 2016, TurboCAD Pro 2017
Laptop Asus i7 6500U, dual-core 2,50GHz, NVIDIA GeForce GTX 950M, RAM 12 GB, SSD 480GB
Windows 10 64 bit


* September 06, 2012, 10:31:42 AM
#5
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.

Logged
John R.

V17—V21, 2015, 2016, 2017
Designer, Deluxe, Basic, Platinum
RedSDK enabled
Windows 10, 64-bit


* September 06, 2012, 01:20:38 PM
#6
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.

Logged
Marek

TurboCAD Pro 2016, TurboCAD Pro 2017
Laptop Asus i7 6500U, dual-core 2,50GHz, NVIDIA GeForce GTX 950M, RAM 12 GB, SSD 480GB
Windows 10 64 bit