Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
1039 Views, 2 Replies

Inventor Studio vba rendering

Hi all,

 

I've got 25 cameras set-up and I would like to render each one for 3 hours.

I want to create a vba code to run all in batch mode.

The code is almost done (thanks internet :slightly_smiling_face: but I'm stuck in last step with is lanching the render and save it in a folder as .jpg file.

I read someone who used ..... oRenderManager.rendertofile "C:\temp\render1.jpg" ... but it doesn't work with me (don't know why) I'm getting run-time error 13.

 

Does anybody know how to lanch a camera based render and save it as *.jpg file in a folder?

 

Thanks in advance,

Jorge

 

 

Ps: please see below the code so far...

 

##############################################

 

Sub StudioRender()

' Find the Studio Add-In
Dim oStudioAddin As ApplicationAddIn
Set oStudioAddin = ThisApplication.ApplicationAddIns.Item(29)

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
'Dim xxx As ApplicationAddIn

' 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("Grid Light")

X = 1
Do Until X > oInventorStudio.StudioCameras.Count

'activate lights per room

'code here

' Set the Camera.
oRenderManager.camera = oInventorStudio.StudioCameras.Item(X)

' 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.

oRenderManager.rendertofile "C:\temp\render1.jpg" ' >>> this is where I get the error

X = X + 1
Loop

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

End Sub

 

#############################

 

YuhanZhang
in reply to: Anonymous

Can you try the code if you un-comment the line below:

 

' Dim oRenderManager As InventorStudioLib.RenderManager


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Anonymous
in reply to: Anonymous

Hi jorgesmd,

have you solved your issue already?

i got stuck in a similar case:

I found the Addin in Item(29), but when the Item(29).Automation is empty and therefore i can not get the Inventor Studio Object. Does anybody know how i can fix it?

Thanks!