Insert Bill of materials in HTML

Insert Bill of materials in HTML

Anonymous
Not applicable
550 Views
3 Replies
Message 1 of 4

Insert Bill of materials in HTML

Anonymous
Not applicable

Hi,

 

Currently we are trying to make a html file using ilogic.

The file will be used to inform people how to assamble a pallet wich is used in our milling machine.

 

We already have the following code;

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 27122 StartFragment: 314 EndFragment: 27090 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

'HTML bestand maken met benodigde gegevens'create an html report sample
report_title = "Design Rapport klem Assembly " & ThisDoc.PathAndFileName(True) 'variable used the body of the html
description = "Opspangegevens" 'variable used in the body of the html

Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
TableMembers = New String () {"Programmeur", "Materiaal", "Uitgangsmaten", "Aanhaalmoment", "Werkordernummer"} 'parameters to include in table

html_filename = ThisDoc.PathAndFileName(False) & ".html"

oWrite = oFile.CreateText(html_filename) 'name and path of html file to create/overwrite
oWrite.WriteLine("<HTML>")
oWrite.WriteLine("<HEAD>")
oWrite.WriteLine("<META CONTENT=""text/html; charset=iso-8859-1"" HTTP-EQUIV=""Content-Type"" >")
oWrite.WriteLine("<TITLE>")
oWrite.WriteLine(report_title) 'set the html search title with local variable
oWrite.WriteLine("</TITLE>")
oWrite.WriteLine("</HEAD>")
oWrite.WriteLine("<BODY BGCOLOR=""#FFFFF1"">")
oWrite.WriteLine("<B><EM><H3>")
oWrite.WriteLine(report_title) 'first line of the report
oWrite.WriteLine("</B></EM></H3>")
oWrite.WriteLine("<B>Date & Time: </B>")
oWrite.WriteLine(Now()) 'today's date and time on the second line
oWrite.WriteLine("<BR>")
oWrite.WriteLine("<B>Description: </B>") 
oWrite.WriteLine(description) 'desciption string goes on the third line of the report
oWrite.WriteLine("<BR>") 
oWrite.WriteLine("<B>Customer:</B>  Customer.<BR><BR>")
oWrite.WriteLine("<TABLE BORDER=""1"" WIDTH=""650"">") 'table width in pixels.  Use % to adjust to browser size.

'create html text lines nessesary to build the table for each parameter specified in the TableMembers array
For Each pName As String in TableMembers
  oWrite.WriteLine("<TR><TD WIDTH=""50%"">") 'column width is half of table size
  oWrite.WriteLine(pName) ' parameter name
  oWrite.WriteLine("</TD><TD>")
  oWrite.WriteLine(DynaParam(pName) ) ' parameter value
  oWrite.WriteLine("</TD> </TR>")
Next

'save iso view to jpg
imagedoc = ThisDoc.PathAndFileName(False) & ".jpg"
oCamera = InventorVb.Application.ActiveView.Camera 'current iso view
oCamera.fit
oCamera.apply
InventorVb.Application.ActiveView.SaveAsBitmap(imagedoc,1680, 1050) 

