Default BOM Structure get a line in my code to fail

Default BOM Structure get a line in my code to fail

Darkforce_the_ilogic_guy
Advisor Advisor
166 Views
4 Replies
Message 1 of 5

Default BOM Structure get a line in my code to fail

Darkforce_the_ilogic_guy
Advisor
Advisor

I have a very complete code. That normaly work... But that change if just one iam is set to Phantom in Default BOM Struture.  

 

the code that fail is this line 

strFileName = brow.ReferencedFileDescriptor.FullFileName

 

 

 

 

 

 

I use it later in this line 

 

oDate1 = oFS.GetFile(strFileName).DateLastModified

 

what i want to know is why is it fail and is there a workaround to fix it ?

 

 

I look like i have fix it with the code below .. but because of the complex natur of my code ... it is really harde to see if that is any way it can cause error in my data output I get by running the code. 

 

Try
strFileName = brow.ReferencedFileDescriptor.FullFileName
debug(strFileName & " error did not happen")	
Catch
debug(strFileName + " error happen")	
end try

 

0 Likes
167 Views
4 Replies
Replies (4)
Message 2 of 5

jjstr8
Collaborator
Collaborator
What defines 'brow'?
0 Likes
Message 3 of 5

WCrihfield
Mentor
Mentor

Hi @Darkforce_the_ilogic_guy.  I initially had the same question...but I guessed that it represented a BOMRow object.  If that is the case, the online help page for its ReferencedFileDescriptor property says that it "only applies to non merged component rows and non local components and immediately referenced components. Therefore this would only be useful in the data view."  It may be better to use its ComponentOccurrences property to access its first ComponentOccurrence object, then access its ReferencedDocumentDescriptor, then its FullDocumentName.  Or go through the BOMRow.ComponentDefinitions.Item(1).Document.FullFileName.

 

By the way...what is the error message saying?  That may help us understand how to fix or handle the error.  There is usually something useful on the More Info tab of the error message, but you may need to translate it to English for us.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 5

Darkforce_the_ilogic_guy
Advisor
Advisor

This part of the code might help to see what brow is 

 

Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument

Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM

oBOM.StructuredViewEnabled = True
oBOM.StructuredViewFirstLevelOnly = False
oBOM.StructuredViewDelimiter = "."

oBOM.PartsOnlyViewEnabled = True

Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews.Item("Structured")
debug("Call ExportToExcel")
Call ExportToExcel(oBOMView.BOMRows)

'Add to Clipboard(Copy & past fuction)
Clipboard.SetText(oHoleRepport)	
Clipboard.SetText(oHoleRepportExcel)		
End Sub


Public Sub debug(txt As String)
	Trace.WriteLine("NTI : " & txt)
End Sub

Public Function ExportToExcel(brows As BOMRowsEnumerator)
	
Dim brow As BOMRow

For Each brow In brows

 the hole code is about 637 lines and not the best writte .. sind I am not a programmer( not a very good one ) .. so it mush design by try and error untill it  works 🙂 and have not have the time til clear it up

0 Likes
Message 5 of 5

jjstr8
Collaborator
Collaborator

I'm not sure what the overall goal of your code is, but can you use the Model ("Unnamed") BOM?  The problem is that Inventor hides phantom components in the Structured and Parts Only BOMs.  In your case,  your phantom assembly has normal or purchased sub-components, so Inventor includes those as "promoted".  Unfortunately, the ReferencedFileDescriptor value does not get promoted, causing the exception when accessed.  The only way to see phantom components as a BOMRow is in BOMView.Item("Unnamed").

0 Likes