Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FindUsingVector() in C#

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
gilsdorf_e
453 Views, 5 Replies

FindUsingVector() in C#

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

 

Tags (1)
5 REPLIES 5
Message 2 of 6
adam.nagy
in reply to: gilsdorf_e

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
Message 3 of 6
gilsdorf_e
in reply to: adam.nagy

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!

Message 4 of 6
Maxim-CADman77
in reply to: gilsdorf_e

@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?

Message 5 of 6
Maxim-CADman77
in reply to: gilsdorf_e

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

Message 6 of 6

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 _)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report