# Sketchup breaking stuff?



## Vormulac (14 Aug 2006)

Hi all,

I finally have some time to build a very small project, but I thought instead of drawing it up on the back of an envelope it might be a good idea to learn Sketchup, especially seeing the amazing work posted on here using it. I have encountered a problem though and wondered if anyone else had found something similar.
I know I should grow up, but I play computer games, and after installing Sketchup Google (or whatever the free one is called) my current favourite, 'Battlefield2' would no longer run; I tried reinstalling it, removing Sketchup, even using the system restore (which I'm far from convinced actually does anything at all) and all to no avail. I can only assume Sketchup has done something driver-related and completely screwed up a part of the system critical to that particular game, I don't know yet if it's damaged anything else.
Has anyone else found anything similar?

Incidentally, concerning Sketchup, is it possible to Push/Pull in any direction other than one of the set planes? My little project has a lid that slopes at an 8 degree angle, but I tried to add an over-hang and the block just extended straight out, it didn't follow the 8 degree line of the rest of the object. (that probably doesn't make any sense, sorry)

I'd be interested to hear anyone's thoughts on either of these issues.

Thanks all,

V.


----------



## SketchUp Guru (14 Aug 2006)

Regarding your problem with the computer game, I have no idea. You might want to ask on the Google SketchUp forum for that. 

As to the Push/Pull question, no, P/P only moves a face along its normal. (perpendicular to the face) You can however use the Move tool to do what you want. Use a left to right selection box (Select arrow) to select only the part of the roof you wish to extend. Get the Move tool and drag the selection in the desired direction. You might find it easier to get the direction correct if you first draw a construction line as an extension to one edge of the roof. Look at the Help files on construction Geometry and the Tape Measure tool for that.


----------



## Steve Maskery (14 Aug 2006)

Sorry, no idea about the driver thing.

I'm not sure if this is what you want, but there is a Ruby plugin called "Push Pull in any direction", and is activated on a right-click of a face.

pushpull_tool.rb (needs to go in the Plugins directory)

Code below:


