'******************************************************************** '******************************************************************** '**** VBSCRIPT MACRO FOR THE GENERATION OF HTML DOCUMENTATION **** '**** FOR THE MANUFACTURING WORKSHOP **** '**** Dassault Systemes **** '******************************************************************** '******************************************************************** Language="VBSCRIPT" Dim OutRef, OutPath, OutIndex RootActivityNameRef = "Process" HTMLFileName = "MfgProcess" HTMLPath = "/tmp/" Sub CATMain() CATDocument RootActivityNameRef, HTMLFileName, HTMLPath End Sub '-------------------------------------------------------------------- ' Main Procedure '-------------------------------------------------------------------- Sub CATDocument( RootActivityName , HtmlFilesName , HtmlFilesPath ) CATIA.SystemService.Print "RootActivityName : " & RootActivityName CATIA.SystemService.Print "HtmlFilesName : " & HtmlFilesName CATIA.SystemService.Print "HtmlFilesPath : " & HtmlFilesPath Dim RootActivity Dim RootActName RootActName = RootActivityName OutPath = HtmlFilesPath OutRef = HtmlFilesName 'OutIndex = OutRef & ".html" OutIndex = ".html" CreateHtmlFile OutPath, OutRef, OutIndex End Sub '--------------------------------------------------------------- ' Create the output file and its header '--------------------------------------------------------------- Sub CreateHtmlFile(OutPath, OutRef, OutIndex) Out = OutPath & OutRef & OutIndex Dim indexfs Dim indexf ' Set indexfs = CreateObject("Scripting.FileSystemObject") Set indexfs = CATIA.FileSystem ' Set indexf = Indexfs.OpenTextFile(OutPath & OutIndex, 2, True) Set indexf1 = indexfs.CreateFile("E:\tmp\tbl.html", TRUE) MsgBox indexf1.Name Set indexf=indexf1.OpenAsTextStream("ForWriting") ' msgbox indexf.name Dim ProcessName ProcessName = "ManufacturingProcess" indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "
" & VBCRLf indexf.Write " " & VBCRLf indexf.Write " " & VBCRLf indexf.Write " " & VBCRLf indexf.Write "Documentation for Process: " & ProcessName &"" & VBCRLf indexf.Write " |
Generation Date : " & Date & " at " & Time & "
"' & VBCRLf '--------------------------------------------------------------- ' Variables declaration '--------------------------------------------------------------- Dim SetupList As MfgActivities Dim ProgramList As MfgActivities Dim ActivityList As MfgActivities Dim NumberOfSetup As Integer Dim NumberOfProgram As Integer Dim NumberOfActivity As Integer Dim I As Integer Dim J As Integer Dim K As Integer Dim SetupName Dim ProgramName Dim ActivityName Dim CurrentSetup As ManufacturingActivity Dim CurrentProgram As ManufacturingActivity Dim CurrentActivity As ManufacturingActivity Dim CurrentTool As ManufacturingTool Dim CurrentMachine As ManufacturingMachine Dim CurrentCatalogName Dim Comment Dim ToolNumber As Integer Dim ActivityType Dim ToolComments Dim MoSpindleParam As Parameter Dim MoFeedrateParam As Parameter Dim MoSpindle Dim MoAppFeedrate Comment = "comments " MoSpindle = 0.0 MoAppFeedrate = 0.0 Dim childs As Activities Dim child As Activity Dim quantity As Integer Dim ActivityRef As AnyObject '--------------------------------------------------------------- ' Retrieve the active document '--------------------------------------------------------------- Dim MfgDoc1 As Document Set MfgDoc1 = CATIA.ActiveDocument '--------------------------------------------------------------- ' Retrieve the current Process '--------------------------------------------------------------- Set ActivityRef = MfgDoc1.GetItem("Process") '--------------------------------------------------------------- ' Scan of the Process '--------------------------------------------------------------- quantity = 0 If (ActivityRef.IsSubTypeOf("PhysicalActivity")) Then Set childs = ActivityRef.ChildrenActivities quantity = childs.Count if quantity <= 0 then Exit Sub End if NumberOfSetup = 0 For I=1 To quantity Set child = childs.Item(I) If (child.IsSubTypeOf("ManufacturingSetup")) Then Set CurrentSetup = child NumberOfSetup = NumberOfSetup +1 SetupName = CurrentSetup.Name '=> If no machine is defined, ignore error On Error Resume Next Set CurrentMachine = CurrentSetup.Machine CurrentCatalogName = "" '=> If no machine is defined, ignore error On Error Resume Next CurrentCatalogName= CurrentMachine.PreferedToolCatalogName Comment = CurrentSetup.comment indexf.Write "Setup Number: "& NumberOfSetup & " , Name :"& SetupName &"
" & VBCRLf
indexf.Write "Setup Comment: "&Comment&"
" & VBCRLf
indexf.Write "
Program Number: "& J & " , Name: " & ProgramName &"
" & VBCRLf
indexf.Write "Program Comment: "& Comment & "
" & VBCRLf
'---------------------------------------------------------------
' Read the Activities Current Program
'---------------------------------------------------------------
Set ActivityList = CurrentProgram.Activities
NumberOfActivity = ActivityList.Count
indexf.Write "Program description
Activity number | " & VBCRLf indexf.Write "Activity name | " & VBCRLf indexf.Write "Tool number | " & VBCRLf indexf.Write "Activity type | " & VBCRLf indexf.Write "Spindle speed | " & VBCRLf indexf.Write "Feedrate | " & VBCRLf indexf.Write "" & VBCRLf indexf.Write "
---|---|---|---|---|---|
" & K &" | " & VBCRLf indexf.Write "" &ActivityName &" | " & VBCRLf indexf.Write "" & ToolNumber & " | " & VBCRLf indexf.Write "" & Comment & " | " & VBCRLf indexf.Write "" & MoSpindle &" | " & VBCRLf indexf.Write "" & MoAppFeedrate & " | " & VBCRLf indexf.Write "