BomInsert

<< Click to Display Table of Contents >>

Navigation:  Programming Mechworks PDM > DBWCommandShell > Commands Reference > BOM >

BomInsert

Description

Only for drawings, this command allows to insert a BOM in a worksheet;
It's the API for the toolbar functionality BOMinsert

Syntax

call DBWShell("BomInsert  UID  BOMtemplateFileName  AnchorMode  IsPointAnchored  BomInsertMode")

Parameters

uid

unique id of the drawing to create the BOM into.

BOMtemplateFileName

the template file for the BOM

AnchorMode

available for Solidworks and Solid Edge only.
-1: no anchor
1: top left (default)
2: top right
3: bottom left
4: bottom right

IsPointAnchored

available for Solidworks only
0: table origin is computed through the [xmin,ymin] of the selected drawing view bounding box (default value)
1: table origin is computed through the general table anchor point (SW specific)

BomInsertMode

1: LinkBOMandBalloons mode (default value)
2: LinkBalloonsOnly mode (Solidworks only)

Remarks

These are the requirements for using the shell command:

the current document in the CAD must be a drawing type document

such drawing must be already registered in the Mechworks database

a drawing view must be selected (manually before invoking the script or at script level with CAD dependent code)

Example (drawing view already selected)

...

DBWShell("GetActiveDocUniqueId")
DocumentUid = DBWResult("@DOCUMENT_UNIQUE_ID")
DBWShell("BomInsert " & DocumentUid & " DBWBOM_Show|top|level|subassemblies|and|parts|only.txt 3 1 1")
...

Example (Solid Edge - view selected by code)

DBWShell("GetActiveDocUniqueId")

DocumentUid = DBWResult("@DOCUMENT_UNIQUE_ID")
dbwmsgbox DocumentUid
Set seApplication = GetObject(, "SolidEdge.Application")
If Not seApplication Is Nothing then
 dbwmsgbox "Ok seApplication"
 set seView = seApplication.ActiveDocument.ActiveSheet.DrawingViews.Item(1)
 If Not seView Is Nothing then
  dbwmsgbox "Ok seView"
  BOMtemplateFileName = "DBWBOM_DRWWeight.txt"
  AnchorMode = -1
  IsPointAnchored = 1
  BomInsertMode = 1
  call DBWShell("BomDelete " &  DocumentUid & " " & 1)
  call seApplication.ActiveDocument.SelectSet.RemoveAll()
  call seApplication.ActiveDocument.SelectSet.Add(seView)
  call DBWShell("BomInsert " & DocumentUid & " " & BOMtemplateFileName & " 3 1 1")
  call DBWShell("BomRefresh " &  DocumentUid & " " & 1)
  call seApplication.ActiveDocument.SelectSet.RemoveAll()
 end if
else
 dbwmsgbox "Script is SE specific"
end if