```
# Copyright 2004, @Last Software, Inc., modified by D. Bur

# Permission to use, copy, modify, and distribute this software for 
# any purpose and without fee is hereby granted, provided that the above
# copyright notice appear in all copies.

# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#-----------------------------------------------------------------------------
# Name        :   pushpulltool.rb
# Description :   A script to push pull faces along a vector given with 2 clicks
# Menu Item   :   Context menu->Pushpull tool
# Usage       :   Select faces, select "Pushpull tool" from the context Menu, then click 2 points on your model
# Date        :   11/02/2004
# Type        :   tool
#-----------------------------------------------------------------------------

require 'sketchup.rb'

class PushPull_Tool
def initialize
    $ss = Sketchup.active_model.selection
    $ip1 = nil
    $ip2 = nil
    @xdown = 0
    @ydown = 0
end

def activate
    $ip1 = Sketchup::InputPoint.new
    $ip2 = Sketchup::InputPoint.new
    @ip = Sketchup::InputPoint.new
    @drawn = false

    Sketchup::set_status_text "Length", SB_VCB_LABEL
    
    self.reset(nil)
end


def deactivate(view)
    view.invalidate if @drawn
end

def onMouseMove(flags, x, y, view)
    if( @state == 0 )
       
        @ip.pick view, x, y
        if( @ip != $ip1 )
            view.invalidate if( @ip.display? or $ip1.display? )
            $ip1.copy! @ip
            view.tooltip = $ip1.tooltip
        end
    else
        $ip2.pick view, x, y, $ip1
        view.tooltip = $ip2.tooltip if( $ip2.valid? )
        view.invalidate
        
        if( $ip2.valid? )
            length = $ip1.position.distance($ip2.position)
            Sketchup::set_status_text length.to_s, SB_VCB_VALUE
        end
        
        if( ([email protected]).abs > 10 || ([email protected]).abs > 10 )
            @dragging = true
        end
    end
end

def onLButtonDown(flags, x, y, view)

    if( @state == 0 )
        $ip1.pick view, x, y
        if( $ip1.valid? )
            @state = 1
            Sketchup::set_status_text "Second point", SB_PROMPT
            @xdown = x
            @ydown = y
        end
    else

        if( $ip2.valid? )
            self.create_geometry($ip1.position, $ip2.position,view)
            self.reset(view)
        end
    end
    
    view.lock_inference
end

# The onLButtonUp method is called when the user releases the left mouse button.
def onLButtonUp(flags, x, y, view)
    if( @dragging && $ip2.valid? )
        self.create_geometry($ip1.position, $ip2.position,view)
        self.reset(view)
    end
end

def onKeyDown(key, repeat, flags, view)
    if( key == CONSTRAIN_MODIFIER_KEY && repeat == 1 )
        @shift_down_time = Time.now
        if( view.inference_locked? )
            view.lock_inference
        elsif( @state == 0 && $ip1.valid? )
            view.lock_inference $ip1
        elsif( @state == 1 && $ip2.valid? )
            view.lock_inference $ip2, $ip1
        end
    end
end

def onKeyUp(key, repeat, flags, view)
    if( key == CONSTRAIN_MODIFIER_KEY &&
        view.inference_locked? &&
        (Time.now - @shift_down_time) > 0.5 )
        view.lock_inference
    end
end


def onUserText(text, view)

    return if not @state == 1
    return if not $ip2.valid?
    
    begin
        value = text.to_l
    rescue
        # Error parsing the text
        UI.beep
        puts "Cannot convert #{text} to a Length"
        value = nil
        Sketchup::set_status_text "", SB_VCB_VALUE
    end
    return if !value

    pt1 = $ip1.position
    vec = $ip2.position - pt1
    if( vec.length == 0.0 )
        UI.beep
        return
    end
    vec.length = value
    pt2 = pt1 + vec

    self.create_geometry(pt1, pt2, view)
    self.reset(view)
end


def draw(view)
    if( $ip1.valid? )
        if( $ip1.display? )
            $ip1.draw(view)
            @drawn = true
        end
        
        if( $ip2.valid? )
            $ip2.draw(view) if( $ip2.display? )
            
            view.set_color_from_line($ip1, $ip2)
            self.draw_geometry($ip1.position, $ip2.position, view)
            @drawn = true
        end
    end
end

# onCancel is called when the user hits the escape key
def onCancel(flag, view)
    self.reset(view)
end


# Reset the tool back to its initial state
def reset(view)
    @state = 0
    
    Sketchup::set_status_text("First point", SB_PROMPT)
    
    $ip1.clear
    $ip2.clear
    
    if( view )
        view.tooltip = nil
        view.invalidate if @drawn
    end
    
    @drawn = false
    @dragging = false
end

# Create new geometry when the user has selected two points.
def create_geometry(p1, p2, view)

model = Sketchup.active_model
model.start_operation "Push-Pull tool"
entities = model.active_entities
ss = model.selection

# Selection error checking
others = 0
i = 0
0.upto(ss.length - 1) do |something|
  element = ss[i]
  if( element.typename != "Face")
    others = others + 1
  end
  i = i + 1
end  #of upto

if( others != 0 )
  UI.messagebox( others.to_s + " objects in the selection aren't faces and will be ignored.")
end

dx = $ip2.position.x - $ip1.position.x
dy = $ip2.position.y - $ip1.position.y
dz = $ip2.position.z - $ip1.position.z


# process each face
current_face = 0

0.upto(ss.length - 1) do |pts|

if( ss[current_face].typename == "Face")
  pts = ss[current_face].vertices
  length_pts = pts.length

  # copy the selected face
  i = 0
  pts2 = []

  pts.each do |pt|
    pts2[i] = pt.position + [dx,dy ,dz]
    i = i +1
  end
  face_copy = entities.add_face pts2
  pts_copy = face_copy.vertices

  # create faces between pairs of vertices of each face
  i = 0
  j = 0

  0.upto(pts.length - 2) do |new_face| 
    new_face = entities.add_face(pts[i], pts_copy[i], pts_copy[i + 1], pts[i + 1])
    i = i + 1
  end    # of upto
  # close the shape
  new_face = entities.add_face(pts[pts.length - 1], pts_copy[pts.length - 1], pts_copy[0], pts[0])
end # of if == face
current_face = current_face + 1
end     #end of upto faces


#That's all folks
model.commit_operation

end

# Draw the geometry
def draw_geometry(pt1, pt2, view)
    view.draw_line(pt1, pt2)
end

end # class PushPull_Tool




#-----------------------------------------------------------------------------
# This functions is just a shortcut for selecting the new tool
def ex_pushpull_tool
    Sketchup.active_model.select_tool PushPull_Tool.new
end

if( not file_loaded?("pushpull_tool.rb") )

#UI.add_context_menu_handler do |menu| 
  #menu.add_separator("Pushpull Tool")
  #menu.add_item("Pushpull Tool") { ex_pushpull_tool }
  #end
    UI.add_context_menu_handler do |menu|
            menu.add_separator
            menu.add_item("Pushpull in any direction") { ex_pushpull_tool }
    end
end
#-----------------------------------------------------------------------------
file_loaded("pushpull_tool.rb")
```


