Module: TT

Defined in:
TT_Lib2/core.rb,
cext/tt_lib2/tt_lib2/src/extension.cpp,
TT_Lib2/debug.rb,
TT_Lib2/win32_shim.rb,
TT_Lib2/c_extension_manager.rb

Overview


Thomas Thomassen thomas[at]thomthomnet


Defined Under Namespace

Modules: Arc, Attributes, Bezier, Binary, BooleanAttributes, Bounds, Color, Cursor, Definition, Edge, Edges, Entities, Face, Faces, GUI, Geom3d, Gizmo, Image, Instance, Javascript, Length, Lib, Locale, Material, MetaClass, Model, Plugins, Point3d, Point3d_Ex, Selection, SketchUp, System, UVQ, Win32 Classes: Babelfish, CExtensionManager, Debug, DeferredEvent, Dimension, DrawCache, GL_Image, JSON, Profiler, Progressbar, Ray, Settings, SimpleTask, UV_Plane, Version, WebDialogPatch

Constant Summary

CEXT_VERSION =

The build version of the TT_Lib binary library.

GetVALUE("1.1.0")
BB_LEFT_FRONT_BOTTOM =

BoundingBox Constants

Since:

  • 2.0.0

0
BB_RIGHT_FRONT_BOTTOM =

Since:

  • 2.0.0

1
BB_LEFT_BACK_BOTTOM =

Since:

  • 2.0.0

2
BB_RIGHT_BACK_BOTTOM =

Since:

  • 2.0.0

3
BB_LEFT_FRONT_TOP =

Since:

  • 2.0.0

4
BB_RIGHT_FRONT_TOP =

Since:

  • 2.0.0

5
BB_LEFT_BACK_TOP =

Since:

  • 2.0.0

6
BB_RIGHT_BACK_TOP =

Since:

  • 2.0.0

7
BB_CENTER_FRONT_BOTTOM =

Since:

  • 2.0.0

8
BB_CENTER_BACK_BOTTOM =

Since:

  • 2.0.0

9
BB_CENTER_FRONT_TOP =

Since:

  • 2.0.0

10
BB_CENTER_BACK_TOP =

Since:

  • 2.0.0

11
BB_LEFT_CENTER_BOTTOM =

Since:

  • 2.0.0

12
BB_LEFT_CENTER_TOP =

Since:

  • 2.0.0

13
BB_RIGHT_CENTER_BOTTOM =

Since:

  • 2.0.0

14
BB_RIGHT_CENTER_TOP =

Since:

  • 2.0.0

15
BB_LEFT_FRONT_CENTER =

Since:

  • 2.0.0

16
BB_RIGHT_FRONT_CENTER =

Since:

  • 2.0.0

17
BB_LEFT_BACK_CENTER =

Since:

  • 2.0.0

18
BB_RIGHT_BACK_CENTER =

Since:

  • 2.0.0

19
BB_LEFT_CENTER_CENTER =

Since:

  • 2.0.0

20
BB_RIGHT_CENTER_CENTER =

Since:

  • 2.0.0

21
BB_CENTER_FRONT_CENTER =

Since:

  • 2.0.0

22
BB_CENTER_BACK_CENTER =

Since:

  • 2.0.0

23
BB_CENTER_CENTER_TOP =

Since:

  • 2.0.0

24
BB_CENTER_CENTER_BOTTOM =

Since:

  • 2.0.0

25
BB_CENTER_CENTER_CENTER =

Since:

  • 2.0.0

26
BB_CENTER =

Since:

  • 2.0.0

26
MB_ICONHAND =

UI.messagebox Constants

Since:

  • 2.4.0

0x00000010
MB_ICONSTOP =

Since:

  • 2.0.0

0x00000010
MB_ICONERROR =

Since:

  • 2.0.0

0x00000010
MB_ICONQUESTION =

Since:

  • 2.0.0

0x00000020
MB_ICONEXCLAMATION =

Since:

  • 2.0.0

0x00000030
MB_ICONWARNING =

Since:

  • 2.0.0

0x00000030
MB_ICONASTERISK =

Since:

  • 2.0.0

0x00000040
MB_ICONINFORMATION =

Since:

  • 2.0.0

0x00000040
MB_ICON_NONE =

Since:

  • 2.0.0

80
MB_DEFBUTTON1 =

Since:

  • 2.0.0

0x00000000
MB_DEFBUTTON2 =

Since:

  • 2.0.0

0x00000100
MB_DEFBUTTON3 =

Since:

  • 2.0.0

0x00000200
MB_DEFBUTTON4 =

Since:

  • 2.0.0

0x00000300
MESH_SHARP =

PolygonMesh

Since:

  • 2.5.0

0
MESH_SOFT =

Since:

  • 2.0.0

4
MESH_SMOOTH =

Since:

  • 2.0.0

8
MESH_SOFT_SMOOTH =

Since:

  • 2.0.0

12
POINT_OPEN_SQUARE =

view.draw_points

Since:

  • 2.5.0

1
POINT_FILLED_SQUARE =

