Quantcast
Channel: Manufacturing DevBlog
Viewing all articles
Browse latest Browse all 518

Cannot extrude sketch geometry

$
0
0

By Adam Nagy

You may have created sketch curves that overlap, but their end points do not meet, so you cannot extrude the area they enclose. Actually, the end points of the curves do not need to coincide in order to be recognised as a profile; it's enough if the curves are tied together with points - i.e. there is a point that is constrained to be coincident with both curves.

So if you start with something like this:

Sketch1

Then you can use the following VBA code to solve the problem:

Public Sub AddSketchPoints()' You need to be in Sketch environment
  Dim sk As PlanarSketch
  Set sk = ThisApplication.ActiveEditObject' This expects to have the sketch' entities shown in the picture:' straight lines on each side connected' by arcs
  Dim lines As SketchLines
  Set lines = sk.SketchLines
  Dim arcs As SketchArcs
  Set arcs = sk.SketchArcs' Create 4 points and constrain each to' a line and an arc
  Dim pts As SketchPoints
  Set pts = sk.SketchPoints
  Dim gc As GeometricConstraints
  Set gc = sk.GeometricConstraints
  Dim line As SketchLine
  Dim arc As SketchArc
  For Each line In lines
    For Each arc In arcs' Temporarily fix the line and arc so' they do not move around
      Dim gnd(1) As GroundConstraint
      Set gnd(0) = gc.AddGround(line)
      Set gnd(1) = gc.AddGround(arc)' Does not matter where we place' it initially
      Dim pt As SketchPoint
      Set pt = pts.Add(line.StartSketchPoint.Geometry)' Now constrain it to a line' and an arc
      Call gc.AddCoincident(arc, pt)
      Call gc.AddCoincident(line, pt)' Delete the temporary constraints
      Call gnd(0).Delete
      Call gnd(1).Delete
    Next
  Next
End Sub

Sketch2

Now this can be extruded:

Sketch3

 


Viewing all articles
Browse latest Browse all 518

Trending Articles