Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations The Obturator on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insertbomtable

Status
Not open for further replies.

Milothicus

Mechanical
Sep 21, 2003
39
i'm trying to insert a bom through API, but i'm having trouble.

here's my code line:

boolstatus = swview.InsertBomTable("C:\Documents and Settings\Administrator\Desktop\bomtemp.xls", 0.2794, 0,"?")

i can't figure out what goes in the "?" place. according to the help file:

Output: (long) Errors
Status of the BOM creation operation as defined in swBOMConfigurationCreationErrors_e

the creationerrors_e includes reasons for errors in the creation, so i'd think it expects a variable to receive the error code, but that didn't work.

i tried putting a "0" into it, and then it's happy until it gets close to the end of the process of adding the bom, and then it creates an error.

help also states:

If the BOM creation fails, the Dispatch pointer that is returned will be NULL. If you want more information about why the operation failed, use the Errors argument. You can pass in NULL as the Errors argument if you are not interested in the specific information.

i tried leaving it blank, making it Null, and leaving out the last comma altogether. nothing seems to work.

anyone had success with this? i'm in 2005...
 
Replies continue below

Recommended for you

i tried, but the insertion of the BOM doesn't come up. i got two lines of actual code in the macro:

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
boolstatus = Part.ActivateSheet("Sheet1")
boolstatus = Part.Extension.SelectByID2("Sheet1", "SHEET", 0.175485425, 0.1744388961538, 0, False, 0, Nothing, 0)

and i don't think either one has anything to do with the BOM...

 
I suppose what i don't understand is how to "pass in NULL as the Errors argument".
 
Have you tried defining a variable of type long, and then using that variable as the last argument of the method call?

I think if you do that, then when the BoM creation fails, the method will change the value of that variable to an error code that is defined in swBOMConfigurationCreationErrors_e.
 
Dim Errors (or whatever) as long
Errors=0 (this way, if it is still zero after the InsertBomTable call, you know there were no errors)

boolstatus = swview.InsertBomTable("C:\Documents and Settings\Administrator\Desktop\bomtemp.xls", 0.2794, 0, Errors)

Then, if there is an error, Errors will contain a long value that can be matched up to the swBOMConfigurationCreationErrors_e enumeration (look in the object browser for the numeric values). This is an output variable that will not be modified unless an error occurs. If an error occurs, you should also get a false for your status variable.

Typically, I only check the value of this output variable if a false was returned for the status variable.




Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...
 
I think i may have been wrong about where my problem is.

here's the relevant code. this is meant to take an open and active assembly file, create a drawing, add the 'front' view to the drawing, and add a BOM for that view.

Set swApp = CreateObject("SldWorks.Application")
set TemplateName = "C:\Program Files\SolidWorks\data\templates\Drawing.drwdot"
Set newdrw = swApp.NewDocument(TemplateName, 2, 0, 0)
set CurDoc = "C:\Documents and Settings\Administrator\Desktop\PIPING TEST\Assem1.SLDASM"
Set DrawView = newdrw.CreateDrawViewFromModelView2(CurDoc, "*Front", 0.1287090834846, 0.1357270435572, 0)
Set swselmgr = newdrw.SelectionManager
Set swview = swselmgr.GetSelectedObject5(1)
boolstatus = swview.InsertBomTable("C:\Documents and Settings\Administrator\Desktop\bomtemp.xls", 0, 0, succ)

my computer doesn't have quite enough memory to run SW smoothly, so as it's running the last line of code, i can watch it successfully create the BOM, and insert it into the drawing. once the BOM is in the drawing, i get run-time error '438': Object doesn't support this property or method

hit debug and it highlights that last line. am i missing something obvious?

i would think the fact that the BOM insertion is 99.99% complete indicates that my object definitions are working. please help me out...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor