Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExtensionLine / DimensionLine complain that start > end #620

Open
jdegenstein opened this issue May 8, 2024 · 0 comments
Open

ExtensionLine / DimensionLine complain that start > end #620

jdegenstein opened this issue May 8, 2024 · 0 comments

Comments

@jdegenstein
Copy link
Collaborator

This code is adapted from docs/objects_2d.py:

std = Draft()

# [ExtensionLine]
with BuildSketch() as e_line:
    with BuildLine():
        l1 = Polyline((20, 40), (-40, 40), (-40, -40), (20, -40))
        RadiusArc(l1 @ 0, l1 @ 1, 50)
    make_face()
    edg = e_line.edges().sort_by(Axis.X)[0]
    ExtensionLine(border=edg, offset=10, draft=std)
    outside_curve = e_line.edges().sort_by(Axis.X)[-1]
    ExtensionLine(border=outside_curve, offset=10, label_angle=True, draft=std)

# [TechnicalDrawing]
with BuildSketch() as tech_drawing:
    with Locations((0, 20)):
        add(e_line)
    TechnicalDrawing()

Returns:

ValueError                                Traceback (most recent call last)
     24     ExtensionLine(border=edg, offset=10, draft=std)
     25     outside_curve = e_line.edges().sort_by(Axis.X)[-1]
---> 26     ExtensionLine(border=outside_curve, offset=10, label_angle=True, draft=std)
     28 # [TechnicalDrawing]
     29 with BuildSketch() as tech_drawing:

File c:\Users\someuser\.conda\envs\ocp_vscode\Lib\site-packages\build123d\drafting.py:562, in ExtensionLine.__init__(self, border, offset, draft, sketch, label, arrows, tolerance, label_angle, project_line, mode)
    560     e_line_shape = sweep(line_pen, extension_line, mode=Mode.PRIVATE)
    561     e_lines.append(e_line_shape)
--> 562 d_line = DimensionLine(
    563     dimension_path,
    564     draft,
    565     sketch,
    566     label,
    567     arrows,
    568     tolerance,
    569     label_angle,
    570     mode=Mode.PRIVATE,
    571 )
    572 self.dimension = d_line.dimension  #: length of the dimension
    574 e_line_sketch = Sketch(children=e_lines + d_line.faces())

File c:\Users\someuser\.conda\envs\ocp_vscode\Lib\site-packages\build123d\drafting.py:410, in DimensionLine.__init__(self, path, draft, sketch, label, arrows, tolerance, label_angle, mode)
    406 if label_length + arrows.count(True) * draft.arrow_length < path_length:
    407     shaft_length = (path_length - label_length) / 2 - draft.pad_around_text
    408     shaft_pair = [
    409         path_obj.trim(0.0, shaft_length / path_length),
--> 410         path_obj.trim(1.0 - shaft_length / path_length, 1.0),
    411     ]
    412 else:
    413     shaft_length = 2 * draft.arrow_length

File c:\Users\someuser\.conda\envs\ocp_vscode\Lib\site-packages\build123d\topology.py:7785, in Wire.trim(self, start, end)
   7783     u_start = edge.param_at_point(trim_start_point)
   7784     u_end = edge.param_at_point(trim_end_point)
-> 7785     edge = edge.trim(u_start, u_end)
   7786 elif contains_start:
   7787     u_value = edge.param_at_point(trim_start_point)

File c:\Users\someuser\.conda\envs\ocp_vscode\Lib\site-packages\build123d\topology.py:4609, in Edge.trim(self, start, end)
   4594 """trim
   4595 
   4596 Create a new edge by keeping only the section between start and end.
   (...)
   4606     Edge: trimmed edge
   4607 """
   4608 if start >= end:
-> 4609     raise ValueError(f"start ({start}) must be less than end ({end})")
   4611 new_curve = BRep_Tool.Curve_s(
   4612     copy.deepcopy(self).wrapped, self.param_at(0), self.param_at(1)
   4613 )
   4614 parm_start = self.param_at(start)

ValueError: start (0.8165271836783728) must be less than end (0.0)

I have also observed some non-repeatable sporadic behavior in which this fails on the first call to ExtensionLine (in the same way as above). Perhaps the line is reversed at some point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant