ntweisen
Mechanical
- Jul 12, 2010
- 94
I have a part with three captures under an annotation set called iso view, notes, and front view which I want the script to cycle through and take a screen shot of each. I can turn the background to white and text to black but I'm not sure the code to cycle through and take a picture of the captured views (not just the active viewer) and save them each as a bmp or png file. Here's what I have so far:
Language="VBSCRIPT"
Sub CATMain()
MsgBox "Must be a part file."
Dim oAnnotationSets As AnnotationSets
Dim oAnnotationSet As AnnotationSet
Dim oAnnotations As Annotations
Dim oAnnotation As Annotation
Dim oSel As Selection
Dim visProperties1 As INFITF.VisPropertySet
Set partDoc = CATIA.ActiveDocument
Set Part = partDoc.Part
Set oAnnotationSets = Part.AnnotationSets
Set oSel = CATIA.ActiveDocument.Selection
Dim ObjViewer3D As Viewer3D
Set objViewer3D = CATIA.ActiveWindow.ActiveViewer
'change background color to white
Dim DBLBackArray(2)
objViewer3D.GetBackgroundColor(dblBackArray)
Dim dblWhiteArray(2)
dblWhiteArray(0) = 1
dblWhiteArray(1) = 1
dblWhiteArray(2) = 1
objViewer3D.PutBackgroundColor(dblWhiteArray)
For IdxSet = 1 To oAnnotationSets.Count
Set oAnnotationSet = oAnnotationSets.Item(IdxSet)
Set oAnnotations = oAnnotationSet.Annotations
For IdxAnnot = 1 To oAnnotations.Count
Set oAnnotation = oAnnotations.Item(IdxAnnot)
If Not oAnnotation Is Nothing Then
With oSel
.Clear
.Add oAnnotation
Call .VisProperties.SetVisibleColor(0, 0, 0, 0)
End With
oAnnotation.ModifyVisu
End If
Next
Next
End Sub
Language="VBSCRIPT"
Sub CATMain()
MsgBox "Must be a part file."
Dim oAnnotationSets As AnnotationSets
Dim oAnnotationSet As AnnotationSet
Dim oAnnotations As Annotations
Dim oAnnotation As Annotation
Dim oSel As Selection
Dim visProperties1 As INFITF.VisPropertySet
Set partDoc = CATIA.ActiveDocument
Set Part = partDoc.Part
Set oAnnotationSets = Part.AnnotationSets
Set oSel = CATIA.ActiveDocument.Selection
Dim ObjViewer3D As Viewer3D
Set objViewer3D = CATIA.ActiveWindow.ActiveViewer
'change background color to white
Dim DBLBackArray(2)
objViewer3D.GetBackgroundColor(dblBackArray)
Dim dblWhiteArray(2)
dblWhiteArray(0) = 1
dblWhiteArray(1) = 1
dblWhiteArray(2) = 1
objViewer3D.PutBackgroundColor(dblWhiteArray)
For IdxSet = 1 To oAnnotationSets.Count
Set oAnnotationSet = oAnnotationSets.Item(IdxSet)
Set oAnnotations = oAnnotationSet.Annotations
For IdxAnnot = 1 To oAnnotations.Count
Set oAnnotation = oAnnotations.Item(IdxAnnot)
If Not oAnnotation Is Nothing Then
With oSel
.Clear
.Add oAnnotation
Call .VisProperties.SetVisibleColor(0, 0, 0, 0)
End With
oAnnotation.ModifyVisu
End If
Next
Next
End Sub