×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Insertbomtable

Insertbomtable

Insertbomtable

(OP)
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...

RE: Insertbomtable

(OP)
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...

RE: Insertbomtable

(OP)
I suppose what i don't understand is how to "pass in NULL as the Errors argument".

RE: Insertbomtable

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.

RE: Insertbomtable

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...

RE: Insertbomtable

(OP)
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...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources