Inventor Factory API C# to VB

Inventor Factory API C# to VB

mk92
Collaborator Collaborator
583 Views
1 Reply
Message 1 of 2

Inventor Factory API C# to VB

mk92
Collaborator
Collaborator

Hi all,

I want to make my first steps with the Inventor API, especially the Factory API. I found this help page:

Autodesk Knowledge Site

There is a code snippet for placing an specific asset in an factory layout. My problem is I couldn't translate it from C# (I hope this is right?) to Visual Basic.

 

using APIv2 = Autodesk.Factory.PublicAPI.Objects.v2;
…
var api = Autodesk.Factory.PublicAPI.API.Instance;
APIv2.AssetInstance newInst1 = new APIv2.AssetInstance()
{
AssetID = "41c84844-7b28-4903-bebd-365ca3a6a53c",  //Straight Belt Conveyor
Position = new System.Windows.Media.Media3D.Matrix3D() { OffsetX = 0, OffsetY = 0, OffsetZ = 0 },
};
var insts = api.AddAssetInstances(layout, new PublicAPI.Currency.v2.IAssetInstance[] { newInst1 });
System.Windows.MessageBox.Show(insts.Length.ToString(), "Added instances");

 

 

Is there anybody who can help? Or is there any example for a vb code doing anything similar?

 

Kind regards,

mk

0 Likes
584 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

The Telerik code converter translates it like this:

Imports APIv2 = Autodesk.Factory.PublicAPI.Objects.v2
...
Private Sub SurroundingSub()
    Dim api = Autodesk.Factory.PublicAPI.API.Instance
    Dim newInst1 As APIv2.AssetInstance = New APIv2.AssetInstance() With {
        .AssetID = "41c84844-7b28-4903-bebd-365ca3a6a53c",
        .Position = New System.Windows.Media.Media3D.Matrix3D() With {
            .OffsetX = 0,
            .OffsetY = 0,
            .OffsetZ = 0
        }
    }
    Dim insts = api.AddAssetInstances(layout, New PublicAPI.Currency.v2.IAssetInstance() {newInst1})
    System.Windows.MessageBox.Show(insts.Length.ToString(), "Added instances")
End Sub


Keep in mind you have to substitute whatever else you have in your code where it shows the "..."

 

0 Likes