AssemblyConvertor Print method fails

Babu Varghese

AssemblyConvertor Print method fails

Hi

Sorry this topic is discussed before but I couldn't find any solution. I am trying to export a BOM from a product structure but the print method fails. Any help please......

Please find the code below

Sub BOMExtract(ByVal filename As String, product1 As product)

 Dim assemblyConvertor1 As AssemblyConvertor
 Dim arrayOfVariantOfBSTR1(2)
 
 
Set assemblyConvertor1 = product1.GetItem("ListingReport")
 
arrayOfVariantOfBSTR1(0) = "PartNumber"""
arrayOfVariantOfBSTR1(1) = "DescriptionRef"
arrayOfVariantOfBSTR1(2) = "Revision"

Set assemblyConvertor1Variant = assemblyConvertor1
 assemblyConvertor1Variant.SetCurrentFormat arrayOfVariantOfBSTR1

 assemblyConvertor1Variant.Print "XLS", filename, product1 'Object dosen't support this property or method

 Regards

Little Cthulhu

RE: AssemblyConvertor Print method fails
(in response to Babu Varghese)

Hi.

 

Have you tried putting "Print" in square brackets?

 

assemblyConvertor1Variant.[Print] "XLS", filename, product1

Babu Varghese

RE: AssemblyConvertor Print method fails
(in response to Little Cthulhu)

Thank you for your replay

Tried with square bracket but still getting "Object dosen't support this property " error
I am using V5 R21

Regards

Little Cthulhu

RE: AssemblyConvertor Print method fails
(in response to Babu Varghese)

Why there's an extra double quotes after PartNumber?

 

arrayOfVariantOfBSTR1(0) = "PartNumber"""

Babu Varghese

RE: AssemblyConvertor Print method fails
(in response to Little Cthulhu)

Hi Little

Its a typying error. I think this is something to do with VBA because the following VBScript code works

Sub CATMain()

Set productDocument1 = CATIA.ActiveDocument

Set product1 = productDocument1.Product

Set assemblyConvertor1 = product1.GetItem("ListingReport")

Dim arrayOfVariantOfBSTR1(2)
arrayOfVariantOfBSTR1(0) = "PartNumber"
arrayOfVariantOfBSTR1(1) = "DescriptionRef"
arrayOfVariantOfBSTR1(2) = "Revision"
assemblyConvertor1.SetCurrentFormat arrayOfVariantOfBSTR1

assemblyConvertor1.Print "TXT", "C:\Temp\Test.txt", product1

End Sub

Regards

Cliff Johnson, Cliff

RE: AssemblyConvertor Print method fails
(in response to Babu Varghese)

In VBA you need to both declare the type for the assembly converter object and use [Print]

Yes this is a VBA problem which is documented in the Dassault Knowledge Base. 

So try this:

 

Sub CATMain()
Set productDocument1 = CATIA.ActiveDocument
Set product1 = productDocument1.Product
Dim assemblyConverter1 as AssemblyConverter
Set assemblyConvertor1 = product1.GetItem("ListingReport")
Dim arrayOfVariantOfBSTR1(2)
arrayOfVariantOfBSTR1(0) = "PartNumber"
arrayOfVariantOfBSTR1(1) = "DescriptionRef"
arrayOfVariantOfBSTR1(2) = "Revision"
Dim vAC as Variant  'To Avoid the Function or Interface Marked as restricted error
Set vAC = assemblyConverter1
vAC.SetCurrentFormat arrayOfVariantOfBSTR1
assemblyConvertor1.[Print] "TXT", "C:\Temp\Test.txt", product1
End Sub
Edited By:
Cliff Johnson, Cliff[Tata Technologies] @ Sep 12, 2014 - 08:06 AM (America/Eastern)

Babu Varghese

RE: AssemblyConvertor Print method fails
(in response to Cliff Johnson, Cliff)

Sorted....

Thanks Cliff.


Sub CATMain()
Set productDocument1 = CATIA.ActiveDocument
Set product1 = productDocument1.Product
Dim assemblyConvertor1 as AssemblyConverter
Set assemblyConvertor1 = product1.GetItem("ListingReport")
Dim arrayOfVariantOfBSTR1(2)
arrayOfVariantOfBSTR1(0) = "PartNumber"
arrayOfVariantOfBSTR1(1) = "DescriptionRef"
arrayOfVariantOfBSTR1(2) = "Revision"
Dim vAC as Variant  'To Avoid the Function or Interface Marked as restricted error
Set vAC = assemblyConvertor1
vAC.SetCurrentFormat arrayOfVariantOfBSTR1
assemblyConvertor1.[Print] "TXT", "C:\Temp\Test.txt", product1
End Sub


LECLERC Sebastien

RE: AssemblyConvertor Print method fails
(in response to Babu Varghese)

Salut :)

 

Ne semble pas fonctionner sur ma version (CATIAV5R28SP6) :  " L' objet ne prend pas en charge cette propriété "

Mais travailler en CATScript oui. 

I try with [Print], with Object declare with "Objet", "AssemblyConvertor" or "CATBaseDispatch" no work.

Dim assemblyConvertor1 As AssemblyConvertor
Set assemblyConvertor1 = product1.GetItem("BillOfMaterial")



Edited By:
LECLERC Sebastien[Subscriber Members] @ Nov 15, 2021 - 04:03 PM (IDLW)
LECLERC Sebastien[Subscriber Members] @ Nov 15, 2021 - 04:06 PM (IDLW)