Class: Sketchup::View

Inherits:
Object
  • Object
show all
Defined in:
SketchUp/Sketchup/View.rb

Overview

This class contains methods to manipulate the current point of view of the model. The drawing methods here (draw_line, draw_polyline, etc) are meant to be invoked within a tool’s Tool.draw method. Calling them outside Tool.draw will have no effect.

You access the View by calling the Model.active_view method.

Examples:

view = Sketchup.active_model.active_view

Version:

  • SketchUp 6.0

Instance Method Summary collapse

Instance Method Details

#add_observer(observer) ⇒ Boolean

The add_observer method is used to add an observer to the current object.

Examples:

view = Sketchup.active_model.active_view
status = view.add_observer observer

Parameters:

  • observer (Object)

    An observer.

Returns:

  • (Boolean)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0



31
32
# File 'SketchUp/Sketchup/View.rb', line 31

def add_observer(observer)
end

#animation=(animation) ⇒ #nextFrame

The animation= method is used to set an animation that is displayed for a view. See Animation for details on how to create an animation object.

Examples:

animation = ViewSpinner.new
model = Sketchup.active_model
view = model.active_view
anim = view.animation=animation
if (anim)
  UI.messagebox anim
else
  UI.messagebox "Failure"
end

Parameters:

  • animation (#nextFrame)

    An Animation object.

Returns:

  • (#nextFrame)

    the newly set Animation object

Version:

  • SketchUp 6.0



54
55
# File 'SketchUp/Sketchup/View.rb', line 54

def animation=(animation)
end

#average_refresh_timeFloat

The average_refresh_time is used to set the average time used to refresh the current model in the view. This can be used to estimate the frame rate for an animation.

Examples:

model = Sketchup.active_model
view = model.active_view
time = view.average_refresh_time

Returns:

  • (Float)

    the time in seconds

Version:

  • SketchUp 6.0



69
70
# File 'SketchUp/Sketchup/View.rb', line 69

def average_refresh_time
end

#cameraSketchup::Camera

The camera method is used to retrieve the camera for the view.

Examples:

camera = view.camera

Returns:

Version:

  • SketchUp 6.0



80
81
# File 'SketchUp/Sketchup/View.rb', line 80

def camera
end

#camera=(camera) ⇒ Sketchup::Camera #camera=(camera_and_transition) ⇒ Array(Sketchup::Camera, Float)

The camera= method is used to set the camera for the view. If a transition time is given, then it will animate the transition from the current camera to the new one.

Examples:

camera2 = Sketchup.Camera.new
model = Sketchup.active_model
view = model.active_view
status = view.camera=camera2

Overloads:

Version:

  • SketchUp 6.0



106
107
# File 'SketchUp/Sketchup/View.rb', line 106

def camera=(arg)
end

#centerGeom::Point3d

The center method is used to retrieve the coordinates of the center of the view in pixels. It is returned as an array of 2 values for x and y.

Examples:

model = Sketchup.active_model
view = model.active_view
c = view.center

Returns:

Version:

  • SketchUp 6.0



120
121
# File 'SketchUp/Sketchup/View.rb', line 120

def center
end

#corner(index) ⇒ Array(Integer, Integer)

The corner method is used to retrieve the coordinates of one of the corners of the view. The argument is an index between 0 and 3 that identifies which corner you want. This method returns an array with two integers which are the coordinates of the corner of the view in the view space. If the view uses a Camera with a fixed aspect ratio, then the corners are the corners of the viewing are of the camera which might be different than the actual corners of the view itself.

The index numbers are as follows:

- 0: top left,
- 1: top right,
- 2: bottom left,
- 3: bottom right.

Examples:

point = view.corner index

Parameters:

  • index (Integer)

    A value between (or including) 0 and 3 identifying the corner whose coordinate you want to retrieve.

Returns:

  • (Array(Integer, Integer))

    a 2d array [w,h] representing the screen point

Version:

  • SketchUp 6.0



147
148
# File 'SketchUp/Sketchup/View.rb', line 147

def corner(index)
end

#draw(openglenum, points) ⇒ Sketchup::View

Note:

If you draw outside the model bounds you need to implement Tool#getExtents which returns a bounding box large enough to include the points you draw. Otherwise your drawing will be clipped.

The #draw method is used to do basic drawing. This method can only be called from within the Tool#draw method of a tool that you implement in Ruby.

The following constants are all OpenGL terms and have been externalized to Ruby. Here is a summary of their meanings:

GL_POINTS

Treats each vertex as a single point. Vertex n defines point n. N points are drawn.

GL_LINES

Treats each pair of vertices as an independent line segment. Vertices 2n-1 and 2n define line n. N/2 lines are drawn.

GL_LINE_STRIP

Draws a connected group of line segments from the first vertex to the last. Vertices n and n+1 define line n. N-1 lines are drawn.

GL_LINE_LOOP

Draws a connected group of line segments from the first vertex to the last, then back to the first. Vertices n and n+1 define line n. The last line, however, is defined by vertices N and 1. N lines are drawn.

GL_TRIANGLES

Treats each triplet of vertices as an independent triangle. Vertices 3n-2, 3n-1, and 3n define triangle n. N/3 triangles are drawn.

GL_TRIANGLE_STRIP

Draws a connected group of triangles. One triangle is defined for each vertex presented after the first two vertices. For odd n, vertices n, n+1, and n+2 define triangle n. For even n, vertices n+1, n, and n+2 define triangle n. N-2 triangles are drawn.

GL_TRIANGLE_FAN

Draws a connected group of triangles. One triangle is defined for each vertex presented after the first two vertices. Vertices 1, n+1, and n+2 define triangle n. N-2 triangles are drawn.

GL_QUADS

Treats each group of four vertices as an independent quadrilateral. Vertices 4n-3, 4n-2, 4n-1, and 4n define quadrilateral n. N/4 quadrilaterals are drawn.

GL_QUAD_STRIP

Draws a connected group of quadrilaterals. One quadrilateral is defined for each pair of vertices presented after the first pair. Vertices 2n-1, 2n, 2n+2, and 2n+1 define quadrilateral n. N/2-1 quadrilaterals are drawn. Note that the order in which vertices are used to construct a quadrilateral from strip data is different from that used with independent data.

GL_POLYGON

Draws a single, convex polygon. Vertices 1 through N define this polygon.

Examples:

points = [
  Geom::Point3d.new(0, 0, 0),
  Geom::Point3d.new(9, 0, 0),
  Geom::Point3d.new(9, 9, 0),
  Geom::Point3d.new(0, 9, 0)
]
view.draw(GL_LINE_LOOP, points)

Parameters:

  • openglenum (Integer)

    The item you are going to draw, one of the constants from the comments, such as GL_LINES.

  • points (Array<Geom::Point3d>)

Returns:

See Also:

Version:

  • SketchUp 6.0



234
235
# File 'SketchUp/Sketchup/View.rb', line 234

def draw(openglenum, points)
end

#draw2d(openglenum, points) ⇒ Sketchup::View

The #draw2d method is used to draw in screen space (using 2D screen coordinates) instead of 3D space.

The second parameter is an Array of Geom::Point3d objects (or several individual Geom::Point3d objects). These Geom::Point3d objects are in screen space, not 3D space. The X value corresponds to the number of pixels from the left edge of the drawing area. The Y value corresponds to the number of pixels down from the top of the drawing area. The Z value is not used.

Examples:

points = [
  Geom::Point3d.new(0, 0, 0),
  Geom::Point3d.new(8, 0, 0),
  Geom::Point3d.new(8, 4, 0),
  Geom::Point3d.new(0, 4, 0)
]
view.draw2d(GL_LINE_STRIP, points)

Parameters:

  • openglenum (Integer)

    An OpenGL enumerator (unsigned integer). See comments in the #draw method for a list of constants.

  • points (Array<Geom::Point3d>)

Returns:

See Also:

Version:

  • SketchUp 6.0



269
270
# File 'SketchUp/Sketchup/View.rb', line 269

def draw2d(openglenum, points)
end

#draw_lines(point_list, ...) ⇒ Sketchup::View #draw_lines(pts) ⇒ Sketchup::View

The draw_lines method is used to draw disconnected lines.

You must have an even number of points. This method is usually invoked within the draw method of a tool.

Examples:

point4 = Geom::Point3d.new 0,0,0
point5 = Geom::Point3d.new 100,100,100
# returns a view
status = view.drawing_color="red"
status = view.draw_lines point4, point5

Overloads:

Version:

  • SketchUp 6.0



295
296
# File 'SketchUp/Sketchup/View.rb', line 295

def draw_line(*args)
end

#draw_lines(point_list, ...) ⇒ Sketchup::View #draw_lines(pts) ⇒ Sketchup::View

The draw_lines method is used to draw disconnected lines.

You must have an even number of points. This method is usually invoked within the draw method of a tool.

Examples:

point4 = Geom::Point3d.new 0,0,0
point5 = Geom::Point3d.new 100,100,100
# returns a view
status = view.drawing_color="red"
status = view.draw_lines point4, point5

Overloads:

Version:

  • SketchUp 6.0



321
322
# File 'SketchUp/Sketchup/View.rb', line 321

def draw_lines(*args)
end

#draw_points(pts, pointsize = 6, pointstyle = 3, pointcolor = 'black') ⇒ Sketchup::View

This method is used to draw points.

This method is usually invoked within the draw method of a tool.

Examples:

point3 = Geom::Point3d.new 0,0,0
# returns a view
status = view.draw_points point3, 10, 1, "red"

Parameters:

  • pts (Array<Geom::Point3d>)

    An array of Point3d objects.

  • pointstyle (Integer) (defaults to: 3)

    Style of the point. 1 = open square, 2 = filled square, 3 = “+”, 4 = “X”, 5 = “*”, 6 = open triangle, 7 = filled triangle.

  • pointcolor (Sketchup::Color) (defaults to: 'black')

    Color of the point.

  • pointsize (Integer) (defaults to: 6)

    Size of the point in pixels.

Returns:

Version:

  • SketchUp 6.0



350
351
# File 'SketchUp/Sketchup/View.rb', line 350

def draw_points(pts, pointsize = 6, pointstyle = 3, pointcolor = 'black')
end

#draw_polyline(point_list, ...) ⇒ Sketchup::View #draw_polyline(pts) ⇒ Sketchup::View

The draw_polyline method is used to draw a series of connected line segments from pt1 to pt2 to pt3, and so on.

This method is usually invoked within the draw method of a tool.

Examples:

point12 = Geom::Point3d.new 0,0,0
point13 = Geom::Point3d.new 10,10,10
point14 = Geom::Point3d.new 20,20,20
point15 = Geom::Point3d.new 30,30,30
status = view.draw_polyline point12, point13, point14, point15

Overloads:

Version:

  • SketchUp 6.0



376
377
# File 'SketchUp/Sketchup/View.rb', line 376

def draw_polyline(*args)
end

#draw_text(point, text, options = {}) ⇒ Sketchup::View

Note:

Under Windows the font name must be less than 32 characters - due to system limitations.

This method is used to draw text on the screen and is usually invoked within the draw method of a tool.

Examples:

view = Sketchup.active_model.active_view

# This works in all SketchUp versions and draws the text using the
# default font, color and size.
point = Geom::Point3d.new(200, 100, 0)
view.draw_text(point, "This is a test")

# This works in SketchUp 2016 and up.
options = {
  :font => "Arial",
  :size => 20,
  :bold => true,
  :align => TextAlignRight
}
point = Geom::Point3d.new(200, 200, 0)
view.draw_text(point, "This is another\ntest", options)

# You can also use Ruby 2.0's named arguments:
point = Geom::Point3d.new(200, 200, 0)
view.draw_text(point, "Hello world!", color: "Red")

Parameters:

  • options (Hash) (defaults to: {})

    The text can be customized by providing a hash or named arguments of options. Available from SketchUp 2016.

  • text (String)

    The text string to draw.

  • point (Geom::Point3d)

    A Point3d object representing a 2D coordinate in view space.

Options Hash (options):

  • :color (Sketchup::Color)

    The color to draw the text with.

  • :align (Integer)

    The text alignment, one of the following constants TextAlignLeft, TextAlignCenter or TextAlignRight.

  • :italic (Boolean)

    Controls the Italic property of the font.

  • :bold (Boolean)

    Controls the Bold property of the font.

  • :size (Integer)

    The size of the font in points

  • :font (String)

    The name of the font to use. If it does not exist on the system, a default font will be used instead.

Returns:

Version:

  • SketchUp 6.0



435
436
# File 'SketchUp/Sketchup/View.rb', line 435

def draw_text(point, text, options = {})
end

#drawing_color=(color) ⇒ Sketchup::View

The drawing_color method is used to set the color that is used for drawing to the view.

This method is usually invoked within the draw method of a tool.

Examples:

view = view.drawing_color = color

Parameters:

Returns:

Version:

  • SketchUp 6.0



452
453
# File 'SketchUp/Sketchup/View.rb', line 452

def drawing_color=(color)
end

#dynamic=(value) ⇒ Boolean

The dynamic= method allows you to degrade visual quality while improving performance when a model is large and view refresh time is slow. For example, if you were using a Ruby script to animate the camera through a large scene, you may want to set dynamic to true during that time.

See also camera.rb which is part of the film and stage ruby scripts.

Examples:

view.dynamic = true

Parameters:

  • value (Boolean)

    true or false

Returns:

  • (Boolean)

Version:

  • SketchUp 6.0



472
473
# File 'SketchUp/Sketchup/View.rb', line 472

def dynamic=(value)
end

#field_of_viewFloat

The field_of_view method is used get the view’s field of view setting, in degrees.

Examples:

fov = Sketchup.active_model.active_view.field_of_view

Returns:

  • (Float)

    the field of view

Version:

  • SketchUp 6.0



484
485
# File 'SketchUp/Sketchup/View.rb', line 484

def field_of_view
end

#field_of_view=(fov) ⇒ Numeric

The field_of_view= method is used set the view’s field of view setting, in degrees.

Examples:

my_view = Sketchup.active_model.active_view
my_view.field_of_view = 45
my_view.invalidate

Parameters:

  • fov (Numeric)

    the field of view

Returns:

Version:

  • SketchUp 6.0



501
502
# File 'SketchUp/Sketchup/View.rb', line 501

def field_of_view=(fov)
end

#guess_target(*args) ⇒ Geom::Point3d

The guess_target method is used to guess at what the user is looking at when you have a perspective view.

This method is useful when writing a viewing tool. See also camera.rb which is part of the film and stage ruby scripts.

Examples:

target = view.guess_target

Returns:

  • (Geom::Point3d)

    a Point3d object representing the point in the model that the user is likely interested in.

Version:

  • SketchUp 6.0



517
518
# File 'SketchUp/Sketchup/View.rb', line 517

def guess_target(*args)
end

#inference_locked?Boolean

The inference_locked? method is used to determine if inference locking is on for the view.

Examples:

model = Sketchup.active_model
view = model.active_view
status = view.inference_locked

Returns:

  • (Boolean)
  • (Boolean)

Version:

  • SketchUp 6.0



533
534
# File 'SketchUp/Sketchup/View.rb', line 533

def inference_locked?
end

#inputpoint(x, y, inputpoint1) ⇒ Sketchup::InputPoint

The inputpoint method is used to retrieve an input point.

This will normally be used inside one of the mouse event handling methods in a tool. Usually, it is preferable to create the InputPoint first and then use the pick method on it.

Examples:

inputpoint = view.inputpoint x, y, inputpoint1

Parameters:

Returns:

Version:

  • SketchUp 6.0



557
558
# File 'SketchUp/Sketchup/View.rb', line 557

def inputpoint(x, y, inputpoint1)
end

#invalidateSketchup::View

Note:

This is the preferred method to update the viewport. Use this before trying to use #refresh.

The invalidate method is used mark the view as in need of a redraw.

Examples:

model = Sketchup.active_model
view = model.active_view
invalidated_view = view.invalidate

Returns:

Version:

  • SketchUp 6.0



573
574
# File 'SketchUp/Sketchup/View.rb', line 573

def invalidate
end

#last_refresh_time(*args) ⇒ Float

The last_refresh_time method is used to retrieve the time for the last full view refresh.

Examples:

time = view.last_refresh_time

Returns:

  • (Float)

    time in milliseconds

Version:

  • SketchUp 6.0



585
586
# File 'SketchUp/Sketchup/View.rb', line 585

def last_refresh_time(*args)
end

#line_stipple=(pattern) ⇒ Sketchup::View

The line_stipple= method is used to set the line pattern to use for drawing. The stipple pattern is given as a string. Valid strings are:

"." (Dotted Line),
"-" (Short Dashes Line),
"_" (Long Dashes Line),
"-.-" (Dash Dot Dash Line),
"" (Solid Line).

This method is usually invoked within the draw method of a tool.

Examples:

point8 = Geom::Point3d.new 0,0,0
point9 = Geom::Point3d.new 100,100,100
view.line_stipple = "-.-"
view = view.draw_lines point8, point9

Parameters:

  • pattern (String)

    A string stipple pattern, such as “-.-”

Returns:

Version:

  • SketchUp 6.0



611
612
# File 'SketchUp/Sketchup/View.rb', line 611

def line_stipple=(pattern)
end

#line_width=(width) ⇒ Integer

The line_width= method is used to set the line width to use for drawing. The value is a Double indicating the desired width in pixels.

This method is usually invoked within the draw method of a tool.

Examples:

view.line_width = width

Parameters:

  • width (Integer)

    The width in pixels.

Returns:

  • (Integer)

Version:

  • SketchUp 6.0



628
629
# File 'SketchUp/Sketchup/View.rb', line 628

def line_width=(width)
end

#lock_inferenceSketchup::View #lock_inference(inputpoint) ⇒ Sketchup::View #lock_inference(inputpoint, inputpoint2) ⇒ Sketchup::View

The lock_inference method is used to lock or unlock an inference.

This method will typically be called from inside a tool class when the user presses the shift key.

With no arguments it unlocks all inferences. With one or two arguments, it locks the inference based on the given InputPoint(s).

Examples:

view = view.lock_inference
view = view.lock_inference(inputpoint)
view = view.lock_inference(inputpoint1, inputpoint2)

Overloads:

Returns:

Version:

  • SketchUp 6.0



662
663
# File 'SketchUp/Sketchup/View.rb', line 662

def lock_inference(*args)
end

#modelSketchup::Model

The model method is used to retrieve the model for the current view.

Examples:

model = view.model

Returns:

Version:

  • SketchUp 6.0



673
674
# File 'SketchUp/Sketchup/View.rb', line 673

def model
end

#pick_helperSketchup::PickHelper #pick_helper(x, y, aperture = 0) ⇒ Sketchup::PickHelper

The pick_helper method is used to retrieve a pick helper for the view. See the PickHelper class for information on pick helpers.

This call returns an initialized PickHelper.

Examples:

model = Sketchup.active_model
view = model.active_view
ph = view.pick_helper

Overloads:

Version:

  • SketchUp 6.0



698
699
# File 'SketchUp/Sketchup/View.rb', line 698

def pick_helper(*args)
end

#pickray(screen_point) ⇒ Array(Geom::Point3d, Geom::Vector3d) #pickray(x, y) ⇒ Array(Geom::Point3d, Geom::Vector3d)

The pickray method is used to retrieve a ray passing through a given screen position in the viewing direction.

Examples:

ray = view.pickray x, y

Overloads:

Version:

  • SketchUp 6.0



719
720
# File 'SketchUp/Sketchup/View.rb', line 719

def pickray(*args)
end

#pixels_to_model(pixels, point) ⇒ Float

The pixels_to_model method is used to compute a model size from a pixel size at a given point.

This method is useful for deciding how big to draw something based on a desired size in pixels.

Examples:

size = view.pixels_to_model pixels, point

Parameters:

  • pixels (Numeric)

    The pixel size.

  • point (Geom::Point3d)

    A Point3d object where the size will be calculated from.

Returns:

  • (Float)

    the model size

Version:

  • SketchUp 6.0



740
741
# File 'SketchUp/Sketchup/View.rb', line 740

def pixels_to_model(pixels, point)
end

#refreshSketchup::View

Note:

This method might impact performance and if used incorrectly cause instability or crashes. Don’t use this unless you have verified that you cannot use #invalidate instead.

The refresh method is used to immediately force a redraw of the view.

Examples:

model = Sketchup.active_model
view = model.active_view
refreshed_view = view.refresh

Returns:

Version:

  • SketchUp 7.1



757
758
# File 'SketchUp/Sketchup/View.rb', line 757

def refresh
end

#remove_observer(observer) ⇒ Boolean

The remove_observer method is used to remove an observer from the current object.

Examples:

view = Sketchup.active_model.active_view
status = view.remove_observer observer

Parameters:

  • observer (Object)

    An observer.

Returns:

  • (Boolean)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0



773
774
# File 'SketchUp/Sketchup/View.rb', line 773

def remove_observer(observer)
end

#screen_coords(point3d) ⇒ Geom::Point3d

The screen_coords method is used to retrieve the screen coordinates of the given point on the screen.

The x and y values returned correspond to the x and y screen coordinates. Ignore the z values. If the referenced point is not in the current viewport, the x and/or y value may be negative.

Examples:

point = view.screen_coords(ORIGIN)

Parameters:

Returns:

Version:

  • SketchUp 6.0



792
793
# File 'SketchUp/Sketchup/View.rb', line 792

def screen_coords(point3d)
end

#set_color_from_line(point1, point2) ⇒ Sketchup::View

Set the drawing color for the view based on the direction of a line that you want to draw. These colors will match the axes colors in the SketchUp model (typically blue for straight up and down, etc.)

This method is usually invoked within the draw method of a tool.

Examples:

view = view.set_color_from_line point1, point2

Parameters:

  • point1 (Geom::Point3d)

    Point3d object representing first point in the line.

  • point2 (Geom::Point3d)

    Point3d object representing the second point in the line.

Returns:

Version:

  • SketchUp 6.0



813
814
# File 'SketchUp/Sketchup/View.rb', line 813

def set_color_from_line(point1, point2)
end

#show_frame(delay) ⇒ Sketchup::View

The show_frame method is used to show a frame of an Animation object in the current view.

You can supply an optional delay in seconds to wait before showing the next frame. This can be useful to control the speed at which the animation runs.

Examples:

status = view.show_frame delay

Parameters:

  • delay (Numeric)

    An optional delay in seconds.

Returns:

Version:

  • SketchUp 6.0



831
832
# File 'SketchUp/Sketchup/View.rb', line 831

def show_frame(delay)
end

#tooltip=(string) ⇒ String

Set a tooltip to display in the view. This is useful for displaying tooltips in a tool that you write in Ruby.

Examples:

tooltip = view.tooltip = string

Parameters:

  • string (String)

    The string tooltip.

Returns:

  • (String)

    the new tooltip string

Version:

  • SketchUp 6.0



846
847
# File 'SketchUp/Sketchup/View.rb', line 846

def tooltip=(string)
end

#vpheightInteger

The vpheight method is used to retrieve the height of the viewport for the view.

Examples:

model = Sketchup.active_model
view = model.active_view
height = view.vpheight

Returns:

  • (Integer)

    the height of the viewport in pixels.

Version:

  • SketchUp 6.0



860
861
# File 'SketchUp/Sketchup/View.rb', line 860

def vpheight
end

#vpwidthInteger

The vpwidth method is used to retrieve the width of the viewport for the view.

Examples:

width = view.vpwidth

Returns:

  • (Integer)

    the width of the viewport in pixels.

Version:

  • SketchUp 6.0



872
873
# File 'SketchUp/Sketchup/View.rb', line 872

def vpwidth
end

#write_image(filename, width = view.vpwidth, height = view.vpheight, antialias = false, compression = 1.0) ⇒ Boolean #write_image(options) ⇒ Boolean

The write_image method is used to write the current view to an image file.

All arguments except for the filename are optional.

If antialias is specified, it should be either true or false.

If a hash is passed as the first parameter, then the contents of that hash define how the image is exported. The keys are:

- filename        The filename for the saved image.
- width           (optional) Width in pixels (max 16000).
- height          (optional) Height in pixels (max 16000).
- antialias       (optional) true or false
- compression     (optional) Float compression factor for JPEG images,
                  between 0.0 and 1.0
- transparent     true or false

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
# Add the face to the entities in the model
face = entities.add_face pts
UI.messagebox "Now Lets Write the Image"
view = model.active_view
# Puts in SketchUp install directory by default
status = view.write_image "test.jpg"
keys = {
  :filename => "c:/tmp/write_image.png",
  :width => 640,
  :height => 480,
  :antialias => false,
  :compression => 0.9,
  :transparent => true
}
model = Sketchup.active_model
view = model.active_view
view.write_image keys

Overloads:

  • #write_image(filename, width = view.vpwidth, height = view.vpheight, antialias = false, compression = 1.0) ⇒ Boolean

    Parameters:

    • filename (String)

      The filename for the saved image

    • width (Integer) (defaults to: view.vpwidth)

      Width in pixels, defaults to the current viewport width #vpwidth.

    • height (Integer) (defaults to: view.vpheight)

      Height in pixels, defaults to the current viewport height #vpheight.

    • antialias (Boolean) (defaults to: false)

      true or false

    • compression (Float) (defaults to: 1.0)

      Float compression factor for JPEG images, between 0.0 and 1.0

  • #write_image(options) ⇒ Boolean

    Parameters:

    • options (Hash)

Returns:

  • (Boolean)

Version:

  • SketchUp 6.0



941
942
# File 'SketchUp/Sketchup/View.rb', line 941

def write_image(*args)
end

#zoom(zoom_or_ents) ⇒ Sketchup::View

The zoom method is used to zoom in or out by some zoom factor.

Examples:

view = view.zoom factor
view = view.zoom selection
view = view.zoom entity
view = view.zoom array_of_entities

Parameters:

Returns:

Version:

  • SketchUp 6.0



959
960
# File 'SketchUp/Sketchup/View.rb', line 959

def zoom(zoom_or_ents)
end

#zoom_extentsSketchup::View

The zoom_extents method is used to zoom to the extents about the entire model, as if the user has selected the zoom extents command from the menu.

Examples:

view = Sketchup.active_model.active_view
new_view = view.zoom_extents

Returns:

Version:

  • SketchUp 6.0



972
973
# File 'SketchUp/Sketchup/View.rb', line 972

def zoom_extents
end