Structured BOM Error, caused by phantom component

Structured BOM Error, caused by phantom component

Patrick1323
Enthusiast Enthusiast
634 Views
3 Replies
Message 1 of 4

Structured BOM Error, caused by phantom component

Patrick1323
Enthusiast
Enthusiast

Hello,

i try to read the filename value from a structured BOM. Visual Studio returns an error when i get to the lines where the parts are, which are members of a phantom component.

 

 

        Dim oBOM As BOM
        oBOM = oAssembly.ComponentDefinition.BOM

        ' Make sure it's enabled
        oBOM.StructuredViewEnabled = True
        oBOM.StructuredViewFirstLevelOnly = False

        Dim oBOMView As BOMView
        oBOMView = oBOM.BOMViews.Item("structured")

        Dim oBOMRows As BOMRowsEnumerator
        oBOMRows = oBOMView.BOMRows

        Dim oBOMRow As BOMRow
        For Each oBOMRow In oBOMRows
            Try
                myFileName = oBOMRow.ReferencedFileDescriptor.FullFileName
            Catch ex As Exception
                'a member of a phantom-component!
                MsgBox("Error on Pos.: " & oBOMRow.ItemNumber)
            End Try
        Next

 

screenshot.99.jpg

 

Error getting on Visual Studio 2012, german:

 

System.Runtime.InteropServices.COMException wurde nicht behandelt.
  ErrorCode=-2147467259
  HResult=-2147467259
  Message=Unbekannter Fehler (Ausnahme von HRESULT: 0x80004005 (E_FAIL))
  Source=""
  StackTrace:
       bei System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
       bei Inventor.BOMRow.get_ReferencedFileDescriptor()
       bei TBF.Form1.getFilenameAndItemFromParent(AssemblyDocument oMyParentAssembly, AssemblyDocument oMyAssembly) in C:\Users\Username\Desktop\lesson1_VisualExpress2010_Complete\Form1.vb:Zeile 312.
       bei TBF.Form1.setPosNr() in C:\Users\Username\Desktop\lesson1_VisualExpress2010_Complete\Form1.vb:Zeile 252.
       bei TBF.Form1.ButtonStart_Click(Object sender, EventArgs e) in C:\Users\Username\Desktop\lesson1_VisualExpress2010_Complete\Form1.vb:Zeile 225.
       bei System.Windows.Forms.Control.OnClick(EventArgs e)
       bei System.Windows.Forms.Button.OnClick(EventArgs e)
       bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       bei System.Windows.Forms.Control.WndProc(Message& m)
       bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
       bei System.Windows.Forms.Button.WndProc(Message& m)
       bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       bei TBF.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:Zeile 82.
       bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       bei System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       bei System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

 

0 Likes
635 Views
3 Replies
Replies (3)
Message 2 of 4

Patrick1323
Enthusiast
Enthusiast
Has anyone an idea? Have I found an Inventor bug?
0 Likes
Message 3 of 4

Patrick1323
Enthusiast
Enthusiast
I can provide more information if needed. Thank you!
0 Likes
Message 4 of 4

Anonymous
Not applicable

This should work:

myFileName = oBOMRow.ComponentDefinitions.Item(1).Document.FullFileName

0 Likes