FindUsingVector() in C#

FindUsingVector() in C#

gilsdorf_e
Collaborator Collaborator
742 Views
5 Replies
Message 1 of 6

FindUsingVector() in C#

gilsdorf_e
Collaborator
Collaborator

Hello,

 

I need some help in using the FindUsingVector() method in C#. According to the help file, there is the optional argument LocationPoints.

 

The help for VB says it is a Variant.

 

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

 

In C# intellisense tells me that out Locationspoints is of type object.

 

How do I get from this object to the set of points that the method should give as result?

 

Best regards

Erik

 

0 Likes
Accepted solutions (2)
743 Views
5 Replies
Replies (5)
Message 2 of 6

adam.nagy
Autodesk Support
Autodesk Support
Accepted solution

Hi Erik,

 

This blog post discusses optional arguments in C#, e.g. using Type.Missing:

http://modthemachine.typepad.com/my_weblog/2010/08/using-c-with-the-inventor-api-part-3.html

 

Cheers,



Adam Nagy
Autodesk Platform Services
0 Likes
Message 3 of 6

gilsdorf_e
Collaborator
Collaborator

Okay, so I tried casting locationPoints as ObjectsEnumerator. That worked.

I still wonder why you do not use out ObjectsEnumerator like in FindUsingRay directly and one has to cast out object as ObjectsEnumerator.

 

Thanks!

0 Likes
Message 4 of 6

Maxim-CADman77
Advisor
Advisor
Accepted solution

@gilsdorf_e 

Nowadays I try to create plugin on C# that uses FindUsingVector method.

Initially I thought I can use only first three arguments but I got "Invalid callee" exception. Forum people hint me that for plugins (unlike add-in) all seven arguments are necessary.

My algorithm needs only intersected entities (no need for LocationPoints) thus I've used "null".

oPCD.FindUsingVector(oPoint, oUnitVector, oSelectionFilterEnums, true, null, true, null)

Compiler detects this as error:

Argument 7: Cannot convert from'<null>' to 'out object'

Should I introduce true ObjectsEnumerator object in this case or there is some better solution?

Please vote for Inventor-Idea Text Search within Option Names

Message 5 of 6

Maxim-CADman77
Advisor
Advisor

My post was marked as an answer by mistake. It was a question.....

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 6 of 6

Maxim-CADman77
Advisor
Advisor

Ok. That was late night and I've payed no attention Visual Studio has recommendation to fix this.
Final code is:

oPCD.FindUsingVector(oPoint, oUnitVector, oSelectionFilterEnums, true, null, true, out _)

Please vote for Inventor-Idea Text Search within Option Names

0 Likes