.NET

Reply
Distinguished Contributor
quigs
Posts: 143
Registered: ‎09-30-2008
Message 1 of 4 (634 Views)

Intersect with on 2011: 32 Bit. Win 7

634 Views, 3 Replies
09-23-2010 11:03 AM

Good day to all.

I have a routine that uses the “intersectwith” function, from AutoCAD 2009.

I recently upgraded to 2011, and I get the following error:

 

 

IntersectWith(entityPointer As Autodesk.AutoCAD.DatabaseServices.Entity,

intersectType As Autodesk.AutoCAD.DatabaseServices.Intersect,

points As Autodesk.AutoCAD.Geometry.Point3dCollection,

thisGraphicSystemMarker As Integer,

otherGraphicSystemMarker As Integer)' is obsolete: 'Use the overload taking IntPtr instead.'.

 

Does anyone know how to fix this, or maybe where there is an example?

 

Cheers,

 

Martin. :smileyvery-happy:

My name is Martin.. :smileyvery-happy:
Contributor
Jozi68
Posts: 25
Registered: ‎07-23-2009
Message 2 of 4 (347 Views)

Re: Intersect with on 2011: 32 Bit. Win 7

07-01-2011 03:00 AM in reply to: quigs

I have exactly the same problem.  Anyone?

Distinguished Contributor
quigs
Posts: 143
Registered: ‎09-30-2008
Message 3 of 4 (345 Views)

Re: Intersect with on 2011: 32 Bit. Win 7

07-01-2011 03:03 AM in reply to: Jozi68

Man this was a while ago!

I got an fix in the form aof a function from the great Tony T.

Here it is:

 

Imports System.Runtime.CompilerServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports System.Reflection


Public Module PlatformCompatibilityExtensionMethods

    Sub New()
        Dim types1 As Type() = Nothing
        Dim types2 As Type() = Nothing
        If (IntPtr.Size > 4) Then
            types1 = New Type() {GetType(Entity), GetType(Intersect), GetType(Point3dCollection), GetType(Long), GetType(Long)}
            types2 = New Type() {GetType(Entity), GetType(Intersect), GetType(Plane), GetType(Point3dCollection), GetType(Long), GetType(Long)}
        Else
            types1 = New Type() {GetType(Entity), GetType(Intersect), GetType(Point3dCollection), GetType(Integer), GetType(Integer)}
            types2 = New Type() {GetType(Entity), GetType(Intersect), GetType(Plane), GetType(Point3dCollection), GetType(Integer), GetType(Integer)}
        End If
        PlatformCompatibilityExtensionMethods.intersectWithMethod1 = GetType(Entity).GetMethod("IntersectWith", (BindingFlags.Public Or BindingFlags.Instance), Nothing, types1, Nothing)
        PlatformCompatibilityExtensionMethods.intersectWithMethod2 = GetType(Entity).GetMethod("IntersectWith", (BindingFlags.Public Or BindingFlags.Instance), Nothing, types2, Nothing)
    End Sub

    Public Function IntersectWith(ByVal entity As Entity, ByVal other As Entity, ByVal intersectType As Intersect, ByVal points As Point3dCollection) As Integer
        Dim start As Integer = points.Count
        Dim args As Object() = Nothing
        If (IntPtr.Size > 4) Then
            args = New Object() {other, intersectType, points, CLng(0), CLng(0)}
        Else
            args = New Object() {other, intersectType, points, CInt(0), CInt(0)}
        End If
        PlatformCompatibilityExtensionMethods.intersectWithMethod1.Invoke(entity, args)
        Return (points.Count - start)
    End Function


    Public Function IntersectWith(ByVal entity As Entity, ByVal other As Entity, ByVal intersectType As Intersect, ByVal plane As Plane, ByVal points As Point3dCollection) As Integer
        Dim start As Integer = points.Count
        Dim args As Object() = Nothing
        If (IntPtr.Size > 4) Then
            args = New Object() {other, intersectType, plane, points, CLng(0), CLng(0)}
        Else
            args = New Object() {other, intersectType, plane, points, CInt(0), CInt(0)}
        End If
        PlatformCompatibilityExtensionMethods.intersectWithMethod2.Invoke(entity, args)
        Return (points.Count - start)
    End Function


    Public Function IntersectWith(ByVal entity As Entity, ByVal other As Entity, ByVal intersectType As Intersect, ByVal points As Point3dCollection, ByVal thisGsMarker As IntPtr, ByVal otherGsMarker As IntPtr) As Integer
        Dim start As Integer = points.Count
        Dim args As Object() = Nothing
        If (IntPtr.Size > 4) Then
            args = New Object() {other, intersectType, points, thisGsMarker.ToInt64, otherGsMarker.ToInt64}
        Else
            args = New Object() {other, intersectType, points, thisGsMarker.ToInt32, otherGsMarker.ToInt32}
        End If
        PlatformCompatibilityExtensionMethods.intersectWithMethod1.Invoke(entity, args)
        Return (points.Count - start)
    End Function


    Public Function IntersectWith(ByVal entity As Entity, ByVal other As Entity, ByVal intersectType As Intersect, ByVal plane As Plane, ByVal points As Point3dCollection, ByVal thisGsMarker As IntPtr, ByVal otherGsMarker As IntPtr) As Integer
        Dim start As Integer = points.Count
        Dim args As Object() = Nothing
        If (IntPtr.Size > 4) Then
            args = New Object() {other, intersectType, plane, points, thisGsMarker.ToInt64, otherGsMarker.ToInt64}
        Else
            args = New Object() {other, intersectType, plane, points, thisGsMarker.ToInt32, otherGsMarker.ToInt32}
        End If
        PlatformCompatibilityExtensionMethods.intersectWithMethod2.Invoke(entity, args)
        Return (points.Count - start)
    End Function

    Private intersectWithMethod1 As MethodInfo = Nothing
    Private intersectWithMethod2 As MethodInfo = Nothing

End Module

 

My name is Martin.. :smileyvery-happy:
New Member
HillJ
Posts: 2
Registered: ‎05-30-2010
Message 4 of 4 (246 Views)

Re: Intersect with on 2011: 32 Bit. Win 7

01-21-2012 05:55 PM in reply to: quigs

Even easier is to replace the last two integer arguments with intptr. For those I usually use 0,0 - I find these two arguments are rarely used.

 

It worked for me to simply replace the last two parameters "0,0" with "New Intptr(), New IntPtr()"

 

Thanks to cadcamm99 in another post.

 

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.