Ok so i tried it and had to change things like sub () to sub main() and delete let&set. I've done it and now i've got another error.
This is my code:
Sub Main()
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
' If the current non-master LOD document is dirty you should save it before you can use the master-LOD document background
If oDoc.Dirty Then
If MsgBox("You should save the document first!" & vbCrLf & "Would you like to save the document?", vbYesNo) = vbYes Then
oDoc.Save
Else
Exit Sub
End If
End If
Dim sFileName As String
sFileName = oDoc.FullFileName
Dim oMasterLODDoc As AssemblyDocument
oMasterLODDoc = ThisApplication.Documents.Open(sFileName, False)
Dim oBOM As BOM
oBOM = oMasterLODDoc.ComponentDefinition.BOM
oBOM.PartsOnlyViewEnabled = True
Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews.Item("Parts Only")
oBOMView.Export ("C:\Temp\BOM.xls", kMicrosoftExcelFormat)
oMasterLODDoc.Close (True)
End Sub
And error sounds like that:
Błąd w regule: Reguła0, dokument: Zespół1.iam
Parametr jest niepoprawny. (Wyjątek od HRESULT: 0x80070057 (E_INVALIDARG))
System.ArgumentException: Parametr jest niepoprawny. (Wyjątek od HRESULT: 0x80070057 (E_INVALIDARG))
w System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
w Inventor.BOMViews.get_Item(Object Index)
w LmiRuleScript.Main()
w Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
w iLogic.RuleEvalContainer.ExecRuleEval(String execRule)