Find if Feature edge is Normal to Workplane In Part

Find if Feature edge is Normal to Workplane In Part

cencinaNB2ET
Advocate Advocate
681 Views
5 Replies
Message 1 of 6

Find if Feature edge is Normal to Workplane In Part

cencinaNB2ET
Advocate
Advocate

Hello All,

 

I thought this was an easy step but after 5 hours of looking through the forum and the Net its not that straight forward it seems.

 

I create a sketch on a plane and the project feature edges to it.

I just need to find the edges that are closer to my plane since it projects all features.

Pic 1.PNGPic 2.PNG

 

The Code can identify the faces then the edges but I cant get a location of that edge because its a feature surface body edge?

 

I tried Face.geometry to attempt at getting the geometry of the surface body face.

 

Any ideas to avoid the back surface body feature to not be included on my face sketch?

 

 

 

 

 

 

 

0 Likes
682 Views
5 Replies
Replies (5)
Message 2 of 6

cencinaNB2ET
Advocate
Advocate
oTransGeom = ThisApplication.TransientGeometry
Dim oEdge As Edge
Dim oLine As Line
Dim oLineSeg As LineSegment
For Each oSurfaceBodies In oDef.WorkSurfaces
For Each oSurfaceBody In oSurfaceBodies.SurfaceBodies
MessageBox.Show(oSurfaceBody.Name)
For r = 1 To oSurfaceBody.Faces.Count
MessageBox.Show(oSurfaceBody.Name)
For Each oEdge In oSurfaceBody.Faces.Item(r).Edges
MessageBox.Show(oSurfaceBody.Name)
oLineSeg = oEdge.Geometry
MessageBox.Show(oSurfaceBody.Name)
oLine = oTransGeom.CreateLine(oLineSeg.StartPoint, oLineSeg.Direction.AsVector)
If oSketch.PlanarEntityGeometry.IsParallelTo(oLine) Then
MessageBox.Show(oSurfaceBody.Name)
Exit For
End If
Next
Next r
0 Likes
Message 3 of 6

cencinaNB2ET
Advocate
Advocate

I Manged to come up with a workaround...

basically placing a point in the middle of the edge loop and then measuring to the face/plane to see if its the correct one or not.

 

Although Im getting the opposite loop maybe someone can fix this? 

But its working for now...

 

 

y = 0
For Each oSurfaceBodies In oDef.WorkSurfaces
For Each oSurfaceBody In oSurfaceBodies.SurfaceBodies
For Each oFace In oSurfaceBody.Faces
For Each outerLoop In oFace.EdgeLoops
If outerLoop.IsOuterEdgeLoop = True Then
Exit For
End If
Next
y = y + 1
oWorkPoint = oDef.WorkPoints.AddAtCentroid(outerLoop)
oWorkPoint.Name = CStr(y) + " Point Face P" + CStr(f)
WorkPoint_Names.Add(oWorkPoint.Name)
Measures = Measure.MinimumDistance(CStr(y) + " Point Face P" + CStr(f),"Face P" + CStr(f))

If Measures < 30 Then
'MessageBox.Show(Measures)
For Each oEdge In oFace.Edges
isUsed = False
For Each checkEdge In usedEdges
If oEdge Is checkEdge Then
isUsed = True
Exit For
End If
Next
If Not isUsed Then
Call oSketch.AddByProjectingEntity(oEdge)
Call usedEdges.Add(oEdge)
End If
Next

End If

Next
Next
Next
0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor

Is the main part a solid or surface body? Is your sketch plane on the face of the part?  Is your sketch plane offset from the face of the part?  Why use sculpt instead of hole command or extrude circle sketch? Can you provide un-confidential file to experiment on?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 6

cencinaNB2ET
Advocate
Advocate

Its a solid with embedded surface bodies from sculpting.

Those holes were created from an assembly where multiple parts interact and change position. So I wrote a code that makes those holes by sculpting. All the parts in that assembly are derived so the workflow will be too hard to create holes or extrusions since its all connected. The sketch is made on a Workplane on the face of that part. Again that part is derived so need to avoid post creation of work planes etc.. as it unliks and links to ita parent assembly all the time. Hard to explain but trust me, tracking extrusions or Hole features will tenfold the complexity in this case.

0 Likes
Message 6 of 6

cencinaNB2ET
Advocate
Advocate

I'll post a file with the code that needs to run tomorrow. Remember it needs to iterate any given number of surfaces bodies on any given face. Determine which surface body cuts through what face and then collect those edges to project the circle entity onto a sketch that creates parameters measures the distance and then saves it all as userparameters.

0 Likes