How do I access Inventor Studio elements

How do I access Inventor Studio elements

VoteCoffee
Explorer Explorer
2,401 Views
10 Replies
Message 1 of 11

How do I access Inventor Studio elements

VoteCoffee
Explorer
Explorer
Using either VBA or VB.NET, how do I access Inventor Studio elements (such as creating cameras, scenes, lighting and rendering)? Is there an API/library/scripting language for this?
0 Likes
2,402 Views
10 Replies
Replies (10)
Message 2 of 11

philippe.leefsma
Alumni
Alumni

Unfortunately you can't create studio elements from the API, it mainly provides access to existing elements.

 

Here is a VBA sample that illustrates how to generate a rendered image, supposing you have an existing camera "MyCamera" created manually in the studio environment:

 

Sub StudioRender()

    ' Find the Studio Add-In
    Dim oStudioAddin As ApplicationAddIn
    Set oStudioAddin = ThisApplication.ApplicationAddIns.ItemById("{F3D38928-74D1-4814-8C24-A74CE8F3B2E3}")
       
    If oStudioAddin Is Nothing Then
        MsgBox "Inventor Studio Addin not loaded."
        Exit Sub
    End If

    ' Get the Inventor Studio object.
    Dim oInventorStudio As InventorStudioLib.InventorStudio
    Set oInventorStudio = oStudioAddin.Automation

    ' Get the environment manager for the active document.
    Dim oEnvironmentMgr As EnvironmentManager
    Set oEnvironmentMgr = ThisApplication.ActiveDocument.EnvironmentManager

    ' Get the current environment.
    Dim oCurrentEnvironment As Environment
    Dim strEditID As String
    Call oEnvironmentMgr.GetCurrentEnvironment(oCurrentEnvironment, strEditID)

    ' Activate the Studio environment.
    Dim oStudioEnvironment As Environment
    Set oStudioEnvironment = oInventorStudio.activate

    ' Get a reference to the RenderManager
    Dim oRenderManager As InventorStudioLib.RenderManager
    Set oRenderManager = oInventorStudio.RenderManager

    ' Set the active lighting style.
    oInventorStudio.ActiveLightingStyle = oInventorStudio.StudioLightingStyles.item("Pleasant")

    ' Set the Camera.
    oRenderManager.camera = oInventorStudio.StudioCameras.item("MyCamera")

    ' Set the active Scene.
    oInventorStudio.ActiveSceneStyle = oInventorStudio.StudioSceneStyles.item("Starfield")

    ' Set the output resolution to the size of the current view.
    oRenderManager.ImageWidth = ThisApplication.ActiveView.width
    oRenderManager.ImageHeight = ThisApplication.ActiveView.height
    'oRenderManager.AntiAliasing
    
    ' Render the image.
    Call oRenderManager.RenderToFile("C:\Temp\Render.bmp")

    ' Reset the environment to whatever it was before
    ' we entered the Studio environment.
    Call oEnvironmentMgr.SetCurrentEnvironment(oCurrentEnvironment)
    
End Sub

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 11

Anonymous
Not applicable

Hi Phillippe,

 

i have a problem with your function..

 

i use inventor 2016 and visual studio 2012. 

 

the line "Dim oInventorStudio As InventorStudioLib.InventorStudio" give me a error "Type InventorStudioLib is not defined"

 

I try add reference "archon.dll" but give me a error "a reference to c:\....\archon.dll could not be added. Please make sure that the file is acessible, and that is a valid assembly or com component." I try registry the "archon.dll"but no success.

 

thanks.

0 Likes
Message 4 of 11

Anonymous
Not applicable

@Anonymous wrote:

 

"I try add reference "archon.dll" but give me a error "a reference to c:\....\archon.dll could not be added. Please make sure that the file is acessible, and that is a valid assembly or com component." I try registry the "archon.dll"but no success."

 


I had the same issue with Inventor 2015. I resolved it as follows

Go to start and in the search box type in "CMD"

type in "CD program files\autodesk\program files\bin" then press enter

type in "regsvr32 archon.dll" and press enter 

You should get a dialog box that says "DLLRegisterServer in Archon.dll succeeded"

Then you should be good to go

Below you should be able to see my screenshots of doing it on 2015.

0 Likes
Message 5 of 11

daniel.hunziker
Observer
Observer

have seen that there is an option parameter in RenterToFile, what the values could be?

0 Likes
Message 6 of 11

Anonymous
Not applicable

Can someone point me in the right direction on how to use this code? do I run it as a macro or as an ilogic rule?

Message 7 of 11

Anonymous
Not applicable

Hi,

 

I'm getting "Compile error: User-defined type not defined" at line: "Dim oInventorStudio As InventorStudioLib.InventorStudio".

I'm using Autodesk Inventor professional 2017.

Does this macro not work with version 2017?

I also couldn't find any objects linked to inventor studio.

 

Does anyone have a solution?

 

Janeau

0 Likes
Message 8 of 11

A_Sandbote
Contributor
Contributor

You must add the Archon.cll to your VBA Projekt to run the code...

 

13.09.png

0 Likes
Message 9 of 11

A_Sandbote
Contributor
Contributor
Hello, i have one Question about some settings of the rendermanager... The method "RenderToFile" has some options... can someone give me the option of the NameValueMap ??? i have found nothing about it....
Message 10 of 11

_KarlH
Enthusiast
Enthusiast

Accessing Inventor Studio via iLogic is a game changer! Does anyone have any links handy to supporting documentation for the Studio Add In?

Also some feedback - I've found that this iLogic Inventor Studio batch rendering will only work when the Render Settings held within the Inventor Assembly or Part file is set to "Render by iteration" via the Renderer settings found in "Render Image" control panel. If this setting is set to "Render Time" then iLogic will output a batch of blank images - at least in my experience.

 

Keen to know if others have also experienced or fixed this issue.

 

0 Likes
Message 11 of 11

_KarlH
Enthusiast
Enthusiast

Just a side question on Inventor Studio and batch rendering via iLogic - is there a method to check if the Inventor Studio Camera is either visible or hidden? It would be a useful toggle for the operator to switch cameras on or off for their render batch session. I had a look but couldn't identify anything.

 

_KarlH_0-1660202678562.png

 

The quickest alternative I can think of would be to have a keyword that a user can rename camera views with, that are then whitelisting/blacklisting cameras for the batch render process.

 

0 Likes