Class: Sketchup::Image

Inherits:
Drawingelement show all
Defined in:
lib/sketchup-api-stubs/stubs/Sketchup/Image.rb

Overview

An Image object represents a raster image placed in the Model.

Version:

  • SketchUp 6.0

Instance Method Summary collapse

Methods inherited from Drawingelement

#bounds, #casts_shadows=, #casts_shadows?, #erase!, #hidden=, #hidden?, #layer, #layer=, #material, #material=, #receives_shadows=, #receives_shadows?, #visible=, #visible?

Methods inherited from Entity

#add_observer, #attribute_dictionaries, #attribute_dictionary, #delete_attribute, #deleted?, #entityID, #get_attribute, #inspect, #model, #parent, #persistent_id, #remove_observer, #set_attribute, #to_s, #typename, #valid?

Instance Method Details

#explodeObject

The explode method is used to explode an image into a face with a texture on it.

Note that current versions of SketchUp will return an empty array here. To work around this limitation you can iterate over your entities collection to determine which new entities were created.

Versions prior to SketchUp 2015 returned an empty array due to a bug.

Examples:

model = Sketchup.active_model
path = "Plugins/su_dynamiccomponents/images"
image_file = Sketchup.find_support_file("report_tool.png", path)
image = model.active_entities.add_image(image_file, ORIGIN, 300)
entities = image.explode

Returns:

  • entitiesarray - an Array object of entities if successful

Version:

  • SketchUp 6.0



31
32
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 31

def explode
end

#heightObject

The height method is used to retrieve the height of the image.

The height is given in inches.

Examples:

model = Sketchup.active_model
path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
pt = Geom::Point3d.new
entities = model.active_entities
image = entities.add_image path, pt, 300
height = image.height
if (height)
  UI.messagebox height
else
  UI.messagebox "Failure"
end

Returns:

  • height - the height of the model if successful

Version:

  • SketchUp 6.0



54
55
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 54

def height
end

#height=(height) ⇒ Object

The height= method is used to set the height of the image.

The height is set in inches.

Examples:

model = Sketchup.active_model
path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
pt = Geom::Point3d.new
entities = model.active_entities
image = entities.add_image path, pt, 300
UI.messagebox "Before adjustment"
height = image.height = 400
if (height)
  UI.messagebox height
else
  UI.messagebox "Failure"
end

Parameters:

  • height

    The height, in inches, to set the image.

Returns:

  • height - the new height if successful

Version:

  • SketchUp 6.0



81
82
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 81

def height=(height)
end

#image_repSketchup::ImageRep

The #image_rep method returns a copy of a Sketchup::ImageRep object representing the pixel data.

Examples:

model = Sketchup.active_model
path = "Plugins/su_dynamiccomponents/images"
image_file = Sketchup.find_support_file("report_tool.png", path)
image = model.active_entities.add_image(image_file, ORIGIN, 300)
image_rep = image.image_rep

Returns:

Version:

  • SketchUp 2018



97
98
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 97

def image_rep
end

#normalObject

The normal method is used to retrieve the 3D Vector that is perpendicular to the plane of the image.

Examples:

model = Sketchup.active_model
path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
pt = Geom::Point3d.new
entities = model.active_entities
image = entities.add_image path, pt, 300
vector = image.normal
if (vector)
  UI.messagebox vector
else
  UI.messagebox "Failure"
end

Returns:

  • vector - a Vector3d object if successful

Version:

  • SketchUp 6.0



119
120
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 119

def normal
end

#originObject

The origin method is used to retrieve the 3D point that defines the origin of the image.

Examples:

model = Sketchup.active_model
path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
pt = Geom::Point3d.new
entities = model.active_entities
image = entities.add_image path, pt, 300
origin = image.origin
if (origin)
  UI.messagebox origin
else
  UI.messagebox "Failure"
end

Returns:

  • point - a Point3d object containing the origin location if successful

Version:

  • SketchUp 6.0



142
143
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 142

def origin
end

#origin=(point) ⇒ Object

The origin= method is used to set the 3D point as the origin of the image.

Examples:

model = Sketchup.active_model
path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
pt = Geom::Point3d.new
pt2 = Geom::Point3d.new 100,100,100
entities = model.active_entities
image = entities.add_image path, pt, 300
UI.messagebox "Before Move"
origin = image.origin=pt2
if (origin)
  UI.messagebox origin
else
  UI.messagebox "Failure"
end

Parameters:

  • point

    A Point3d object with the new origin.

Returns:

  • point - the Point3d object representing the newly established origin if successful

Version:

  • SketchUp 6.0



169
170
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 169

def origin=(point)
end

#pathObject

The path method is used to retrieve the path of the file defining the image.

Examples:

model = Sketchup.active_model
path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
pt = Geom::Point3d.new
entities = model.active_entities
image = entities.add_image path, pt, 300
path = image.path
if (path)
  UI.messagebox path
else
  UI.messagebox "Failure"
end

Returns:

  • path - the path for the image file if successful

Version:

  • SketchUp 6.0



190
191
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 190

def path
end

#pixelheightObject

The pixelheight method is used to retrieve the height of the image file in pixels.

