Linq in Inventor API

Linq in Inventor API

taher.basha
Enthusiast Enthusiast
376 Views
2 Replies
Message 1 of 3

Linq in Inventor API

taher.basha
Enthusiast
Enthusiast

Hi Everyone,

 

I have searched but didn't find any material for "Linq in Inventor API". 

I mean how can i use Linq in Inventor API?

any learning link any doc or any block or any other way to learn and implement

 

I could able to use Linq in Revit API. but, the same couldn't be able to implement in Inventor API.

 

thanks in Advance

 

0 Likes
377 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor

In the inventor API most lists do not implement IEnumerable(Of ....). Therefore linq won't work on lists straight from the API. But you can almost always cast to an IEnumerable(Of ....). Here some example:

Dim docs As IEnumerable(Of Document) = ThisApplication.Documents.Cast(Of Document)

Dim fileNames = docs.Where(Function(d) d.FullFileName.Contains(".ipt")).
					Select(Function(d) d.FullFileName)

or if you prefer in C#

IEnumerable<Document> docs = ThisApplication.Documents.Cast<Document>();

var fileNames = docs.Where(d => d.FullFileName.Contains(".ipt")).
                    Select(d => d.FullFileName);

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 3

frederic.vandenplas
Collaborator
Collaborator

Here you have some examples

 

Dim oDrawDoc as DrawingDocument = thisapplication.activedocument
Dim oSheet as Sheet
= oDrawDoc.Sheets.Cast(Of Sheet).Where(Function(s) s.Name.Contains("MasterDrawing")).FirstOrDefault()

 

	Dim oDrawingViews As DrawingViews = oSheet.DrawingViews
	Dim oExtView As DrawingView = oDrawingViews.Cast(Of DrawingView).Where(Function(s) s.Name = "EXT.").FirstOrDefault()

 

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"