Hello, all
I am using Micha's render tools and within the tools, there are scripts written by Gelfling in 04.
This buttons save views and render all the saved views with another button.
Only issue is that the button saves views in parallel perspective regardless of my current normal perspective. (I want to save in normal perspective).
Can someone who knows about scripting help me out? (I have no knowledge on scripting..)
I really need you guys' help
Thank you in advance!
========= SCRIPT TO ADD SCENES=========
-_RunScript (
Option Explicit
'Script written by Gelfling '04
Sub AddQueueElement()
Dim strCurrentView 'As String
Dim curCamPosition 'As PointArray
Dim curTarPosition 'As PointArray
Dim curPerspective 'As Boolean
Dim curPerspectiveAngle 'As Double
Dim curViewUpVector 'As PointArray
Dim strQueueCode 'As String
Dim allCodes 'As StringArray
strCurrentView = Rhino.CurrentView
If Rhino.IsViewPerspective(strCurrentView) Then
curPerspective = True
curCamPosition = Rhino.ViewCamera(strCurrentView)
curTarPosition = Rhino.ViewTarget(strCurrentView)
curViewUpVector = Rhino.ViewCameraUp(strCurrentView)
curPerspectiveAngle = Rhino.ViewCameraLens(strCurrentView)
Else
curPerspective = False
curCamPosition = Rhino.ViewCamera(strCurrentView)
curTarPosition = Rhino.ViewTarget(strCurrentView)
curViewUpVector = Rhino.ViewCameraUp(strCurrentView)
curPerspectiveAngle = 1.5E300
End If
allCodes = AllQueueCodes()
If IsNull(allCodes) Then
strQueueCode = Rhino.StringBox("Name of new queue element [" & strCurrentView & "]", strCurrentView, "Render queue manager")
If IsNull(strQueueCode) Then Exit Sub
Else
strQueueCode = Rhino.ComboListBox (allCodes, "Name of new queue element", "Render queue manager")
If IsNull(strQueueCode) Then Exit Sub
End If
AddQueueCode strQueueCode, curCamPosition, curTarPosition, curPerspective, curPerspectiveAngle, curViewUpVector
End Sub
AddQueueElement
Function AllQueueCodes()
AllQueueCodes = Null
Dim allCodes
Dim i, N
Dim queCodes()
allCodes = Rhino.GetDocumentData()
If Not IsArray(allCodes) Then Exit Function
N = 0
For i = 0 To UBound(allCodes)
If Left(allCodes(i),14) = "GELFLINGQUEUE_" Then
ReDim Preserve queCodes(N)
queCodes(N) = Mid(allCodes(i),15)
N = N+1
End If
Next
If N = 0 Then Exit Function
AllQueueCodes = queCodes
End Function
Function IsQueueCode(strQueueCode)
Dim varRet
IsQueueCode = False
varRet = Rhino.GetDocumentData("GELFLINGQUEUE_" & strQueueCode)
If Not IsNull(varRet) Then IsQueueCode = True
End Function
Function AddQueueCode(strCode, arrCam, arrTar, blnPerspective, dblAngle, arrUp)
Rhino.SetDocumentData "GELFLINGQUEUE_" & strCode, "CAMERA", Rhino.Pt2Str(arrCam)
Rhino.SetDocumentData "GELFLINGQUEUE_" & strCode, "TARGET", Rhino.Pt2Str(arrTar)
Rhino.SetDocumentData "GELFLINGQUEUE_" & strCode, "VIEWUP", Rhino.Pt2Str(arrUp)
If blnPerspective Then
Rhino.SetDocumentData "GELFLINGQUEUE_" & strCode, "TYPE", "Perspective"
Else
Rhino.SetDocumentData "GELFLINGQUEUE_" & strCode, "TYPE", "Parallel"
End If
Rhino.SetDocumentData "GELFLINGQUEUE_" & strCode, "ANGLE", CStr(dblAngle)
AddQueueCode = True
End Function
)
=======SCRIPT TO RENDER ALL SAVED SCENES IN THE QUEUE=======================
-_RunScript (
Option Explicit
'Script written by Gelfling '04
'Change: Updated/Fixed formats 'Damien Alomar, ASGvis
Sub RenderQueue()
Dim allCodes, chkCodes()
Dim selCodes
Dim i
Dim strFolderPath
Dim FileFormat
Dim curView
curView = Rhino.CurrentView
allCodes = AllQueueCodes
If IsNull(allCodes) Then
Rhino.Print "There are no stored views in the render-queue"
Exit Sub
End If
ReDim chkCodes(UBound(allCodes))
For i = 0 To UBound(chkCodes)
chkCodes(i) = vbTrue
Next
selCodes = Rhino.CheckListBox(allCodes, chkCodes, "Select queue elements to render", "Render queue manager")
If IsNull(selCodes) Then Exit Sub
FileFormat = Rhino.ListBox(Array("JPEG", "Bitmap", "Targa", "Tiff", "PNG", "HDR", "EXR"), "Select a fileformat to use", "Render queue manager")
If IsNull(FileFormat) Then Exit Sub
Select Case UCase(FileFormat)
Case "JPEG": FileFormat = ".jpeg"
Case "BITMAP": FileFormat = ".bmp"
Case "TARGA": FileFormat = ".tga"
Case "TIFF": FileFormat = ".tiff"
Case "PNG": FileFormat = ".png"
Case "HDR": FileFormat = ".hdr"
Case "EXR": FileFormat = ".exr"
Case Else: FileFormat = ".bmp"
End Select
strFolderPath = Rhino.BrowseForFolder(,"Select a folder to save to", "Render queue manager")
If IsNull(strFolderPath) Then Exit Sub
If msgBox("Are you sure all settings are correct?" & vbNewLine & _
"Render engine, resolution, quality...", _
vbYesNo Or vbQuestion, "Render queue manager") = vbNo Then Exit Sub
For i = 0 To UBound(allCodes)
If selCodes(i) Then
Rhino.Print "Element [" & allCodes(i) & "] restored..."
Call RestoreQueueCode(allCodes(i), curView)
Rhino.Command "-_Render", vbFalse
Rhino.Command "-_SaveRenderWindowAs " & Chr(34) & strFolderPath & allCodes(i) & FileFormat & Chr(34), vbFalse
Rhino.Command "-_CloseRenderWindow", vbFalse
Else
Rhino.Print "Element [" & allCodes(i) & "] skipped in queue..."
End If
Next
Rhino.Print "Completed!"
End Sub
RenderQueue
Function AllQueueCodes()
AllQueueCodes = Null
Dim allCodes
Dim i, N
Dim queCodes()
allCodes = Rhino.GetDocumentData()
If Not IsArray(allCodes) Then Exit Function
N = 0
For i = 0 To UBound(allCodes)
If Left(allCodes(i),14) = "GELFLINGQUEUE_" Then
ReDim Preserve queCodes(N)
queCodes(N) = Mid(allCodes(i),15)
N = N+1
End If
Next
If N = 0 Then Exit Function
AllQueueCodes = queCodes
End Function
Function RestoreQueueCode(strCode, strView)
Rhino.EnableRedraw vbFalse
Dim newCamPosition 'As PointArray
Dim newTarPosition 'As PointArray
Dim newPerspective 'As Boolean
Dim newPerspectiveAngle 'As Double
Dim newViewUpVector 'As PointArray
newCamPosition = Rhino.Str2Pt(Rhino.GetDocumentData("GELFLINGQUEUE_ " & strCode, "CAMERA"))
newTarPosition = Rhino.Str2Pt(Rhino.GetDocumentData("GELFLINGQUEUE_ " & strCode, "TARGET"))
If Rhino.GetDocumentData("GELFLINGQUEUE_" & strCode, "TYPE") = "Perspective" Then
newPerspective = True
Else
newPerspective = False
End If
newPerspectiveAngle = CDbl(Rhino.GetDocumentData("GELFLINGQUEUE_" & strCode, "ANGLE"))
newViewUpVector = Rhino.Str2Pt(Rhino.GetDocumentData("GELFLINGQUEUE_ " & strCode, "VIEWUP"))
If newPerspective Then
Rhino.ViewProjection strView, 0
Rhino.ViewCameraTarget strView, newCamPosition, newTarPosition
Rhino.ViewCameraUp strView, newViewUpVector
Rhino.ViewCameraLens strView, newPerspectiveAngle
Else
Rhino.ViewProjection strView, 1
Rhino.ViewCameraTarget strView, newCamPosition, newTarPosition
Rhino.ViewCameraUp strView, newViewUpVector
End If
Rhino.EnableRedraw vbTrue
RestoreQueueCode = True
End Function
)
================================================== ================
I am using Micha's render tools and within the tools, there are scripts written by Gelfling in 04.
This buttons save views and render all the saved views with another button.
Only issue is that the button saves views in parallel perspective regardless of my current normal perspective. (I want to save in normal perspective).
Can someone who knows about scripting help me out? (I have no knowledge on scripting..)
I really need you guys' help
Thank you in advance!
========= SCRIPT TO ADD SCENES=========
-_RunScript (
Option Explicit
'Script written by Gelfling '04
Sub AddQueueElement()
Dim strCurrentView 'As String
Dim curCamPosition 'As PointArray
Dim curTarPosition 'As PointArray
Dim curPerspective 'As Boolean
Dim curPerspectiveAngle 'As Double
Dim curViewUpVector 'As PointArray
Dim strQueueCode 'As String
Dim allCodes 'As StringArray
strCurrentView = Rhino.CurrentView
If Rhino.IsViewPerspective(strCurrentView) Then
curPerspective = True
curCamPosition = Rhino.ViewCamera(strCurrentView)
curTarPosition = Rhino.ViewTarget(strCurrentView)
curViewUpVector = Rhino.ViewCameraUp(strCurrentView)
curPerspectiveAngle = Rhino.ViewCameraLens(strCurrentView)
Else
curPerspective = False
curCamPosition = Rhino.ViewCamera(strCurrentView)
curTarPosition = Rhino.ViewTarget(strCurrentView)
curViewUpVector = Rhino.ViewCameraUp(strCurrentView)
curPerspectiveAngle = 1.5E300
End If
allCodes = AllQueueCodes()
If IsNull(allCodes) Then
strQueueCode = Rhino.StringBox("Name of new queue element [" & strCurrentView & "]", strCurrentView, "Render queue manager")
If IsNull(strQueueCode) Then Exit Sub
Else
strQueueCode = Rhino.ComboListBox (allCodes, "Name of new queue element", "Render queue manager")
If IsNull(strQueueCode) Then Exit Sub
End If
AddQueueCode strQueueCode, curCamPosition, curTarPosition, curPerspective, curPerspectiveAngle, curViewUpVector
End Sub
AddQueueElement
Function AllQueueCodes()
AllQueueCodes = Null
Dim allCodes
Dim i, N
Dim queCodes()
allCodes = Rhino.GetDocumentData()
If Not IsArray(allCodes) Then Exit Function
N = 0
For i = 0 To UBound(allCodes)
If Left(allCodes(i),14) = "GELFLINGQUEUE_" Then
ReDim Preserve queCodes(N)
queCodes(N) = Mid(allCodes(i),15)
N = N+1
End If
Next
If N = 0 Then Exit Function
AllQueueCodes = queCodes
End Function
Function IsQueueCode(strQueueCode)
Dim varRet
IsQueueCode = False
varRet = Rhino.GetDocumentData("GELFLINGQUEUE_" & strQueueCode)
If Not IsNull(varRet) Then IsQueueCode = True
End Function
Function AddQueueCode(strCode, arrCam, arrTar, blnPerspective, dblAngle, arrUp)
Rhino.SetDocumentData "GELFLINGQUEUE_" & strCode, "CAMERA", Rhino.Pt2Str(arrCam)
Rhino.SetDocumentData "GELFLINGQUEUE_" & strCode, "TARGET", Rhino.Pt2Str(arrTar)
Rhino.SetDocumentData "GELFLINGQUEUE_" & strCode, "VIEWUP", Rhino.Pt2Str(arrUp)
If blnPerspective Then
Rhino.SetDocumentData "GELFLINGQUEUE_" & strCode, "TYPE", "Perspective"
Else
Rhino.SetDocumentData "GELFLINGQUEUE_" & strCode, "TYPE", "Parallel"
End If
Rhino.SetDocumentData "GELFLINGQUEUE_" & strCode, "ANGLE", CStr(dblAngle)
AddQueueCode = True
End Function
)
=======SCRIPT TO RENDER ALL SAVED SCENES IN THE QUEUE=======================
-_RunScript (
Option Explicit
'Script written by Gelfling '04
'Change: Updated/Fixed formats 'Damien Alomar, ASGvis
Sub RenderQueue()
Dim allCodes, chkCodes()
Dim selCodes
Dim i
Dim strFolderPath
Dim FileFormat
Dim curView
curView = Rhino.CurrentView
allCodes = AllQueueCodes
If IsNull(allCodes) Then
Rhino.Print "There are no stored views in the render-queue"
Exit Sub
End If
ReDim chkCodes(UBound(allCodes))
For i = 0 To UBound(chkCodes)
chkCodes(i) = vbTrue
Next
selCodes = Rhino.CheckListBox(allCodes, chkCodes, "Select queue elements to render", "Render queue manager")
If IsNull(selCodes) Then Exit Sub
FileFormat = Rhino.ListBox(Array("JPEG", "Bitmap", "Targa", "Tiff", "PNG", "HDR", "EXR"), "Select a fileformat to use", "Render queue manager")
If IsNull(FileFormat) Then Exit Sub
Select Case UCase(FileFormat)
Case "JPEG": FileFormat = ".jpeg"
Case "BITMAP": FileFormat = ".bmp"
Case "TARGA": FileFormat = ".tga"
Case "TIFF": FileFormat = ".tiff"
Case "PNG": FileFormat = ".png"
Case "HDR": FileFormat = ".hdr"
Case "EXR": FileFormat = ".exr"
Case Else: FileFormat = ".bmp"
End Select
strFolderPath = Rhino.BrowseForFolder(,"Select a folder to save to", "Render queue manager")
If IsNull(strFolderPath) Then Exit Sub
If msgBox("Are you sure all settings are correct?" & vbNewLine & _
"Render engine, resolution, quality...", _
vbYesNo Or vbQuestion, "Render queue manager") = vbNo Then Exit Sub
For i = 0 To UBound(allCodes)
If selCodes(i) Then
Rhino.Print "Element [" & allCodes(i) & "] restored..."
Call RestoreQueueCode(allCodes(i), curView)
Rhino.Command "-_Render", vbFalse
Rhino.Command "-_SaveRenderWindowAs " & Chr(34) & strFolderPath & allCodes(i) & FileFormat & Chr(34), vbFalse
Rhino.Command "-_CloseRenderWindow", vbFalse
Else
Rhino.Print "Element [" & allCodes(i) & "] skipped in queue..."
End If
Next
Rhino.Print "Completed!"
End Sub
RenderQueue
Function AllQueueCodes()
AllQueueCodes = Null
Dim allCodes
Dim i, N
Dim queCodes()
allCodes = Rhino.GetDocumentData()
If Not IsArray(allCodes) Then Exit Function
N = 0
For i = 0 To UBound(allCodes)
If Left(allCodes(i),14) = "GELFLINGQUEUE_" Then
ReDim Preserve queCodes(N)
queCodes(N) = Mid(allCodes(i),15)
N = N+1
End If
Next
If N = 0 Then Exit Function
AllQueueCodes = queCodes
End Function
Function RestoreQueueCode(strCode, strView)
Rhino.EnableRedraw vbFalse
Dim newCamPosition 'As PointArray
Dim newTarPosition 'As PointArray
Dim newPerspective 'As Boolean
Dim newPerspectiveAngle 'As Double
Dim newViewUpVector 'As PointArray
newCamPosition = Rhino.Str2Pt(Rhino.GetDocumentData("GELFLINGQUEUE_ " & strCode, "CAMERA"))
newTarPosition = Rhino.Str2Pt(Rhino.GetDocumentData("GELFLINGQUEUE_ " & strCode, "TARGET"))
If Rhino.GetDocumentData("GELFLINGQUEUE_" & strCode, "TYPE") = "Perspective" Then
newPerspective = True
Else
newPerspective = False
End If
newPerspectiveAngle = CDbl(Rhino.GetDocumentData("GELFLINGQUEUE_" & strCode, "ANGLE"))
newViewUpVector = Rhino.Str2Pt(Rhino.GetDocumentData("GELFLINGQUEUE_ " & strCode, "VIEWUP"))
If newPerspective Then
Rhino.ViewProjection strView, 0
Rhino.ViewCameraTarget strView, newCamPosition, newTarPosition
Rhino.ViewCameraUp strView, newViewUpVector
Rhino.ViewCameraLens strView, newPerspectiveAngle
Else
Rhino.ViewProjection strView, 1
Rhino.ViewCameraTarget strView, newCamPosition, newTarPosition
Rhino.ViewCameraUp strView, newViewUpVector
End If
Rhino.EnableRedraw vbTrue
RestoreQueueCode = True
End Function
)
================================================== ================
Comment