[PythonCAD] rotating objects?

Art Haas ahaas at airmail.net
Tue Jun 6 16:19:45 CEST 2006

On Mon, Jun 05, 2006 at 06:23:55PM -0400, Russ Nelson wrote:
> Art Haas writes:
>  > to place the parallel line. Use a similar procedure for creating
>  > horizontal lines 13.55mm across. You then go to 'Draw'->'Segment' and
>  > draw segments on the box defined by the construction lines.
> Hrm.  Okay, I can make four angled construction lines, however there
> are only three intersections.  How do I define a point to snap to at
> the fourth intersection?
> Slowly .... I'm figuring out how to use this program.  It begs for a
> tutorial.

I agree 110%. The project needs documenting as well, more than the
various doc strings I've placed within the code. This is an area
that I could use help on, as I've not been good at writing the type
of documentation users and/or programmers need.

> If I have something selected, and then choose Modify/Delete, shouldn't
> that delete the selected things?

Yes it should, and I've committed the following changes to the program
so that any selected entities are deleted when you 'Modify'->'Delete'.
If you're pulling from the public repo then an 'svn update' will get
you the contents of the patch below.

> Shouldn't the scroll wheel zoom in and out on the thing you're
> pointing at?

Ideally yes, but I haven't written the code to tie the zoom operations
into a scroll event. I suspect this is not too hard to do, but it
may be more complicated. I also want to add code to make the image
view change when you press the arrow keys, and possibly the PageUp
and PageDown keys as well.

> If I select four points and the four segments connecting them, and
> then Edit/Copy, shouldn't Edit/Paste insert four points and segments?
> I'm only getting one point inserted.

The copy/paste routines are old, and need reworking. A problem I've
always had was in handling the Paste operation is in determining
just where to put any copied entities. If I draw a segment, select it,
then copy it, when I try to paste it do I put an endpoint or the
middle of the segment at the location where the mouse was clicked?
There needs to be some sort of reference point used in these operations.

>  > The use of construction lines is how PythonCAD is designed to create
>  > drawings.
> Indeed!  They're practically a requirement.
>  > No, I haven't. Python offered an XML parsing module making the format
>  > easy to deal with, and when I started this project it fit the bill.
> Maybe better for me to add the features I want within PythonCAD
> .... like rotate.

Adding a Rotate operation would be great.

Art Haas

Index: PythonCAD/Interface/Gtk/gtkmodify.py
--- PythonCAD/Interface/Gtk/gtkmodify.py	(revision 2363)
+++ PythonCAD/Interface/Gtk/gtkmodify.py	(revision 2364)
@@ -361,9 +361,19 @@
     return True
-def delete_mode_init(tool):
+def delete_mode_init(gtkimage, tool):
     tool.setHandler("button_press", delete_button_press_cb)
     tool.setHandler("initialize", delete_mode_init)
+    if gtkimage.hasSelection():
+        gtkimage.startAction()
+        try:
+            for _obj in gtkimage.getSelectedObjects():            
+                _layer = _obj.getParent()
+                if _layer is not None:
+                    _layer.delObject(_obj)
+        finally:
+            gtkimage.endAction()
+        gtkimage.redraw()
 # stretch operations
Index: PythonCAD/Interface/Gtk/gtkmenus.py
--- PythonCAD/Interface/Gtk/gtkmenus.py	(revision 2363)
+++ PythonCAD/Interface/Gtk/gtkmenus.py	(revision 2364)
@@ -816,7 +816,7 @@
     _tool = tools.DeleteTool()
     gtkimage.setPrompt(_('Click on the items you want to delete.'))
-    gtkmodify.delete_mode_init(_tool)
+    gtkmodify.delete_mode_init(gtkimage, _tool)
 def change_style_cb(menuitem, gtkimage):
     _st = gtkmodify.change_style_dialog(gtkimage)

Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822

More information about the PythonCAD mailing list