Ah, I had forgotten about that interface (also, it seems the "e" key only works after I used the alt+click alternative once or so, weird). Seems a bit of a weird place to edit the properties of the entire object being edited, but realizing that you could be editing multiple draft objects at the same time, I guess it makes some sense. Even more, it seems there is already an "invert arc" command there. I originally thought that this was essentially the same thing, but later I realized this did not actually reverse the direction of the arc, but the size (i.e. replace a 90° arc with a 270° one), actually *without* reversing the direction.
In the impression that invert arc was the same thing for arc, I actually started implementing this a bit, but I didn't like just adding an "invert wire" option similar to "invert arc", too much boilerplate duplication of code IMHO. Also, it seems weird to do the actual inversion in some gui class, IMHO that should be done in the Proxy class itself so it's easy to call it from other places / scripts too. I made a start adding a `canInvertDirection` and `invertDirection` method to DraftObject, to be overridden by subclasses, but then I realized that really only wires can invert their direction (arcs always run in the same direction defined by Part.makeCircle/BRepBuilder it seems), rectangles always use the same order of wires as well, etc. This means that inverting really is only possible for wires. For other shapes you might still want to be able to invert the direction of the produced Face, but other than rotating using Placement (with all the complexities for non-symmetrical objects), or adding a "InvertFace" attribute (probably a bad idea, enough attributes already) I am not sure how exactly. I got a bit demotivated by this, and stopped implementing again.
Yeah, I thought about that, but it seems like a menu that quickly gets flooded with editing options, so things must be added there sparingly. It is probably the easiest place to discover, though.
I initialy the best place would be the sidebar in edit mode, i.e. here:
But looking at the code, there seems to be a lot of generalization in place there, and the possibility of editing multiple objects made this a bit less obvious than I thought. Also, again a lot of boilerplate for adding a button there, so I'm not sure I'm going to bother here.
For future reference, though, to reverse the direction of a wire, the following Python code seems to work:
Code: Select all
obj.Points, obj.Start, obj.End = reversed(obj.Points), obj.End, obj.Start
I had one more thought, though: Currently, the direction that the face produced by a wire has, depends on the order in which points were drawn (CCW = up, CW = down). This in itself is actually a bit surprising, given that all other objects (circle, rectangle) seem to produce a face with the forward direction up (in the current working plane, so the positive Z direction before Placement). It would be IMHO sane if a wire behaved the same, both for consistency, and because that's usually what you want (draw a face and then extrude upward).
An obvious way to fix this is to just modify the Wire execute method to, when making a face, reverse the points if they would produce a downward face. However, this is going to break backward compatibility (where people might have added additional rotation or negative extrusion height or so to compensate for the reversed face). Also, this assumes that all points are actually in the Z=0 plane, which does not seem to be guaranteed (a wire does not need to be flat, or if it is flat, it might not be flat on another place). Note that I don't mean rotation in Placement, I mean the contents of Points that might not have Z=0.
Another fix would be to, when creating a wire, reverse the points if needed to ensure that they are always CCW, ensuring that the produced face is always upwards. This would be pragmatic, but might also surprise people when the order of their points changed (and if the order of points is ever relevant, this could also be problematic in addition to suprising). Maybe this could be solved with an extra option during wire creation ("Wire direction: As drawn / Produce upwards face"), though.