----------



## SketchUp Guru (14 Aug 2006)

Good call Steve. I'd forgotten about that script. V, you can get that script here: http://www.crai.archi.fr/RubyLibraryDep ... ll_tool.rb and as Steve says, put it in your Plugins folder.

The method I outlined is useful to know, though because it can be used for resizing without changing scale.


----------



## Vormulac (14 Aug 2006)

That's terrific, thanks guys!  

I really like the look of this Sketchup package, it looks like the creation of the overall 'piece' is a lot easier than other cad packages I've looked at in the past, but how easy is it to work with at component level such as exploding your design down to it's individual bits and accurately sizing and then putting them together? I've done the tutorial videos on the sketchup site, but I guess there's a lot more to it!

V.


----------



## SketchUp Guru (14 Aug 2006)

It is easy enough to work at component level if you draw the components individually and either make them components or groups. Do a search in the Design forum here for my blathering about the use of groups and components.

You can pull the components away from each other as desired or put them on layers of their own and turn the layers on and off as desired. 

By the way, if you are working with layers, always, always, ALWAYS, keep layer 0 as the active layer. Move components or groups to other layers as needed but never make those layers active. With a simple model it wouldn't really be a big deal but it can really screw up your model if you start drawing stuff on different layers. 

If you haven't done so, take a look at the images in this thread: https://www.ukworkshop.co.uk/forums/view ... hp?t=11153 Every element I drew is either a group or component. The model could be disassembled into its parts and laid out as if you were disassembling the real machine. I didn't go nuts with the detailing so although there are screw heads, there aren't any bodies to them. Still, each element is drawn separately either in place or moved into place later.


----------



## Vormulac (14 Aug 2006)

Thanks for the advice, I'll certainly give it another go and see what happens 

That thread you linked to is one of the reasons I decided to take a look at Sketchup, that truly is a remarkable piece of work!

V.


----------



## Vormulac (14 Aug 2006)

