Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to see if a linesegment intersects a surfacebody, but I keep getting a Run time error (Method 'IntersectWithSurface' of object 'LineSegment' failed)
This is the code:
Private Function cableClash(p1 As Point, p2 As Point) As Boolean ' Create a linesegment Dim l As LineSegment Set l = ThisApplication.TransientGeometry.CreateLineSegment(p1, p2) ' Set part in which the surface is Dim str As String: str = "C:\Workspace\Documents\Projects\2018\TWD-NL-2018-066\REFERENCES\VESSEL OUTLINE_TWD20180507145730678.ipt" Dim prt As PartDocument Set prt = ThisApplication.Documents.Open(str, False) ' Set the surface Dim surf As Object Set surf = prt.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Item(1).SurfaceBodies.Item(1).SurfaceBodies.Item(1) ' On Error Resume Next Dim out As ObjectsEnumerator Set out = l.IntersectWithSurface(surf) End Function
I've also tried to just say
If l.IntersectWithSurface(surf).Count <> 0 Then
All give the same runtime error..
How do I get this method to work?
Solved! Go to Solution.