CAD_Sketcher icon indicating copy to clipboard operation
CAD_Sketcher copied to clipboard

Bevel Tool Supporting Lines For Constrained Points

Open TheMakerTales opened this issue 2 years ago • 5 comments

Currently, when adding a bevel to a point that already has a dimensional constant it's behavior is this:

Capture1

Let's add some supporting construction like creation for point that are beveled that are already constrained in some way like this:

Capture

I'm unsure if this should be "automatic" behavior, toggleable or modifier key initiated i.e. pressing shift while using the bevel tool

TheMakerTales avatar Jun 08 '23 08:06 TheMakerTales

Just to be clear the resulting construction lines should be parallel to the original line thus supporting lines in any orientation.

TheMakerTales avatar Jun 22 '23 14:06 TheMakerTales

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: image

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.

TimStrauven avatar Apr 18 '24 15:04 TimStrauven

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: image

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.

TimStrauven avatar Apr 19 '24 15:04 TimStrauven

Good catch, can you open a PR?

hlorus avatar Apr 19 '24 16:04 hlorus

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

image image image image

Would you prefer it this way or rather without the construction lines?

TimStrauven avatar Apr 19 '24 16:04 TimStrauven