Notifications
Clear all
[Closed] Open dialogue for several files at once
May 25, 2008 4:32 pm
I want to create a script that lets me select a bunch of JPG files and that creates for each JPG a plane with a material of that JPG assigned to it. Now I’ve managed to do that with one File:
f = getOpenFileName caption:"Open JPGs" types:"JPG (*.jpg)|*.jpg|All Files (*.*)|*.*|"
myFile = filenameFromPath f
myPlane = plane()
myPlane.name = myFile
myPlane.length = 30
myPlane.width = 40
myPlane.material = standard diffuseMap:(myBitmap) showInViewport:true name:myFile Self_Illumination:100
Work perfectly but getOpenFileName lets me only select one JPG at a time. How do I do that if I want to select several JPGs at once?
4 Replies
May 25, 2008 4:32 pm
Ha! It works. This is my final code:
theDialog = dotNetObject "System.Windows.Forms.OpenFileDialog"
theDialog.title = "PLEASE Select One Or More Files"
theDialog.Multiselect = true
theDialog.Filter = "JPG Files (*.jpg)|*.jpg|All Files (*.*)|*.*"
theDialog.FilterIndex = 1
result = theDialog.showDialog()
result.ToString()
result.Equals result.OK
theFilenames = theDialog.fileNames
if result.Equals result.OK then
(
myZ = 0
for o in theFilenames do
(
myFile = filenameFromPath o
myPlane = plane()
myPlane.name = myFile
myPlane.length = 30
myPlane.width = 40
myPlane.pos.z = myZ
myBitmap = bitmaptexture()
myBitmap.filename = o
myBitmap.reload()
myPlane.material = standard diffuseMap:(myBitmap) showInViewport:true name:myFile Self_Illumination:100
myZ = myZ + 10
)
)
Thank you! Again. You have been a great help!
May 25, 2008 4:32 pm
Just thinking out loud here krystman but you might want to check the aspect ratio of all the jpegs you’re importing and respect that in the plane size as well. Just in case you have JPegs of different sizes to avoid stretching.