IntersectWithSurface method

IntersectWithSurface method

basnederveen
Advocate Advocate
373 Views
1 Reply
Message 1 of 2

IntersectWithSurface method

basnederveen
Advocate
Advocate

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?

0 Likes
Accepted solutions (1)
374 Views
1 Reply
Reply (1)
Message 2 of 2

basnederveen
Advocate
Advocate
Accepted solution

Found it already. You cannot use surfacebodies, only 

 

LineSegment.IntersectWithSurface Method

Input object. This can be a Plane, Cone, Cylinder, EllipticalCone, EllipticalCylinder, Sphere, Torus or a BSplineSurface.