Unfortunately I can't get that plug-in to do anything  And not being able to work properly in Metric is a bit of a pipper. The more I play with Sketchup the more I find it doesn't seem able to do things (ok, it's probably me not knowing the little tricks, but it does some odd things it seems to me). Shame, it's the most easily accessible cad package I've seen, but it's frustrating not being able to put together something incredibly simple because of little niggles.

V.


----------



## Steve Maskery (14 Aug 2006)

Vormulac":3m6iscbh said:


> Unfortunately I can't get that plug-in to do anything  And not being able to work properly in Metric is a bit of a pipper.



Hi V

Well it works fine for me! 

And what's the problem with metric? Have you got the metric template active? I use only metric, no problem.

Persevere! It's worth it.

Cheers
Steve


----------



## SketchUp Guru (15 Aug 2006)

V. Lets attack the metric thing first. Print out this post so you can follow along.

1. Open a new session of SU.
2. Go to Window>Model Info>Units.
3. Change Format to Decimal and select your desired metric format. (Millimeters?)
4. Set your desired Precision. Three places beyond the decimal ought to be fine.
5. Uncheck the box at "Enable Length Snapping."
6. Close the Model Info window for now.
7. Select the Rectangle tool and starting (left click) at the origin drag out a rectangle so that two of the edges are along the solid green and red axes. Click to set the opposite point.
8. Type in the dimensions for the rectangle. For the typical woodworking project you might be working inside a box that is perhaps 1500mm square. Type 1500,1500 and press Enter.
9. Select the Push/Pull tool and pull the square up into a box. Left click to start and again to stop the Push/Pull. Type 1500 to make the box 1500mm tall.
10. If you have a person standing around doing nothing, delete them from your drawing.
11. Click on the Zoom Extents button. this should fill the drawing window with the box you just drew. If you'd like to change the view a bit, orbit around the box and click Zoom Extents again. When you have a view you like move on to the next step.
12. If it isn't set already, set the view to Shaded. It's the little cube icon next to white cube icon.
13. If you have any funky rendering, (Endpoints, Jitter Edges, etc.) turned on, turn them off by unchecking them from the View>Rendering menu. I personally don't like to have Profile Edges turned on but they can be useful for some things. It's your choice whether you leave them on or not.
14. Triple click on the cube and delete it.
15. Go to File>Save As... Set the location as the Template folder under Google SketchUp in the Program Files.
16. Give the file a name you can remember for at least two minutes and save it.
17. Go to Window>Preferences>Template.
18. Select that file you save a few seconds ago and make sure it is displayed in the little box.
19. Close the Preferences window.
20. Close SU.

Now, when you open a new SU drawing, you should be able to work in millimters and you shouldn't have to zoom in so you can see your model.

Now, on to your Plugin thing. With SU not open, navigate in Windows Explorer to the Plugins folder in Google SketchUp. You should see a folder there called Examples. Open that and select the file called sketchup.rb. Copy that file and paste it directly into the Plugins folder. Now you probably have sketchup.rb and the push/pull script. Make sure the Push/Pull script has .rb as its extension.

Close Explorer and open SU. You should now see a Plugins menu that is probably empty. Drag out a rectangle and select the face. Right click on it and you should get a Push/Pull in any direction option. Now you can click at some point and drag in the direction of the desired Push/Pull.

As I said before, you might find it advantageous to set a construction line to follow to give you the correct direction.

Good luck.


----------



## Vormulac (15 Aug 2006)

Terrific! Thanks Dave 

That push/pull plugin seems a little random but I'm sure that's me needing practise, and it's a lot easier for me now it's in Metric (in real life I use both, but for precision work I find working in 1/72ths of something to be a bit surreal!).
I noticed that there's a template there for 'woodworking', any ideas what that does? (apart from stick the scale to Imperial once more I expect)

I shall continue to play with this now 

Does everyone use the free Sketchup Google program or has anyone found upgrading to the full package worthwhile?

Vormulac.


----------



## SketchUp Guru (15 Aug 2006)

I use SU5 because I bought it before Google bought @Last and released the free version. I do like the fact that I can output high resolution images and animations as well as DXF/DWG format files from SU.

As to the Push/Pull script, have you tried making a construction line to follow. I think you'll find that helps immensly. Here's an example.






Note that I ended up with some lines that don't look great. I used Delete Coplanar Edges to get rid of those. That's another script here: http://www.crai.archi.fr/RubyLibraryDep ... aredges.rb

The Woodworking template appears to set precision to 1/16" too. I prefer higher precision that offered by that template. It's easy enough to make your own anyway and you might find down the road that you want to modifiy it again which is also a simple matter.


----------



## Vormulac (15 Aug 2006)

I think I've gone about my little bit of creation buttocks-about-face. It's an outdoor project, so I wanted to run a drip groove on the underside the lid, so I was trying to use the p/p tool to extrude the cut-out for the groove down the (sloping) length of the lid edges I had already created - it was proving impossible. I guess if I had thought about it more I would simply have created the profile of the lid edge at the highest point and used the p/p to extrude that profile down the full length instead.
Reckon practise is going to be the key here...  

Thanks for all your help - I will doubtless be asking advice again in future!

Vormulac.


----------

