ntweisen
Mechanical
- Jul 12, 2010
- 94
Hello. I created a macro that exports all 3d annotation data to a Power Point. This macro only runs when working from a single CATPart. I am trying to modify my code to allow the user to have a CATProduct open, select the part to get the data, then it will run as usual and export the annotation data for that selected part.
Sub CATMain()
Dim productDocument1 As Document
Dim product1 As Product
Dim products1 As Products
Set productDocument1 = CATIA.ActiveDocument
Set product1 = productDocument1.Product
Set products1 = product1.Products
Dim sStatus As String
Set Selection = productDocument1.Selection
ReDim sFilter(0)
Msgbox "Please select a part."
sFilter(0) = "Part"
sStatus = Selection.SelectElement2(sFilter, "Select a part", False)
Dim partDoc1 As PartDocument
Set partDoc1=selection.Item(1).value
namebody=partDoc1.name
Dim part1 as Part
set part1 = partDoc1
Dim myProduct As Product
Set myProduct = productDocument1.GetItem(part1.Name)
Dim partName, RealPartNumber,Defy As String
partName=myProduct.name
'====================================
Dim oAnnotationSets As AnnotationSets
Set oAnnotationSets= partDocument1.Product.GetTechnologicalObject("CATAnnotationSets")
The program stops working at this last line. Any ideas why?
Sub CATMain()
Dim productDocument1 As Document
Dim product1 As Product
Dim products1 As Products
Set productDocument1 = CATIA.ActiveDocument
Set product1 = productDocument1.Product
Set products1 = product1.Products
Dim sStatus As String
Set Selection = productDocument1.Selection
ReDim sFilter(0)
Msgbox "Please select a part."
sFilter(0) = "Part"
sStatus = Selection.SelectElement2(sFilter, "Select a part", False)
Dim partDoc1 As PartDocument
Set partDoc1=selection.Item(1).value
namebody=partDoc1.name
Dim part1 as Part
set part1 = partDoc1
Dim myProduct As Product
Set myProduct = productDocument1.GetItem(part1.Name)
Dim partName, RealPartNumber,Defy As String
partName=myProduct.name
'====================================
Dim oAnnotationSets As AnnotationSets
Set oAnnotationSets= partDocument1.Product.GetTechnologicalObject("CATAnnotationSets")
The program stops working at this last line. Any ideas why?