Problems using IntersectWith method iCAD 7.2

The following code is within a blank userform with the command button placed on it. The code is taken straight from progeCAD help. Running it results in an "out of memory" error.

Code: Select all

Private Sub CommandButton4_Click()
    Dim myLine1 As IntelliCAD.Line
    Dim myLine2 As IntelliCAD.Line

    Set myLine1 = ThisWorkspace.ActiveDocument.ModelSpace.AddLine(Library.CreatePoint(4, 4), Library.CreatePoint(7, 1))

    Set myLine2 = ThisWorkspace.ActiveDocument.ModelSpace.AddLine(Library.CreatePoint(5, 2), Library.CreatePoint(8, 4))

    ' Find the intersection point.
    Dim intPoints As points
    Set intPoints = myLine1.IntersectWith(myLine2, vicExtendNone)
    ' Above line creates "out of memory" error.
    msgbox "Intersection point: " & Chr(13) & Chr(13) & "x = " & intPoints.Item(1).X & Chr(13) & "y = " & intPoints.Item(1).Y & Chr(13) & "z = " & intPoints.Item(1).Z
End Sub

I tested the above code after writing this out (in the same isolated userform). The below code results in an "Object does not support this action" error, when selecting two circles that intersect each other. When using it on the lines that the above code draws in modelspace, it results in the same "out of memory" error.

Code: Select all

Dim shape1 As IntelliCAD.Entity
Dim shape2 As IntelliCAD.Entity
Dim pickpt As IntelliCAD.POINT
Dim intPoints As points

Private Sub CommandButton1_Click()
    ThisWorkspace.ActiveDocument.Utility.GetEntity shape1, pickpt, "Choose 1st shape"
End Sub

Private Sub CommandButton2_Click()
    ThisWorkspace.ActiveDocument.Utility.GetEntity shape2, pickpt, "Choose 2nd shape"
End Sub

Private Sub CommandButton3_Click()
    msgbox "SHAPE 1 | " & "Name: " & shape1.EntityName & " | Type: " & shape1.EntityType
    msgbox "SHAPE 2 | " & "Name: " & shape2.EntityName & " | Type: " & shape2.EntityType
    Set intPoints = shape1.IntersectWith(shape2, vicExtendNone)

End Sub
Last edited by Accuright on Tue Apr 16, 2013 11:21 am, edited 1 time in total.


Upgrading to the NEWEST build v7.2.4141 03/07/2013 release resolved this issue. Will post as to other issues resolved by intsalling this build.

HOWEVER, still working on making this method work with two intersecting circles (math: a circle can not intersect a circle with same radius in only one place. There must be two intersecting points).

Re: Problems using IntersectWith method iCAD 7.2

Not sure the issue with old version, but the built v9.2 work fine.
Refer the sub "adding points at intersection of two curve".

Code: Select all

Public Sub AddPointAtIntersect()
    On Error Resume Next    
    Dim ent1 As IntelliCAD.Entity
    Dim ent2 As IntelliCAD.Entity
    Dim pickpt As IntelliCAD.point
    Dim intPoints As Points
    ThisWorkspace.ActiveDocument.Utility.GetEntity ent1, pickpt, Chr(13) & "Choose first curve:"

    ThisWorkspace.ActiveDocument.Utility.GetEntity ent2, pickpt, Chr(13) & "Choose second curve:"   

    Set intPoints = ent1.IntersectWith(ent2, vicExtendNone)

    Dim count As Long
    count = intPoints.count
    Dim point As IntelliCAD.PointEntity
    Dim i As Integer
    For i = 0 To count - 1
        Set point = ThisWorkspace.ActiveDocument.ModelSpace.AddPointEntity(intPoints.Item(i))
        'MsgBox "Intersection point " & i + 1 & ": " & Chr(13) & Chr(13) & "x = " & intPoints.Item(i).x & Chr(13) & "y = " & intPoints.Item(i).y & Chr(13) & "z = " & intPoints.Item(i).z

End Sub