FindUsingVector in VB.NET

FindUsingVector in VB.NET

pveng
Contributor Contributor
1,250 Views
9 Replies
Message 1 of 10

FindUsingVector in VB.NET

pveng
Contributor
Contributor

Hello All,

 

does anybody has an example of the FindUsingVector command in vb.net?

 

There is already an vba example in a previous post ("FindUsingVector") but it didn't work in vb.net.

 

I think the issue is that in vb.net all arrays are 0 based but the FindUsingVector command needs a 1 based array for the ObjectTypes().

 

Autodesk help:

ComponentDefinition.FindUsingVector( OriginPoint As Point, Direction As UnitVector, ObjectTypes() As SelectionFilterEnum, [UseCylinder] As Boolean, [ProximityTolerance] As Variant, [VisibleObjectsOnly] As Boolean, [LocationPoints] As Variant ) As ObjectsEnumerator

 

Thanks in advance

pveng

0 Likes
Accepted solutions (1)
1,251 Views
9 Replies
Replies (9)
Message 2 of 10

adam.nagy
Autodesk Support
Autodesk Support
Accepted solution

Hi,

 

I don't think that's the issue because in VBA using an array with lower bound 0 works fine.

I guess you are referring to this code?

http://forums.autodesk.com/t5/Inventor-Customization/FindUsingVector/td-p/3772145

 

You can reproduce the problem with a much simpler code as well, of course. My sample code also contains the solution, which is late-binding:

Sub FindUsingVector_Test
  Try
    Dim oApp As Application = GetObject(, "Inventor.Application")

    Dim oPartDoc As PartDocument
    oPartDoc = oApp.ActiveDocument

    Dim oTG As TransientGeometry
    oTG = ThisApplication.TransientGeometry
  
    Dim oPoint As Point 
    oPoint = oTG.CreatePoint()
 
    Dim oUV As UnitVector 
    oUV = oTG.CreateUnitVector(0, 0, 1) 

    Dim oFilter(0) As SelectionFilterEnum
    oFilter(0) = SelectionFilterEnum.kPartFaceFilter    

    ' a) Early-binding: if you use this then
    ' FindUsingVector will throw a DISP_E_BADCALLEE error
    'Dim oPartDef As PartComponentDefinition
    ' b) Late-binding: if you use this then
    ' FindUsingVector works fine
    Dim oPartDef As Object
    oPartDef = oPartDoc.ComponentDefinition  

    ' In case of early-binding this throws DISP_E_BADCALLEE error
    oPartDef.FindUsingVector(oPoint, oUV, oFilter) 
  Catch ex As Exception
    MsgBox(ex.Message) 
  End Try
End Sub

Still, this issue should not happen, so I logged it in our database: id 1516333

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 3 of 10

pveng
Contributor
Contributor

OK, thank you for your help.

0 Likes
Message 4 of 10

Richard.MM
Contributor
Contributor

Hi, 

I have a similar problem but in the Assembly.

My code  also return error DISP_E_BADCALLEE.

There is a solution for assembly?

Part of the code see below.

 

Thank you

Richard M.

 

 

....


Dim asmDoc As AssemblyDocument
asmDoc = m_inventorApp.ActiveDocument

....


Dim oAsmCompDef As AssemblyComponentDefinition
 oAsmCompDef = asmDoc.ComponentDefinition

...


 Dim oEdge As ObjectCollection
 oEdge = oAsmCompDef.FindUsingVector(circ1.Center, Unit_vector_x, filtr_new_hrana, True, 10, True)

 

 

0 Likes
Message 5 of 10

adam.nagy
Autodesk Support
Autodesk Support

HI Richard,

 

Did you try the same solution as shown in the above code? - i.e. replace ...

Dim oAsmCompDef As AssemblyComponentDefinition

... with ...

Dim oAsmCompDef As Object

Cheers,



Adam Nagy
Autodesk Platform Services
0 Likes
Message 6 of 10

Richard.MM
Contributor
Contributor

Yes, I tried it, but then it returned an error HRESULT: 0x80004001 (E_NOTIMPL).

 

0 Likes
Message 7 of 10

adam.nagy
Autodesk Support
Autodesk Support

Which Inventor version are you using?



Adam Nagy
Autodesk Platform Services
0 Likes
Message 8 of 10

Richard.MM
Contributor
Contributor
Inventor Professional 2014
Build: 246, Release: 2014 SP2 Update3
0 Likes
Message 9 of 10

HermJan.Otterman
Advisor
Advisor

Thanks Adam, this helps but....

I want to find the intersection of a line and a circular edge...

the circular edge is of a hole in a part and the line is a sketch line on that face.

my line intersects at two points, but only the first gets listed (in the Locationpoints)

I also tried FindUsingRay, but still can't find my second intersectionpoint with the circular edge.

how can I find that second intersection point?? (or the coordinates)

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 10 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support

@HermJan.Otterman,

 

Can you please provide sample inventor file to investigate which is having circle with 2 intersection of line? please make sure that files are non confidential.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes