[PythonCAD] Moving objects breaks dimensions

Art Haas ahaas at airmail.net
Mon Feb 13 17:14:33 CET 2006

On Mon, Feb 13, 2006 at 09:45:25AM -0600, Art Haas wrote:
> On Sat, Feb 11, 2006 at 09:37:37AM -0600, Art Haas wrote:
> > 
> > I see if I can duplicate this today. If you drew a box around the
> > dimension in addition to the entities then the dimension text should
> > have moved. Maybe there is a bug in determining that the dimension
> > was within the boxed region.
> Ugh. I found a stupid typo, but this does not completely resolve
> things. I am embarrassed ...

I've prepared a better patch. In addition to fixing the dumb typo
it resolves the problem where the DimString entities do not move.
The loop where users of Point entities needed to be touched up so
that the flag used to test moving Dimension entities is not set
to False.

Index: PythonCAD/Generic/move.py
--- PythonCAD/Generic/move.py	(revision 2166)
+++ PythonCAD/Generic/move.py	(revision 2168)
@@ -34,7 +34,7 @@
 from PythonCAD.Generic.leader import Leader
 from PythonCAD.Generic.polyline import Polyline
 from PythonCAD.Generic.text import TextBlock
-from PythonCAD.Generic.dimension import Dimension
+from PythonCAD.Generic.dimension import Dimension, DimString
 from PythonCAD.Generic.dimension import LinearDimension
 from PythonCAD.Generic.dimension import AngularDimension
 from PythonCAD.Generic.layer import Layer
@@ -576,9 +576,12 @@
         _objdict = {}
         _fillets = []
         for _obj in objs:
-            _objdict[id(_obj)] = True
+            if not isinstance(_obj, DimString):
+                _objdict[id(_obj)] = True
         for _obj in objs:
             _oid = id(_obj)
+            if _oid not in _objdict:
+                continue
             if _objdict[_oid]:
                 if isinstance(_obj, Point):
                     _obj.move(_dx, _dy)
@@ -586,7 +589,8 @@
                         _user = _uref()
                         if _user is not None:
                             _uid = id(_user)
-                            if _uid in _objdict:
+                            if (_uid in _objdict and
+                                not isinstance(_user, Dimension)):
                                 _objdict[_uid] = False
                 elif isinstance(_obj, (Segment, CLine)):
                     _move_seg_cline(_obj, _objdict, _dx, _dy)
@@ -599,7 +603,7 @@
                 elif isinstance(_obj, Polyline):
                     _move_polyline(_obj, _objdict, _dx, _dy)
                 elif isinstance(_obj, (TextBlock, Dimension)):
-                    _obj.move(_nx, _ny)
+                    _obj.move(_dx, _dy)
                 elif isinstance(_obj, (HCLine, VCLine, ACLine)):
                     _move_spcline(_obj, _objdict, _dx, _dy)
                 elif isinstance(_obj, (Chamfer, Fillet)):

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