CAD_Sketcher
CAD_Sketcher copied to clipboard
Bevel Tool Supporting Lines For Constrained Points
Currently, when adding a bevel to a point that already has a dimensional constant it's behavior is this:
Let's add some supporting construction like creation for point that are beveled that are already constrained in some way like this:
I'm unsure if this should be "automatic" behavior, toggleable or modifier key initiated i.e. pressing shift while using the bevel tool
Just to be clear the resulting construction lines should be parallel to the original line thus supporting lines in any orientation.
This behavior is linked to: Cannot set Distance constraint to horizontal or vertical for lines [BUG] #459 It should be half solved if the PR on it is accepted: Checks for duplicate constraints. #461
The reason it happened is also because the distance constraint is set onto the line instead of its endpoints.
New behavior after merge of that PR would look like this:
So if the bevel tool would then add a coincident from the point to each line (and as TheMakerTales suggested maybe the two construction lines) it should be solved as well I think.
If you add the following else statement to "operators/bevel.py" at line 138 after the existing if statement it seems to do what it is supposed to:
# Remove original point if not referenced
if not is_entity_referenced(point, context):
context.scene.sketcher.entities.remove(point.slvs_index)
else:
ssc.add_coincident(point, seg1, sketch)
ssc.add_coincident(point, seg2, sketch)
This works for keeping the reference to arcs as well:
If the construction lines need to be added as well extra checks need to be done on the entities since that should not be done on arcs but only lines.
Good catch, can you open a PR?
If you also want the lines to be added, this seems to work well and I think it fully covers the initial request:
# Remove original point if not referenced
if not is_entity_referenced(point, context):
context.scene.sketcher.entities.remove(point.slvs_index)
else:
ssc.add_coincident(point, seg1, sketch)
ssc.add_coincident(point, seg2, sketch)
# add reference construction lines
sse = context.scene.sketcher.entities
for i in range(0, 2):
if isinstance(self.connected[i], SlvsLine2D):
target = sse.add_line_2d(point, self.points[i], sketch)
target.construction = True
elif isinstance(self.connected[i], SlvsArc):
target = sse.add_arc(sketch.wp.nm, self.connected[i].ct, self.points[i], point, sketch)
target.construction = True
if target.angle > HALF_TURN:
target.invert_direction = True
Would you prefer it this way or rather without the construction lines?