Since:

  • 2.0.0

2
POINT_CROSS =

Since:

  • 2.0.0

3
POINT_X =

Since:

  • 2.0.0

4
POINT_STAR =

Since:

  • 2.0.0

5
POINT_OPEN_TRIANGLE =

Since:

  • 2.0.0

6
POINT_FILLED_TRIANGLE =

Since:

  • 2.0.0

7

Class Method Summary collapse

Class Method Details

.array_to_hash(array) ⇒ Hash

Parameters:

  • array (Array)

Returns:

  • (Hash)

Since:

  • 2.6.0



475
476
477
478
479
480
481
# File 'TT_Lib2/core.rb', line 475

def self.array_to_hash( array )
  h = {}
  for key, value in array
    h[ key ] = value
  end
  h
end

.debug(data) ⇒ Nil

Outputs debug data.

Under Windows the data is sent to OutputDebugString and requires a utility like DebugView to see the data. Without it the call is muted.

Under other platforms the data is sent to the console.

Parameters:

  • data (Mixed)

Returns:

  • (Nil)

Since:

  • 2.5.0



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'TT_Lib2/debug.rb', line 26

def self.debug(data)
  if data.is_a?( String )
    str = data
  else
    str = data.inspect
  end
  if TT::System.is_windows?
    TT::Win32::OutputDebugString.call( "#{str}\n\0" )
  else
    puts data
  end
  nil
end

.defer(time = 0) ⇒ Nil

Defers execution of the given block.

Parameters:

  • time (Numeric) (defaults to: 0)

Returns:

  • (Nil)

Since:

  • 2.5.0



387
388
389
390
391
392
393
394
395
396
397
398
# File 'TT_Lib2/core.rb', line 387

def self.defer( time = 0 )
  done = false
  timer = UI.start_timer( time, false ) {
    # (i) Unless the timer is stopped before the messagebox it will
    # continue to trigger until the frist messagebox is closed.
    unless done
      done = true
      yield
    end
  }
  nil
end

.even?(number) ⇒ Boolean

Parameters:

  • number (Integer)

Returns:

  • (Boolean)

Since:

  • 2.5.0



404
405
406
# File 'TT_Lib2/core.rb', line 404

def self.even?(number)
  number % 2 == 0
end

.format_time(time) ⇒ String

Returns:

  • (String)

Since:

  • 2.5.0



424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'TT_Lib2/core.rb', line 424

def self.format_time( time )
  time = (time.finite?) ? time : 0.0
  hours = (time / 3600).to_i
  minutes = (time/60 - hours * 60).to_i
  seconds = (time - (minutes * 60 + hours * 3600)).to_i
  if hours > 0 && minutes > 0
    "#{hours}h #{minutes}m #{seconds}s"
  elsif minutes > 0
    "#{minutes}m #{seconds}s"
  else
    "#{seconds}s"
  end
end

.lib2_updateObject

Since:

  • 2.0.0



101
# File 'TT_Lib2/core.rb', line 101

def self.lib2_update; @lib2_update; end

.lib2_update=(window) ⇒ Object

Since:

  • 2.0.0



102
# File 'TT_Lib2/core.rb', line 102

def self.lib2_update=(window); @lib2_update = window; end

.m2(area_meters) ⇒ Numeric

Returns the given square meters area_meters in square inches.

Parameters:

  • area_meters (Numeric)

Returns:

  • (Numeric)

Since:

  • 2.5.0



445
446
447
448
# File 'TT_Lib2/core.rb', line 445

def self.m2( area_meters )
  ratio = 1.m ** 2
  area_meters * ratio
end

If TT's Menu is installed this method will return a custom Menu item instead of the requested root menu.

Parameters:

  • name (String)

    The prefered root menu in Sketchup.

Returns:

  • (Sketchup::Menu)

Since:

  • 2.0.0



354
355
356
357
358
359
360
# File 'TT_Lib2/core.rb', line 354

def self.menu( name )
  if global_variables.include?( :$tt_menu ) && $tt_menu
    $tt_menu
  else
    UI.menu( name )
  end
end

.object_id_hex(object) ⇒ String

Parameters:

  • object (Object)

Returns:

  • (String)

Since:

  • 2.6.0



467
468
469
# File 'TT_Lib2/core.rb', line 467

def self.object_id_hex( object )
  "0x%x" % (object.object_id << 1)
end

.odd?(number) ⇒ Boolean

Parameters:

  • number (Integer)

Returns:

  • (Boolean)

Since:

  • 2.5.0



413
414
415
# File 'TT_Lib2/core.rb', line 413

def self.odd?(number)
  number % 2 > 0
end

.to_m2(area_inches) ⇒ Numeric

Returns the given square inches area_inches in square meters.

Parameters:

  • area_inches (Numeric)

Returns:

  • (Numeric)

Since:

  • 2.5.0



457
458
459
460
# File 'TT_Lib2/core.rb', line 457

def self.to_m2( area_inches )
  ratio = 1.0 / self.m2(1)
  area_inches * ratio
end