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.


I gave ruby a try
Read 3470 times
* July 15, 2011, 07:05:52 PM
Hello
I gave ruby a try. Spend some hours and come to the end - I´m longing for my good old vba.
Its completely different to vb(a) and the IMSI-documentation is very low. It seems to be very powerful. In the near future I will stay with vb6 and autoit.
But my efforts have one good result. Starting my vb- and autoit-.exe is  comfortable with ruby.
(see contribution)
http://forums.turbocad.com/index.php/topic,6797.0.html
best regards
Bernd
« Last Edit: July 22, 2011, 01:06:40 AM by ibruethsch »

Logged


July 16, 2011, 01:35:59 PM
#1
Hello
I gave ruby a try. Spend some hours and come to the end - I´m longing for ma good old vba.
Its completely different too vb(a) and the IMSI-documentation is very low. Its seems to be very powerful. In the near future I will stay with vb6 and autoit.
But my efforts have one good result. Starting my vb.exe is more comfortable.
(see contribution)
http://forums.turbocad.com/index.php/topic,6797.0.html
best regards
Bernd


I agree, the documentation needs to be improved. The feature will much more successful if users aren't required to trial and error their way through it.

Logged
BradE [ dean3Design ]
Core i7-3930K CPU @ 4.20GHz, 32GB 1333 DDR3, FirePro V5900
TC 21 Platinum (64-Bit) Running on Win7 Pro SP1


* February 05, 2012, 04:22:52 PM
#2
I gave RUBY a second chance.
The performance is very quick.
For the speedtest I use a drawing with 10000 lines, and the color is changed one after the other. (the 10000 red lines have to be selected)

RUBY
------------------------------------------------
require "Sketchup"


def geschw_test
  ents = Sketchup.active_model.entities
  sel = Sketchup.active_model.selection
count = sel.count
i=0
for i in (0..count-1)              # achtung for i in und ende mit end

gr=sel

sel.material = Color.new("Green") if sel.tc_object().color.to_s == "Color(255, 0, 0, 255)"   
 
end

end
----------------------------------------------------
The whole stuff in \RubyEngine seems to be nessecare to adapt the TC-Objectmodel to the Sketup-objectmodel.
The Syntax in Ruby is different

With Win32ole I could realise a connection fom the Rubyconsole within TC to Excel.
-------------------------------------------
require 'win32ole'
def test_excel
# aus Rubyconsole Werte in Excel schreiben
# Excel muß laufen
# http://ruby-doc.org/stdlib-1.9.3/libdoc/win32ole/rdoc/WIN32OLE.html
  excel = WIN32OLE.connect('Excel.Application')
  excel.visible = true
  workbook = excel.Workbooks.Add();
  worksheet = workbook.Worksheets(1);
  worksheet.Range("A1:D1").value = ["North","South","East","West"];
  worksheet.Range("A2:B2").value = [5.2, 10];
  worksheet.Range("C2").value = 8;
  worksheet.Range("D2").value = 20;

  range = worksheet.Range("A1:D2");
  range.select
  chart = workbook.Charts.Add;

  #workbook.saved = true;

  #excel.ActiveWorkbook.Close(0);
  #excel.Quit();

end
------------------------------------------------------------

Trying to do the same with TC was not successful:
-----------------
require 'win32ole'
def test_TC
# aus Rubyconsole Linie in TC zeichnen
# TC muß laufen

TC = WIN32OLE.connect('TurboCAD.Application')
-------------------------------------------
don´t work
 
best regards
Bernd

remark:
the Syntax is sel....  but the brackets don´t appear
again
sel & rectanglebracket & i & rectangelbracket ….

« Last Edit: February 06, 2012, 12:07:13 PM by ibruethsch »

Logged


February 12, 2012, 07:19:17 AM
#3

Hi,

I too, tried looking at Ruby, but decided it required too much time.  I prefer the pascal, and basic-flavoured languages.

However, you might like to try this book, which should prove a useful introduction . . .

http://www.sapphiresteel.com/IMG/pdf/LittleBookOfRuby.pdf

Regards Tim

Logged
You can design without engineering, but you cannot engineer without design.
Testing/using with Win 10 and various TurboCAD 64-bit versions.