i guess your extension uses ruby. just look for "ruby OS X plist" and you'll find some gits helping you out. though sketchup might have its own methods for it. its a simple xml which can be in binary format though.
EDIT: using 5 as a default size for the grid seems odd e.g. while modeling a 4x4 or (3x2) building. its fine for 1x1 or 3x3 buildings though.
you'll probably want an option to set the actual grid size of the building you want to model.
if we want to redraw the grid how would be remove a previously drawn grid in code?
EDIT: using 5 as a default size for the grid seems odd e.g. while modeling a 4x4 or (3x2) building. its fine for 1x1 or 3x3 buildings though.
you'll probably want an option to set the actual grid size of the building you want to model.
if we want to redraw the grid how would be remove a previously drawn grid in code?
Code:
module TT::Plugins::CitiesSkylinesTools
SECTOR_SIZE = 8.m
OBJECT_TYPE = "ObjectType".freeze
TYPE_GUIDE_GRID = "GuideGrid".freeze
def self.create_guide_grid
# dialog:
prompts = ["Grid Width", "Grid Depth"]
defaults = [ "4", "4"]
list = [ "1|2|3|4|5|6|7|8", "1|2|3|4|5|6|7|8"]
input = UI.inputbox(prompts, defaults, list, "Grid Dimensions")
cells_x = Integer(input[0])
cells_y = Integer(input[1])
grid_lines_x = cells_x + 1
grid_lines_y = cells_y + 1
model = Sketchup.active_model
model.start_operation("Guide Grid")
group = model.entities.add_group
# Tag this group so we can find it later.
group.set_attribute(PLUGIN_ID, OBJECT_TYPE, TYPE_GUIDE_GRID)
# Add guide points.
grid_lines_x.times { |x|
grid_lines_y.times { |y|
group.entities.add_cpoint([x * SECTOR_SIZE, y * SECTOR_SIZE, 0])
}
}
# Add guide lines.
grid_lines_x.times { |x|
grid_lines_y.times { |y|
point1 = Geom::Point3d.new(x * SECTOR_SIZE, y * SECTOR_SIZE, 0)
point2 = point1.offset(X_AXIS, SECTOR_SIZE)
point3 = point1.offset(Y_AXIS, SECTOR_SIZE)
group.entities.add_cline(point1, point2) unless x == cells_x
group.entities.add_cline(point1, point3) unless y == cells_y
}
}
# Center at origin.
half_size_x = (SECTOR_SIZE * cells_x) / 2.0
half_size_y = (SECTOR_SIZE * cells_y) / 2.0
tr = Geom::Transformation.new([-half_size_x, -half_size_y, 0])
group.transform!(tr)
# Prevent it from easily being moved.
group.locked = true
model.commit_operation
# Ensure the grid is visible.
model.rendering_options["HideConstructionGeometry"] = false
rescue Exception => error
# model.abort_operation
# ERROR_REPORTER.handle(error)
end
end # module TT::Plugins::CitiesSkylinesTools
Last edited: