Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This seems like it should be easy, but I can't get the following piece of iLogic to run even with "Imports System.Linq" at the top:
'AddReference "System.Web"
AddReference "System.Linq"
Imports System.Linq
Imports System.IO
Imports System.Collections.Generic
Sub Main()
Call BeginCreateAssemblyStructure
End Sub
Sub BeginCreateAssemblyStructure
'define the parent assembly
Dim asmDoc As AssemblyDocument
asmDoc = ThisApplication.ActiveDocument
Dim filename As String = System.IO.Path.GetFileNameWithoutExtension(ThisApplication.ActiveDocument.Displayname)
Dim filetab As String = InputBox("Which project?", "4 Letter Project Code", "ABCD") + "-MODELLING-BASELINE"
Dim PartsList As List(Of SubObjectCls)
PartsList = New List(Of SubObjectCls)
'debug
MessageBox.Show(PartsList.Count, "Parts List Count")
Dim FilesArray As New ArrayList
Dim tr As transaction
tr = ThisApplication.TransactionManager.StartTransaction( _
ThisApplication.ActiveDocument, _
"Create Standard Parts From Excel")
'this is to simply set the excel values to the correct file/tab- nothing more!
FileArray = GoExcel.CellValues("C:\VAULT WORKING FOLDER\Designs\Project Tracker.xlsx", filetab , "A3" , "A4") ' sets excel to the correct sheet!
'Data collection:
For MyRow = 3 To 5000 ' max limit = 5000 rows for debugging purposes
Dim SO As SubObjectCls
SO = New SubObjectCls
If GoExcel.CellValue("A"& MyRow) = "" Then Exit For
SO.Partno = GoExcel.CellValue("B" & MyRow)
SO.LegacyDescr = GoExcel.CellValue("K" & MyRow)
SO.LegacyRev = GoExcel.CellValue("L" & MyRow)
SO.LegacyDrawingNo = GoExcel.CellValue("M" & MyRow)
SO.ParentAssembly = GoExcel.CellValue("I" & MyRow)
PartsList.Add(SO)
Next
MessageBox.Show(PartsList.Count, "Parts List Count")
'sort our list of parts
PartsList.Sort()
Dim r = From a As SubObjectCls In PartsList Where a.PartNo.StartsWith("AS-") And a.ParentAssembly = filename Select a '<-- ERROR IS AT THIS LINE
For i = 0 To r.Count -1
MessageBox.Show(r(i).PartNo + vbCrLf + r(i).ParentAssembly,"Info in part #" + i.ToString())
Next i
For i = 0 To PartsList.Count - 1
'MessageBox.Show(PartsList(i).PartNo,"Part No in part: " + i.ToString())
Next
End Sub
Public Class SubObjectCls
Public PartNo As String
Public LegacyDescr As String
Public LegacyRev As String
Public LegacyDrawingNo As String
Public ParentAssembly As String
Public Sub Init(m_partno As String,
m_legacydescr As String,
m_legacyrev As String,
m_legacydrawingno As String,
m_parentassy As String)
PartNo = m_partno
LegacyDescr = m_legacydescr
LegacyRev = m_legacyrev
LegacyDrawingNo = m_legacydrawingno
ParentAssembly = m_parentassy
End Sub
End ClassDoes anyone have any ideas why this isn't working? (The error message I receive is:
"Error on Line 64 : Expression of type 'System.Collections.Generic.List(Of LmiRuleScript.SubObjectCls)' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider."
Thanks,
Alex.
----------------------------------------------------------------
Alex Fielder
Inventor Expert
https://github.com/alexfielder/
LinkedIn - Github Inventor Extension Server - Bonkers polygon iLogic thing
Top ten iLogic Tips - API Shortcut In Google Chrome - Assembly Extrusion Example
Alex Fielder
Inventor Expert
https://github.com/alexfielder/
LinkedIn - Github Inventor Extension Server - Bonkers polygon iLogic thing
Top ten iLogic Tips - API Shortcut In Google Chrome - Assembly Extrusion Example
Solved! Go to Solution.