Draft: project point in split operation and copy original wire (#22452)
* Roy 043 patch 1 (#6) * Update split.py * Update gui_split.py * Add recompute to update wire in split test * Avoid circular import: init_draft_statusbar -> params -> init_draft_statusbar * Remove accidentally added "ui/preferences-webgl.ui"
This commit is contained in:
@@ -27,9 +27,8 @@
|
||||
|
||||
## \addtogroup draftfunctions
|
||||
# @{
|
||||
import draftutils.utils as utils
|
||||
import draftmake.make_wire as make_wire
|
||||
|
||||
from draftmake import make_copy
|
||||
from draftutils import utils
|
||||
|
||||
def split(wire, newPoint, edgeIndex):
|
||||
if utils.get_type(wire) != "Wire":
|
||||
@@ -41,12 +40,11 @@ def split(wire, newPoint, edgeIndex):
|
||||
|
||||
def split_closed_wire(wire, edgeIndex):
|
||||
wire.Closed = False
|
||||
new = make_copy.make_copy(wire)
|
||||
if edgeIndex == len(wire.Points):
|
||||
new = make_wire.make_wire([wire.Placement.multVec(wire.Points[0]),
|
||||
wire.Placement.multVec(wire.Points[-1])], placement=wire.Placement)
|
||||
new.Points = [wire.Points[0], wire.Points[-1]]
|
||||
else:
|
||||
new = make_wire.make_wire([wire.Placement.multVec(wire.Points[edgeIndex-1]),
|
||||
wire.Placement.multVec(wire.Points[edgeIndex])], placement=wire.Placement)
|
||||
new.Points = [wire.Points[edgeIndex-1], wire.Points[edgeIndex]]
|
||||
wire.Points = list(reversed(wire.Points[0:edgeIndex])) + list(reversed(wire.Points[edgeIndex:]))
|
||||
return new
|
||||
|
||||
@@ -55,19 +53,23 @@ splitClosedWire = split_closed_wire
|
||||
|
||||
|
||||
def split_open_wire(wire, newPoint, edgeIndex):
|
||||
new = make_copy.make_copy(wire)
|
||||
wire1Points = []
|
||||
wire2Points = []
|
||||
for index, point in enumerate(wire.Points):
|
||||
if index == edgeIndex:
|
||||
wire1Points.append(wire.Placement.inverse().multVec(newPoint))
|
||||
edge = wire.getSubObject("Edge" + str(edgeIndex))
|
||||
newPoint = wire.Placement.inverse().multVec(edge.Curve.projectPoint(newPoint))
|
||||
wire1Points.append(newPoint)
|
||||
wire2Points.append(newPoint)
|
||||
wire2Points.append(wire.Placement.multVec(point))
|
||||
wire2Points.append(point)
|
||||
elif index < edgeIndex:
|
||||
wire1Points.append(point)
|
||||
elif index > edgeIndex:
|
||||
wire2Points.append(wire.Placement.multVec(point))
|
||||
wire2Points.append(point)
|
||||
wire.Points = wire1Points
|
||||
return make_wire.make_wire(wire2Points, placement=wire.Placement)
|
||||
new.Points = wire2Points
|
||||
return new
|
||||
|
||||
|
||||
splitOpenWire = split_open_wire
|
||||
|
||||
Reference in New Issue
Block a user