Autocad is designed primarily for engineers but the GoogleSketcUp software user base is much wider. This is my experience with Google SketchUp. In this blog i deal how to utilize Ruby On Rails Control Interface in Google SketchUp. Although there are many three-dimensional modeling tools available, SketcUp software is probably the most easy to use. The basic use of the program can be learned in no time. What makes it so flexible is that it includes Ruby On Rails Api. So it is therefore possible to utilize the software interface and Ruby scripts and take thus the full potential of SketcUp. SketchUp features a ruby console to test script functionality. Another possibility is to use Ruby code editor. The feature is very good because the code can be tested in real time. Animation is easy with the adding scenes and the user interface and tool menu are clear. They are also easy to edit with scripts.
WHY USE SKETCHUP
There are many reasons why you should use this program. Design management is developed for complex structures. SketchUp Groups and Components can be used to create different hierarchies for design elements. A complex structure can consist of many components and sub-components. These structures are easy to manage with scripts. Add-ons can add functionality to the general application. One can add items to a new menu, add new tools to the toolbar, add new dialog boxes. The plugin is actually only a SketchUp script in a specific directory.One of the biggest advantages of storing SketchUp commands in a script is that the commands need only be written once. The scripts can then be executed repeatedly. If you want to make changes to the scripts, they can be edited in the text editor.
WEB BASED VERSION
If you have used SketchUp to install on your computer, almost the same tools for creating and editing 3D models can also be found in the browser-based version. However, if the operating environment is a web browser, it will bring changes to some functions. In my opinion, this requires a bit of getting used to. You can log in to a browser-based SketchUp with a Trimble or Google ID.
TRIMBLE CONNECT PERSONAL VERSION
If a browser-based free version is used, limited storage space is used. In this version, it is possible to share files between five different users. The paid version has unlimited storage and files can be shared indefinitely with other users.
HOW TO CREATE WEB DIALOGS ?
This Blog deal with Google SketchUp Web Dialog and Plugins. SketchUp is a surface modeling program that lets you draw three-dimensionally. SketchUp is suitable for space planning and product design. It is also suitable for architectural design. In addition to SketchUp's basic tools, various add-ons are available for the program. Web Dialog allow you to add functionality to the SketchUp program. The add-ons are freely customizable to suit the user's needs.
RUBY API
Api is a common definition, which means that different programs can make requests and exchange information, that is, talk to each other. In the examples, the JavaScript code in Web dialog communicates with the Ruby On Rails code. Ruby On Rails is a plain text programming language and API is Application Programming Interface. Ruby Api gives the designer the ability to automate the SketchUp design process. There are also many other different development environments for script design. With Ruby Api, the designer can program additional add-ons so the design work is much more efficient.
CAD - DESIGN AND GOOGLE SKETCHUP
CAD designing means computer-aided designing that enables the user to create different 2- and 3-dimensional drawings. Drawings can be used in construction and manufacturing. There are many AutoCAD programs and there are many Plugins. It is possible to bring drawings from other Cad systems to Google SketchUp depending of the file format. One can example import a map with Google Earth terrain into SketchUp. Google SketchUp also allows you to export your drawings either as a 3D model or as a 2D graphics. You can also create animations from drawings.
GOOGLE SKETCHUP PLUGIN
These examples do not use volume models. All examples are surface models. Plugins allow surfaces to be selected together or individually. The number and range of surfaces can be calculated together or individually. The surfaces of the models can be rotated together or individually. All the number of pieces, surfaces and edges in the models can be calculated. The program code can be edited so that also template properties can be downloaded to the Web dialog. Or whatever the programmer wants. The possibilities are almost limitless. Additions may also be used as various combinations and are freely modifiable.
GEOMETRY
The geometry that SketchUp uses is made up of edges and surfaces. So, in SketchUp all geometry is created on edges and surfaces and each model uses these two building blocks. Basic surface consists of four edges and one surface. In the formation of the surface, at least three edges of the same level are required and the edges must form a loop. Also, the curved surfaces consist of smaller straight surfaces. Surfaces do not have a thickness.
JAVASCRIPT
JavaScript is a programming language that can increase web page interactivity. It enables user to create dynamically updating content to web pages. Things like animations, images and multimedia. It is an object-oriented language with prototypical inheritance. JavaScript supports several built in objects. Programmers can create or delete these objects. In these Plugins JavaScript communicates with Ruby On Rails scripting language.
THE RUBY WEB DIALOG CLASS
SketchUp can open Web Dialog instance, which is a browser window that is opened within SketchUp. It is possible to make calls from SketchUp to web page or from web page to SketchUp using JavaScript. In these examples Java Script communicates with Ruby. Document files can be stored in the SketchUp plugin folder. They can also be launched via the Ruby console. Data can be shared between Java Script and Ruby. So one can utilized Ruby Api. It provides two mechanism. One can define a Ruby method that a web dialog can call. Second can send data from Ruby to Java script.
So, using these two mechanisms we can create communication between Ruby and JavaSript. When SketcUp starts html and rb files are downloaded from the plugins file. The Rb file defines the properties of the web dialog, such as width, and height.
AREA AND FACE PLUGIN
The geometry that Sketch Up uses is made up of edges and surfaces. So, in Sketch Up all geometry is created on edges and surfaces and each model uses these two building blocks. The basic surface consists of four edges and one surface. In the formation of the surface, at least three edges of the same level are required. The edges must form a loop. The surfaces and edges do not have a thickness and also the curved surfaces consist of smaller flat surfaces.
ENTERING VALUES
Web Dialog interface allows you to enter the values of the drawing you create, such as width or height. Since Ruby can communicate with JavaScript, data from the drawing can be sent also for Web Dialog. This Plugin draw face and counts the area. The width of the face can be given through the plugin interface. Plugin draws the defined surface and calculates its surface area.
Short explanation how the program works
We are creating a Web Dialogue instance called "wd". The title of the dialog is called "Face Drawing". Next we define the dialog so that it has a scroll bar. The register information is stored in the "Info" file. Then, we define the size of the window, ie width and height, and that the size of the window can not be changed. Next we are using add_action_callback method so Ruby is waiting a contact from JavaScript. When button is pressed, the "message" value is passed from WebDialog to Ruby. Then we convert the string value to integer and set the value to variables named "depth" and "width". Next, we define the geometric points according to the the given values. The Ruby code adds the surface to the generated points and calculates its field. Ruby transfers the information to the Web Dialog who reported it. Information is also displayed on the Ruby panel Finally we show the WebDialog.
DRAWING SURFACE AND CALCULATING AREA
The starting point of the surface is 0.0.0. The program draws the surface and automatically calculates the range. Surfaces can be drawn to the desired amount. Plugins allow surfaces to be selected together or individually. Number and range of surfaces can be calculated together or individually. The surfaces of the models can be rotated together or individually. All the number of pieces, surfaces and edges in the models can be calculated. The program code can be edited so that also template properties can be downloaded to the Web dialog.
SURFACE MODELS
These examples do not use volume models. All examples are surface models. Plugins allow surfaces to be selected together or individually. The number and range of surfaces can be calculated together or individually. The surfaces of the models can be rotated together or individually. Negative values can also be given. All the number of pieces, surfaces and edges in the models can be calculated. The program code can be edited so that template properties can be downloaded to the Web dialog. The possibilities are almost limitless.
SET ATTRIBUTES
Program "Set attributes" create two attribute dictionaries and sets attributes to selected objects. Attributes can then be read with "Get attributes" program. Attributes can also be deleted.
CONVERT AREA
This Plugin counts faces and entities and converts areas and show them in list view. The plugin opens an HTML page that converts the areas of the selected regions. The list view shows six units. Objects can be selected together or individually. If the objects are selected separately, two list displays can be opened, whereby the surface areas of the pieces can be compared.
CREATING SURFACES
When creating surfaces, you can choose different modes. Surfaces can be displayed or surfaces can be hidden from the geometry without changing it. If the surface is within a group and the group scale has been changed, the surface method returns the original scale. When the drawings and regions are selected, the program calculates the surface areas and changes them to different units. At the same time, several surface areas can be compared. All examples are surface models. Plugins allow surfaces to be selected together or individually. The number and range of surfaces can be calculated together or individually. All example files contain the HTML and RB files of the pages' examples. Files can be downloaded and stored in the Google SketchUp plug-in file folder. Files can also be downloaded via the Ruby panel with the command 'load example.rb'.
Short explanation how the program works
We are creating a Web Dialogue instance called "my_thi_dialog". The title of the dialog is called "Multi Actions". Next we define the dialog so that it has no scroll bar. The register information is stored in the "Selection Info" file. Then, we define the size of the window, ie width and height, and that the size of the window can be changed. Next we are using add_action_callback methods so Ruby is waiting a contact from JavaScript. When the button is pressed, the program checks the ruby code for the corresponding function name. Next, the Ruby code executes the loop of the selected item where it checks for the surface. In the case of a surface, the surface area is added to the variable "area_a". The variable values are moved to the array and are printed on the Ruby panel. The number and the area of the surfaces are reported. Next, the surface area is moved from Ruby to DHTML which runs a JavaScript code that converts the surface and displays them in the table view. Finally, we show the WebDialog.
ABOUT SURFACES
Wireframe: In this mode, the surfaces are invisible. Only edges are visible.
Hidden Line: Shows all surfaces of the template regardless of background color.
Shaded: In this mode, the colors of the surfaces appear.
Shaded with Textures: Materials appear.
Display Shaded Using All Same: This simplified color model uses the default edge and the rear colors.
X-Ray: In this space, you can look through the surfaces.
DEFINING WEB - DIALOG WITHIN SKETCHUP
To define a Web Dialog eight arguments are needed. First one is Web Dialog Name that appears in the upper left corner. If the Web Dialog has a scroll bar the Boolean value is true. If the scroll bar is not needed the Boolean value is false. Registry information contains the WebDialog definition information. Width defines the width of the Web Dialog as pixels. Height determines the height of the Web Dialog as pixels. Left defines Web Dialog distance from the left of the screen as pixels. Right defines Web Dialog distance from right of the screen as pixels. If the Web Dialog is need to be re sizable the Boolean value is true. False if Web Dialog is not re sizable. If you want to display the Web Dialog on the top, you can use the method bring_to_front.
DRAWING CLASS
In the example three drawing objects have been created in the Ruby class. Drawing objects has been created by using the new method. Parameters are entered through the input box. In this example the initialize method is declared with name, depth, width and height. Def and end are used to define a Ruby method initialize and the values of these local variables are passed to the instance variables @draw_name, @draw_depth, @draw_width and @draw_height.
How it works ?
First, you define a Web Dialog instance named wd. Pressing a button opens a dialog box where you can enter the drawing information.In the example three drawing objects have been created in the Ruby class. Drawing objects has been created by using the new method. Parameters are entered through the input box. In this example the initialize method is declared with name, depth, width and height. Def and end are used to define a Ruby method initialize and the values of these local variables are passed to the instance variables @draw_name, @draw_depth, @draw_width and @draw_height.
EXTRUDE AND SELECT
This plugin can be used to calculate edges and surfaces of models. Surfaces can also be selected individually. The faces of the parts can also be individually selected and can be extruded. The plugin also counts the common area of all faces selected. Areas of the faces can also be count individually. PushPull Tool allows the surfaces to be pushed out or in. This example uses push pull method. The program pushes the selected surfaces out or in to the given value. Negative values can also be given to the surfaces. The program code can be edited so that also template properties can be downloaded to the WebDialog. Or whatever the programmer wants. Ruby Api gives the designer the ability to automate the SketchUp design process. With Ruby Api, the designer can program additional add-ons so the design work is much more efficient.
Short explanation how the program works
We are creating a Web Dialogue instance called "my_thi_dialog". The title of the dialog is called "Selection Info". Next we define the dialog so that it has no scroll bar. Then, we define the size of the window, ie width and height, and that the size of the window can be changed. Next we are using add_action_callback methods so Ruby is waiting a contact from JavaScript. When the button is pressed, the program checks the ruby code for the corresponding function name. Next, the Ruby code executes the loop of the selected item where it checks for the surface. In the case of a surface, the surface area is added to the variable "area_a". The number and the area of the surfaces are reported. Next, the surface area is moved from Ruby to DHTML which displays them. Finally, we show the WebDialog.
RACK PLUGIN
This Plugin creates a rack. The plugin defines five faces and two circles. Circles are duplicated with z axis. The width of the rack can be entered through the text field. In SketchUp all geometry is created on edges and surfaces and each model uses these two building blocks. The basic surface consists of four edges and one surface. In the formation of the surface, at least three edges of the same level are required. The edges must form a loop. So every surface must have at least three edges. The add-on draws the first surface from the point of 0.0.0. Next, the remaining four surfaces will be added to the value entered. Next, the loop defined in the program duplicates two circles in the z - axis direction.
Very short explanation how the program works
Creating a web Dialog instance named "wd". Define its features. In Web Dialog, enter values for variables "depth" and "width". Next, tell to the program : Form the surfaces in three - dimensional space and duplicate the generated circle along the z - axis.
ROTATION TOOL
This Plugin rotates objects along X - Y - Z axes. The plugin allows you to choose the faces of the tiled surface individually or in combination. The piece or face can be rotated by the x, y or z axis. Axis of rotation is defined by software. Thus, the selected object can be rotated in relation to any axis in three dimensional space. If all objects are selected, they can be rotated around the selected axis. Rotation rates can be entered through the user interface. The plugin can rotate a single surface or a range of surfaces for any axis. Plugins allow surfaces to be selected together or individually. All examples are surface models and all plugins allow surfaces to be selected together or individually. These examples do not use volume models. The number and range of surfaces can be calculated together or individually. The surfaces of the models can be rotated together or individually. All the number of pieces, surfaces and edges in the models can be calculated.
Short explanation how the program works
We are creating a Web Dialogue instance called "wd". The title of the dialog is called "Rotator". Next we define the dialog so that it has a scroll bar. The register information is stored in the "Info" file Then, we define the size of the window, ie width and height, and that the size of the window can not be changed. Next we are using add_action_callback method so Ruby is waiting a contact from JavaScript. When button is pressed, the "message" value is passed from WebDialog to Ruby. Then we convert the string value to integer and set the value to variable named "angle". Next, we define the geometric transfers according to the different axes and the program rotates the objects according to the given angles. Finally, we show the WebDialog.
STAIRS PLUGIN
The program draws the stairs according to the given value. Program has a loop that adds the surface every turn. The program then moves the surface every turn for a certain degree. The surface also moves in the direction of the z axis in each round until the stairs are drawn. Number of stairs, the staircase thickness, color and the angle of the stairs can be changed to different values in programs code.
Short explanation how the program works
The program draws the stairs according to the values' given. Program Creates a Web dialog with appropriate definitions. User enters the values through WebDialog for variable called the stairs. Ruby code defines a loop and form a group of surfaces. The loop creates the surface along of each rounds. The surface is moved by x and z axes for each loop round. With scripts is therefore possible to create and repeat complicated geometric forms. When it comes to repeat structures, scripts are very powerful tools.
model = Sketchup.active_model
entities = model.active_entities
for x in (0..100).step(4)
group = entities.add_group
stairentities = group.entities
face = stairentities.add_face [0,x,x],[x+90,x,x],[x+90,x+10,x],[0,x+10,x]
tr = Geom::Transformation.rotation([0,0,0],[0,0,1],x.degrees)
Sketchup.active_model.active_entities.transform_entities(tr,face)
face.material = "gray"
face.pushpull(10)
end
GEOMETRY
The geometry that SketchUp uses is made up of edges and surfaces. In SketchUp all geometry is created on edges and surfaces and each model uses these two building blocks. The basic surface consists of four edges and one surface.
CUBE
Cube consists of six surface and twelve edges. In the formation of the surface, at least three edges on the same level are required and the edges must form a loop. Then it is possible to give depth to the surfaces. So every surface must have at least three edges. The surfaces also do not have a thickness value.
MODEL CLASS METHODS
The Model object in SketchUp can provide information about the drawing by using Ruby methods. How to use Ruby methods in active model ? First we have to retrieve the current model object. Then we have to set the mod object which is equal to model object. Then we can use methods. In this case methods, entities and length.
mod = Sketchup.active_model
mod.entities.length
So we can count all entities of the Box ,,,, that is according to Ruby 18 ...
RUBY CLASS
First we create class called DrawFace. Then we create function called DrawingFunction ( In Ruby functions are called Methods ) Then we use entities method add_face to draw a surface. Finally, we create new object called FirstSurfing from DrawFace class and then we call the function ( or Method ) DrawingFunction to execute the drawing process.
class DrawFace
def DrawingFunction
mod = Sketchup.active_model
entities = mod.entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [100, 0, 0]
pts[2] = [100, 100, 0]
pts[3] = [0, 100, 0]
face = entities.add_face(pts)
puts " Surface Is Drawn "
puts " Surface area is"
puts face.area
end
end
FirstSurfing = DrawFace.new
FirstSurfing.DrawingFunction
USING LOOPS TO CREATE GEOMETRY
Duplicating objects ... for i in 0..100 ....
class DrawFace
def DrawingFunction
mod = Sketchup.active_model
entities = mod.entities
for i in 0..100
pts = []
pts[0] = [0, 0, i ]
pts[1] = [100, i, i ]
pts[2] = [100, 100, i]
pts[3] = [0, i, i ]
face = entities.add_face(pts)
end
end
end
FirstSurfing = DrawFace.new
FirstSurfing.DrawingFunction
DIFFERENCIES BETWEEN SKETCHUP AND AUTOCAD
The most important differences between Autocad and Sketchup are in my opinion users of these programs. Autocad also has extensive support for various interfaces. It is also possible to make various conversions between different file formats. Another important difference I think is that, because AutoCAD has many features and extensions that allow models to be customized to the user's needs, this requires the user to focus on the topic. On the other hand, the SketchUp interface is simpler and can be adopted relatively quickly. There are also differences in rendering details where Autocad seems to me to be more accurate. Autocad features numerous add-ons. This feature creates many opportunities to utilize this design software for complex projects. A database, such as Microsoft Access, can be integrated into the autocad, and this allows the necessary information to be transferred from the drawings to the database. It is also possible to use scripts, e.g., Lisp scripts,to transfer the information contained in the drawings to, for example, excel tables. SketcUp Pro can use predefined attributes to define dynamic components. Attributes can be, for example, x, y, z coordinates, coordinate lengths or coordinate angles. SketchUp is very versatile when it comes to utilizing Ruby scripts because with using Ruby it is possible to automate numerous SketchUp functions. It is also possible to access resources in the sketchup user interface utilizing ruby code. So if you want to programmatically select certain tool or activate certain functions you can use actions ( sketchup.send_action) . An action interacts with SketchUp and perform an operation related to its user interface. Actions allow you to activate tools or change rendering styles etc. This is very useful command and it speed up things and drawing process. You can example add scenes programmatically. ( Sketchup.send_action "pageAdd:" )
AutoCads data processing and extensions
Autocad's data processing is based on graphical objects so it's a vector graphics program.Graphic objects, lines, circles, texts, curves. Autocad's latest tools are also called surface tools. With these, it is possible to create basic forms of solid modeling. Available also an efficient rendering engine. Autocad is best suited for line drawing 2D or 3D design so it's not the actual 3D modeling program. However, certain software packages are available modeling software. (Suite software package with several language versions) Autocad is therefore a general design software and can be expanded with different application-specific extensions. Because the software has multiple interfaces, interfaces can be used to create many additional functions. The advantage of creating interfaces is that encoding. Many programming languages can be used. This is, in my opinion, a significant advantage that makes Autocad an popular application platform. Applications can be created for different tasks and fields.
SketchUp entities
Whenever we are creating line or face in SketchUp we are creating an entity. When we are combining lines or faces into a group or component we are creating a special group or component entity. Each entity contain specific attributes and it is possible to change these attributes with scripts.