'******************************************************************** '******************************************************************** '**** 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 "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "
" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "
Documentation for Process: " & ProcessName &"" & VBCRLf indexf.Write "
" & 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 "Setup Tool Catalog Name: "&CurrentCatalogName&"

" & VBCRLf '--------------------------------------------------------------- ' Read the Programs of the Current Setup '--------------------------------------------------------------- Set ProgramList = CurrentSetup.Programs NumberOfProgram = ProgramList.Count For J=1 To NumberOfProgram Set CurrentProgram = ProgramList.GetElement(J) ProgramName = CurrentProgram.Name Comment = CurrentProgram.comment 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

" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf For K=1 To NumberOfActivity Set CurrentActivity = ActivityList.GetElement(K) ActivityName = CurrentActivity.Name ActivityType= CurrentActivity.Type MoSpindle = 500 MoAppFeedrate = 200 MoCompLengthTool = 4 MoCompRadiusTool = 3 Comment = ActivityType '--------------------------------------------------------------- ' Read the Activity Type ' If the Activity is a tool Change ' Read the Tool,Tool Number ' If The Activity is a Machining operation ' Read the Mo Name, Mo Spindle, Mo feedrate... '--------------------------------------------------------------- If ( ActivityType = "ToolChange" ) Then Set CurrentTool = CurrentActivity.Tool ToolNumber = CurrentTool.Number MoSpindle = "x" MoAppFeedrate = "x" ElseIf (ActivityType = "PPInstruction") or (ActivityType = "TableHeadRotation") or (ActivityType = "CoordinateSystem")Then MoSpindle = "x" MoAppFeedrate = "x" Else Set MoSpindleParam = CurrentActivity.GetAttribute("SpindleSpeed.Value") MoSpindle =MoSpindleParam.Value Set MoFeedrateParam = CurrentActivity.GetAttribute("MachiningFeedrate.Value") MoAppFeedrate =MoFeedrateParam.Value End If indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf indexf.Write "" & VBCRLf Next indexf.Write "
Activity numberActivity nameTool numberActivity typeSpindle speedFeedrate
" & K &"" &ActivityName &"" & ToolNumber & "" & Comment & "" & MoSpindle &"" & MoAppFeedrate & "
" & VBCRLf Next End If Next End If '--------------------------------------------------------------- ' End of the Scan '--------------------------------------------------------------- indexf.Write "" & VBCRLf End Sub