News:

All posts discussing pricing or where to buy TurboCAD will be deleted.

Main Menu

I gave ruby a try

Started by ibruethsch, July 15, 2011, 07:05:52 PM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

ibruethsch

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

Brad Easterday

Quote from: ibruethsch on 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 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.
Brad E.
TC 2022, 2023 Platinum
Windows 11 (64-Bit)

ibruethsch

#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 ….


Tim Stewart


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
Regards Tim

You can design without engineering, but you cannot engineer without design.
Windows 10 Pro (19043.1165) 64-bit, TurboCAD Designer 2017-2020 and Pro. Plat. 2018-2020 + LW (64-bit) + AnimationLab 6
Intel i5 2500@3.3GHz 8GB Ram NVIDIA Quadro K2200