crillejohan
Mechanical
Been looking into using VB.NET and Visual Studio (2017) to control an (semi-)automation application in CATIA v5 (running R24).
Up until recently, things were going well, “transferring” code from VBA in Catia to Visual Studio; but now I ran into some issues with adding CATparts to a CATProduct (i.e., assembly).
Upon trying to use AddComponentsFromFiles I get stuck. One thing I notice is that the Variant type that is used in VBA has been deleted from VB.NET, and so the tooltip says it’s an Array type now.
In VBA, the standard procedure (i.e., macro recording) is to use:
----
Sub CATMain()
Dim productDocument1 As ProductDocument
Set productDocument1 = CATIA.ActiveDocument
Dim product1 As Product
Set product1 = productDocument1.Product
Dim products1 As Products
Set products1 = product1.Products
Dim arrayOfVariantOfBSTR1(0)
arrayOfVariantOfBSTR1(0) = "C:\temp\test-cylinder.CATPart"
Set products1Variant = products1
products1Variant.AddComponentsFromFiles arrayOfVariantOfBSTR1, "All"
End Sub
-----
However, when I transfer – in every which way I can think of including putting the file name into an Array type – I get different types of errors, but no real indication of a way forwards.
Anyone tried anything similar / can point me in some direction?
Thanks.
Up until recently, things were going well, “transferring” code from VBA in Catia to Visual Studio; but now I ran into some issues with adding CATparts to a CATProduct (i.e., assembly).
Upon trying to use AddComponentsFromFiles I get stuck. One thing I notice is that the Variant type that is used in VBA has been deleted from VB.NET, and so the tooltip says it’s an Array type now.
In VBA, the standard procedure (i.e., macro recording) is to use:
----
Sub CATMain()
Dim productDocument1 As ProductDocument
Set productDocument1 = CATIA.ActiveDocument
Dim product1 As Product
Set product1 = productDocument1.Product
Dim products1 As Products
Set products1 = product1.Products
Dim arrayOfVariantOfBSTR1(0)
arrayOfVariantOfBSTR1(0) = "C:\temp\test-cylinder.CATPart"
Set products1Variant = products1
products1Variant.AddComponentsFromFiles arrayOfVariantOfBSTR1, "All"
End Sub
-----
However, when I transfer – in every which way I can think of including putting the file name into an Array type – I get different types of errors, but no real indication of a way forwards.
Anyone tried anything similar / can point me in some direction?
Thanks.