Here's the idea; I'm doing house plans and site plans from existing
hard copy plans - scan in the plan, trace it, and make changes in
SketchUp, which is the usual way to do it. I am used to panning and
moving around, but sometimes it gets frustrating. There are lots of
applications where I want to do 2D only for a while, often without a
picture, and then switch to 3D, and sometimes back and forth. Mostly
this can be done using Scenes, turn off perspective, etc. However,
when I don't have a picture or have moved on to adjusting things and
the picture is no longer useful, I don't want to keep drawing on an
existing picture or face, I just want to draw lines in 2 dimensions
only, on the XY (or Red/Green if you prefer) plane.
Sometimes I think it would be easier to lock things into 2D. Is there
a way to do a ruby that would *lock* the camera into Top view with
perspective off, and then toggle back to whatever it was switched
from? I know switching pages would work, but that requires setting up
pages every time, on every model.
I realize all these things can be done with existing tools/shortcuts,
except for locking the camera to only pan with the mouse wheel without
having to hold Shift. I hate clicking or shortcut-ing the pan tool,
and it's annoying when I forget to hold shift and have to keep pushing
the "top" button again.
So, overall, not a big thing. I know that I can already do all this -
with several commands instead of one - but Ruby scripting is all about
simplifying and optimizing the way I want to work, right? I'm sure
other people would have use for this too; anyone else get tired of
reading all the posts asking basic questions, often about 2D/3D
issues, to which the answer is always RTFM?
2D TOOL DESCRIPTION AND METHODOLOGY
I don't know enough ruby for this, but I do know that this can be done
and I think I have come up with a reasonably simple way to do it using
existing tools. Basically all I want is a button (shows on/off similar
to the Show Section Planes button, for instance) that wraps up several
commands and toggles them all together as follows:
When "2D" is turned On: switch to top view if not already there, turn
perspective off, and lock camera to pan only (which is probably the
tricky part) when using the mouse wheel. I don't know enough about
ruby to know if you can change the button definition to the Pan tool
and back, or if you can just lock on the Shift modifier for the tool,
which would act the same way.
Then when 2D is turned Off, switch perspective or || projection back
on (whichever was in use before) and give the mouse button back it's
usually functionality. Also, maybe switch to another view, such as
wherever the camera position was before 2D mode was activated or maybe
to a certain scene, but this wouldn't always be desirable. Maybe that
part could have an option setting somewhere if anyone wanted it.
Eventually I want to learn ruby myself, and this would probably be an
easy learning project, but I learn best by digging through other
people's scripts and looking at the pieces. I'd be happy to do the
button icon or having someone else do one if they want. Is anyone up
to tackling such a tool?
Are you looking for a free script, or is this something that you could
justify from a business perspective?
Todd
Here's your first minimal help.
The complete list of classes and methods you'll be choosing from are
in SketchUp Help>Ruby Help.
Classes and methods you will be interested in are:
Camera.set to reposition the camera.
Camera.perspective to query and set the perspective.
You'll want to write a Tool class to force lines, rectangles, circles,
etc. to only be drawn on the X/Y plane.
You'll want an Observer to follow the user's camera movement, to keep
it pointing down. (This is the part I have not researched myself, but
it should be available in V6.)
You'll want to use the methods in the Toolbar class to add buttons/
Icons for tools.
That should get you started. There are many free scripts out there
that will show you how to use each of the classes and methods
mentions, with the exception of the Camera Observer. Save that for
last. Then, come back, and we can work through it together.
Todd
Todd
What about this approach for a 2d drafting ruby - disabling an axis,
as opposed to changing perspectives and cameras etc ...
...
A ruby (eg connected to command buttons) that only allows drafting in
2 axes (ie DISABLES one axis).
That way, you could draw in 2d - safe in the knowledge that your
geometry wouldn't be wandering off in the blue (z) direction for
instance.
The buttons would allow you to draw in ANY 2 axes but not a third -
would be VERY useful.
Even drawing in this proposed 2d drawing mode I can still see that it
would be VERY useful to have the ability to be able to have a
perspective view on an object eg drawing detail on the gable end of a
building etc
.....
You could also use this feature then for drawing in plan mode with
perspective off if required - leaving it up to the user to change
cameras, perspectives etc as needed.
...
It would be a ruby that could lock both the red and green axes (for
example) - AT THE SAME TIME.
...
Regards
Howard L'
End quote.
This sounds like it could be easier to implement (?); however, what if
you want a plane that isn't axial, such as a gable on a building wing
that is 45 degrees from the rest of the house? In that case you'd
still need all 3 axes. Is there a simple way to constrain the line
being drawn to be perpendicular to the camera's line of sight? I
basically know the math for that (cos between vectors = 0) but not
sure how to check on the fly while the pencil (or whatever tool) is
moving and active...
Todd
Hey, this is your baby! You tell me! I would suspect that if you
want to constrain drawing to a given plane, you would want to know
what the plane is. Therefore, one technique you could use would be to
pick a face (which always has at a minimum 3 points) to choose your
plane. Otherwise, the user needs to tell you (through a series of
mouse picks) where to form the virtual drawing plane.
Also, constraining drawing to 2D does not dictate that the camera
vector be perpendicular to the plane.
As far as a distance... you have to pick that. Or, let the user pick
it with a single left click, and you can use the camera's direction to
derive your plane from that user-picked point (in which case the
camera would be perpendicular to the plane).
I'll look at your code.
Todd
Todd
Reposted .rb as .txt; should be good now.
Todd
Todd