Notifications
Clear all

[Closed] RadioButton Problem

I have a radio button that would add the format type at the end of certain text to create a file output type in my renderer… Example:“Test.tga” But the radio button text does not show, and I do not get an error message. My code will help explain:

-- creates my radio buttons
radiobuttons rdoFileType labels:#("rpf", "tga", "jpg") default:1

-- tells the button number what text to display.
on rdoFileType changed type do (case state of
				(
					1: ".rpf"
					2: ".tga"
					3: ".jpg"
				)
			)

-- Creates a variable that converts my button info into text.
FileType = rdoFileType.state as string

-- Creates a variable that generates the output file type text.
-- txtSavePath.text and CameraName are other variables that add to the text, they work fine.
saveFile = txtSavePath.text + "\\" + cameraName + "\\" + cameraName + "_" + FileType

-- saves all text in the Output of the renderer.
rendOutputFilename = saveFile

What am I missing? It doesn’t show .tga, .rpf, or .jpg at the end

16 Replies

Should your filetype pulldown change event be an assignment of some kind? Right now you’re assigning the FileType variable to rdoFileType.state (which would be a number like “2”) as a string. Change the line quoted above to


 FileType = rdoFileType.items[rdoFileType.state]

That should yield the string you want. (Can’t test it, though. Gotta go!)

You don’t appear to be assigning the strings to the actual labels in your case statement. I think you need to assign like this:

 
on rdoFileType changed type do 
(
 fileType = case state of
 (
  1: ".rpf"
  2: ".tga"
  3: ".jpg"
 )
)


I haven’t got time to test right now, but try that. Check the example code in the help file related to radio buttons.

2 Replies
(@bobo)
Joined: 11 months ago

Posts: 0

You had ‘type’ in the handler but ‘state’ in the case statement. Use either one twice and it will work. So

 
 on rdoFileType changed [b]type [/b]do 
 (
  fileType = case [b]type [/b]of
  (
   1: ".rpf"
   2: ".tga"
   3: ".jpg"
  )
 )
 

or

 
 on rdoFileType changed [b]state [/b]do 
 (
  fileType = case [b]state [/b]of
  (
   1: ".rpf"
   2: ".tga"
   3: ".jpg"
  )
 )
 
 
(@erilaz)
Joined: 11 months ago

Posts: 0

This is what happens when I try to remember code without max in front of me.

Mr-BlueSummers,

I get an error message when I modify my fileType variable to your settings…

“Unknown property: “items” in RadioControl:rdoFileType”

This is what I have:

group "Final Rendering"
 (
 radiobuttons rdoFileType labels:#("rpf", "tga", "jpg") default:1
 )
 
 on rdoFileType changed type do
 			(
 				case state of
 				(
 					1: ".rpf"
 					2: ".tga"
 					3: ".jpg"
 				)
 			)
 local fileType = rdoFileType.items[rdoFileType.state]

Erilaz,

I get an error message when I change my code to your settings…

“Unable to convert: undefined to type: String”

If I keep my old variable “fileType = rdoFileType.state as string” Then it works except a number is behind my output file name. Like “test1” not “test.tga”

What am I doing wrong?

Also, I have been using the script help file, I wouldn’t have gotten this far without it;) But Im at a roadblock and can’t find the solution.

1 Reply
(@erilaz)
Joined: 11 months ago

Posts: 0

Instead of state, maybe try b[/b] in the case expression

Still no go It’s driving me crazy because I feel like it should be simple but Im at a lost Im trying modified version of from the feedback you gave me, but nothing Im doing works. If you need more information, please let me know!

The closest I can get are the numbers listing properly, but I can’t get the text like “.rpf” to show up in the number’s place…

When I get a moment i’ll try to recreate what you’re doing.

Found a moment.


 
(
rollout testCase "Test"
(
 radioButtons testRadio Labels:#("test1", "test2", "test3")
 on testRadio changed state do
 (
  fileType = case testRadio.state of
  (
   1:"test1"
   2:"test2"
   3:"test3"
  )
  print fileType
 )
)
createDialog testCase
)
  

I ran this and I get the correct string output.

Im home now, I will try this first thing in the morning. I swore I had something like this already, but I will try exactly what you have. Thanks for helping!!

Ditto. :hmm:

My code is still returning a number value Here is what I have exactly:

group "Final Rendering"
(
radiobuttons rdoFileType labels:#("rpf", "tga", "jpg") default:1
button butFinal "Setup Final Rendering"
)
on rdoFileType changed state do
			(
				fileType = case state of
				(
					1: ".rpf"
					2: ".tga"
					3: ".jpg"
				)
			)

on butFinal pressed do
		(
		  FileType = rdoFileType.state as string

-- ignore the txtSavePath.text and cameraName variables, they work fine.
saveFile = txtSavePath.text + "\\" + cameraName + "\\" + cameraName + "_" + fileType
rendOutputFilename = saveFile
)

Pressing the button returns a value of 1, 2, or 3. Not .rpf, tga, or jpg. What am I missing?

Page 1 / 2