Examples:

model = Sketchup.active_model
path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
pt = Geom::Point3d.new
entities = model.active_entities
image = entities.add_image path, pt, 300
pixelheight = image.pixelheight
if (pixelheight)
  UI.messagebox pixelheight
else
  UI.messagebox "Failure"
end

Returns:

  • height - the height of the image in pixels if successful

Version:

  • SketchUp 6.0



213
214
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 213

def pixelheight
end

#pixelwidthObject

The pixelwidth method is used to retrieve the width of the image file in pixels.

Examples:

model = Sketchup.active_model
path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
pt = Geom::Point3d.new
entities = model.active_entities
image = entities.add_image path, pt, 300
pixelwidth = image.pixelwidth
if (pixelwidth)
  UI.messagebox pixelwidth
else
  UI.messagebox "Failure"
end

Returns:

  • width - the width of the image in pixels if successful

Version:

  • SketchUp 6.0



235
236
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 235

def pixelwidth
end

#size=(width, height) ⇒ Object

The size= method is used to set the width and height of the image, in inches.

Examples:

model = Sketchup.active_model
path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
pt = Geom::Point3d.new
entities = model.active_entities
image = entities.add_image path, pt, 300
UI.messagebox "Before Resize"
size = image.size= 500,500
if (size)
  UI.messagebox size
else
  UI.messagebox "Failure"
end

Parameters:

  • width

    The width of the image.

  • height

    The height of the image.

Returns:

  • size - the new width and height of the image if successful

Version:

  • SketchUp 6.0



264
265
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 264

def size=(width, height)
end

#transform!(transform) ⇒ Object

The transform! method is used to apply a transformation to the image.

Examples:

model = Sketchup.active_model
path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
point = Geom::Point3d.new 100,100,100
t = Geom::Transformation.new point
pt = Geom::Point3d.new
entities = model.active_entities
image = entities.add_image path, pt, 300
UI.messagebox "Before Move"
image = image.transform! t
if (image)
  UI.messagebox image
else
  UI.messagebox "Failure"
end

Parameters:

  • transform

    A Transformation object.

Returns:

  • image - the transformed Image object if successful

Version:

  • SketchUp 6.0



291
292
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 291

def transform!(transform)
end

#transformationObject

The transformation method is used to retrieve the transformation for the image.

Examples:

# Add an image to the model.
model = Sketchup.active_model
entities = model.active_entities
path = Sketchup.find_support_file('report_tool.png', 'Plugins/su_dynamiccomponents/images')
point = Geom::Point3d.new(100,100,100)
image = entities.add_image(path, point, 300)

trans = image.transformation

Returns:

  • transformation - a Transformation object if successful

Version:

  • SketchUp 2014



310
311
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 310

def transformation
end

#transformation=(transform) ⇒ Object

The transformation= method is used to set the transformation for the image.

Examples:

# Add an image to the model.
model = Sketchup.active_model
entities = model.active_entities
path = Sketchup.find_support_file('report_tool.png', 'Plugins/su_dynamiccomponents/images')
point = Geom::Point3d.new(100,100,100)
image = entities.add_image(path, point, 300)

new_transform = Geom::Transformation.new([100,0,0])
image.transformation = new_transform

Parameters:

  • transform

    The Transformation object to apply

Returns:

  • image - the newly transformed image

Version:

  • SketchUp 2014



333
334
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 333

def transformation=(transform)
end

#widthObject

The width method is used to retrieve the width of the image.

The width is given in inches.

Examples:

model = Sketchup.active_model
path = Sketchup.find_support_file "report_tool.png",
  "Tools/DynamicComponents/images"
pt = Geom::Point3d.new
entities = model.active_entities
image = entities.add_image path, pt, 300
width = image.width
if (width)
  UI.messagebox width
else
  UI.messagebox "Failure"
end

Returns:

  • width - the width of the image if successful

Version:

  • SketchUp 6.0



357
358
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 357

def width
end

#width=(width) ⇒ Object

The width= method is used to set the width of the image.

The width is set in inches.

Examples:

model = Sketchup.active_model
path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
pt = Geom::Point3d.new
entities = model.active_entities
image = entities.add_image path, pt, 300
UI.messagebox "Before adjustment"
width = image.width=400
if (width)
  UI.messagebox width
else
  UI.messagebox "Failure"
end

Parameters:

  • width

    The width, in inches, to set the image.

Returns:

  • width - the new width if successful

Version:

  • SketchUp 6.0



384
385
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 384

def width=(width)
end

#zrotationObject

The zrotation method is used to get the angle that the image is rotated about the normal vector from an arbitrary X axis.

Examples:

model = Sketchup.active_model
path = Sketchup.find_support_file "report_tool.png", "Tools/DynamicComponents/images"
pt = Geom::Point3d.new
entities = model.active_entities
image = entities.add_image path, pt, 300
zrotation = image.zrotation
if (zrotation)
  UI.messagebox zrotation
else
  UI.messagebox "Failure"
end

Returns:

  • vector - a Vector3d object if successful

Version:

  • SketchUp 6.0



406
407
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Image.rb', line 406

def zrotation
end