oWrite.WriteLine("</TABLE>") ' end the table
oWrite.WriteLine("Afbeelding opspanning.<BR>") 'footer notes
oWrite.WriteLine("")'footer notes
oWrite.WriteLine("<IMG src=""" & imagedoc & """ ALT=""text"" WIDTH = 650 ALIGN = <RIGHT> ")
oWrite.WriteLine("</BODY>")
oWrite.Close()

'option to view report
go = MessageBox.Show("Wilt u het Design Rapport bekijken?", "iLogic Rapporten", MessageBoxButtons.YesNo)
If go = 6 Then ThisDoc.Launch(html_filename)

 This code creates the following HTML file;

 

Knipsel_LI (2).jpg

The only thing that's missing is the BOM of the assembly.

We tried al lot of things to put it in the html but none of them worked.

 

Does somebody know how to fix this?

 

Thanks a lot!

 

Rik 

 

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

Mark.Lancaster
Consultant
Consultant

@Anonymous

 

Welcome to the Autodesk User's Community..

 

Programming questions and needs should be asked in the Inventor Customization forum.  I will have the moderator relocate it there to better suit your needs.

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi,

 

In the mean time we got ilogic to build a html file with the bom list using te following code;

 

Sub Main()

'create an html report sample
report_title = "Configuratie document WO: " & Werkordernummer  'variable used the body of the html

'HTML bestand maken met Sub Main()benodigde gegevens

Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
TableMembers = New String () {"Programmeur", "Materiaal", "Uitgangsmaten", "Aanhaalmoment", "Opmerkingen"} 'parameters to include in table

    
html_filename = Werkordernummer & ".html"

'export BOM

Dim activeAssembly As AssemblyDocument = ThisApplication.ActiveDocument

Dim oAssemblyComponentDefinition As AssemblyComponentDefinition
oAssemblyComponentDefinition = activeAssembly.ComponentDefinition

Dim oBOM As BOM
oBOM = oAssemblyComponentDefinition.BOM

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


'HTML
oWrite = oFile.CreateText(html_filename) 'name and path of html file to create/overwrite
oWrite.WriteLine("<HTML>")
oWrite.WriteLine("<HEAD>")
oWrite.WriteLine("<META CONTENT=""text/html; charset=iso-8859-1"" HTTP-EQUIV=""Content-Type"" >")
oWrite.WriteLine("<STYLE> html, body { font-family:Arial, Helvetica, sans-serif; }</style>")
oWrite.WriteLine("<TITLE>")
oWrite.WriteLine(report_title) 'set the html search title with local variable
oWrite.WriteLine("</TITLE>")
oWrite.WriteLine("</HEAD>")
oWrite.WriteLine("<BODY>")

oWrite.WriteLine("<IMG src='../logoce.png' height='50px'>") 

oWrite.WriteLine("<B><EM><H2>")
oWrite.WriteLine(report_title) 'first line of the report
oWrite.WriteLine("</B></EM></H2>")
oWrite.WriteLine("<B>Aanmaak: </B>")
oWrite.WriteLine(Now()) 'today's date and time on the second line
oWrite.WriteLine("<BR>")
oWrite.WriteLine("<BR>")
oWrite.WriteLine("<BR>")
oWrite.WriteLine("<TABLE BORDER=""1"" WIDTH=""650"">") 'table width in pixels.  Use % to adjust to browser size.

'create html text lines nessesary to build the table for each parameter specified in the TableMembers array
For Each pName As String in TableMembers
  oWrite.WriteLine("<TR><TD WIDTH=""50%"">") 'column width is half of table size
  oWrite.WriteLine(pName) ' parameter name
  oWrite.WriteLine("</TD><TD>")
  oWrite.WriteLine(DynaParam(pName) ) ' parameter value
  oWrite.WriteLine("</TD> </TR>")
Next

'save iso view to jpg
imagedoc = ThisDoc.PathAndFileName(False) & ".jpg"
oCamera = InventorVb.Application.ActiveView.Camera 'current iso view
oCamera.fit
oCamera.apply
InventorVb.Application.ActiveView.SaveAsBitmap(imagedoc,1680, 1050) 

oWrite.WriteLine("</TABLE>") ' end the table
oWrite.WriteLine("<BR>") 
oWrite.WriteLine("<B><EM><H3>")
oWrite.WriteLine("Afbeelding opspanning<BR>") 'footer notes
oWrite.WriteLine("<BR>")
oWrite.WriteLine("")'footer notes
oWrite.WriteLine("<IMG src=""" & imagedoc & """ ALT=""text"" WIDTH = 650 ALIGN = <RIGHT> ")

oWrite.WriteLine("<B><EM><H3>")
oWrite.WriteLine("Bill of materials") 'first line of the report
oWrite.WriteLine("</B></EM></H3>")

oWrite.WriteLine("<TABLE BORDER=""1"" WIDTH=""650"">") 'table width in pixels.  Use % to adjust to browser size.

  oWrite.WriteLine("<TR><TD WIDTH=""25%"">") 'column width is half of table size
  oWrite.WriteLine("Part Number") ' parameter name
  oWrite.WriteLine("</TD><TD>")
  oWrite.WriteLine("QTY") ' parameter value
  oWrite.WriteLine("</TD><TD>")
  oWrite.WriteLine("Description") ' parameter value
  oWrite.WriteLine("</TD> </TR>")

For Each oBOMRow As BOMRow In oBOMView.BOMRows
  Dim oComponentDefinition As ComponentDefinition
  oComponentDefinition = oBOMRow.ComponentDefinitions.Item(1)
  
  Dim oDOMItemNumber As String
  oBOMItemNumber = oBOMRow.ItemNumber()
  
  Dim oDef As ComponentDefinition
  oDef = oBomRow.ComponentDefinitions(1)
  
  If oDef.Type = 100675072 'Virutal Component
    PartNumber = oDef.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Part Number").Value
  Else
    PartNumber = oDef.Document.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Part Number").Value
  End If
  
  If oDef.Type = 100675072 'Virutal Component
    Description = oDef.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Description").Value
  Else
    Description = oDef.Document.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Description").Value
  End If

  quantity =ThisBOM.CalculateQuantity("Model Data", PartNumber)

  oWrite.WriteLine("<TR><TD WIDTH=""25%"">") 'column width is half of table size
  oWrite.WriteLine(PartNumber) ' parameter name
  oWrite.WriteLine("</TD><TD>")
  oWrite.WriteLine(quantity) ' parameter value
  oWrite.WriteLine("</TD><TD>")
  oWrite.WriteLine(Description) ' parameter value
  oWrite.WriteLine("</TD> </TR>")
  
Next

oWrite.WriteLine("</TABLE>") ' end the table

oWrite.WriteLine("</BODY>")
oWrite.WriteLine("</HTML>")


oWrite.Close()


'option to view report
go = MessageBox.Show("Wilt u het Design Rapport bekijken?", "iLogic Rapporten", MessageBoxButtons.YesNo)
If go = 6 Then ThisDoc.Launch(html_filename)

'this is an example 
End Sub

 It works fine when we open inventor the first time and put some stuff in the assembly, and generate the html. When we leave inventor open, put some extra stuff in the assy and regenerate the html the BOM doesn't get updated.

 

I hope someone has an idea to fix this!

 

Rik 

0 Likes
Message 4 of 4

Anonymous
Not applicable

Hi Rik, have you checked if the extra stuff you added is already added in your "pBomView"?

0 Likes