Error: unknown property

Hello
I worked on the camera parameters interface and ran into a problem.
The interface does not start if the camera is not selected. (Unknown property)
Tell me how to fix this?
Can I see changes in camera settings in my interface?
Thanks :-)

AttachmentSize
cam_parameter-error.ms1.5 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

You have to edit your code, because when you change values of any of the spinner if the selected object is not your camera you will get an error.

(
	try(destroyDialog ::Cam_P)catch()
-- 	Cam_P_iso_x = getinisetting "$plugcfg\\CamParam.ini" "Cam_P" "pos_x" as integer
-- 	Cam_P_iso_y = getinisetting "$plugcfg\\CamParam.ini" "Cam_P" "pos_y" as integer
 
	rollout Cam_P "Cam parameter" width:170
	(
		local camObj = undefined
		local camFilm_Width = 0
		local camFocal_length = 0
		local camFov = 0
		local camZoom_Factor = 0
 
		group"Options"
		(
			label lf_1 "Film gate" align:#left across:2
			spinner sf_1 fieldwidth:50 range:[0,999,camFilm_Width] type:#float scale:0.01 align:#right
			label lf_2 "Focal length" align:#left across:2
			spinner sf_2 fieldwidth:50 range:[0,999,camFocal_length] type:#float scale:0.01 align:#right
			label lf_3 "FOV" align:#left across:2
			spinner sf_3 range:[0,180,camFov] fieldwidth:50 type:#float scale:0.01 align:#right
			checkbox cf_1 "" width:25 height:25 align:#center offset:[0,-25]
			label lf_4 "Zoom factor" align:#left across:2 offset:[0,-5]
			spinner sf_4 fieldwidth:50 range:[0,999,camZoom_Factor] type:#float scale:0.01 align:#right offset:[0,-5]
		)
		on Cam_P close do
		(
			setinisetting "$plugcfg\\CamParam.ini" "Cam_P" "pos_x" ((GetDialogPos Cam_P).x as string)
			setinisetting "$plugcfg\\CamParam.ini" "Cam_P" "pos_y" ((GetDialogPos Cam_P).y as string)
		)
 
		on sf_1 changed val do $.film_width = val
 
		on sf_2 changed val do $.focal_length = val
 
		on sf_3 changed val do $.fov = val
 
		on sf_4 changed val do $.zoom_factor = val
 
		on cf_1 changed true do
		(
			if true then $.specify_fov = on
			else
			(
				$.specify_fov = off
			)
		)
 
		on Cam_P open do
		(
			if selection.count == 1 do
			(
				if superclassof selection[1] == camera do
				(
					camObj = selection[1]
					camFilm_Width = camObj.film_width_mm
					camFocal_length = camObj.focal_length_mm
					camFov = camObj.fov
					camZoom_Factor = camObj.zoom_factor
 
					sf_1.value = camFilm_Width
					sf_2.value = camFocal_length
					sf_3.value = camFov
					sf_4.value = camZoom_Factor
				)
			)
		)
	)
	createDialog Cam_P --pos:[Cam_P_iso_x,Cam_P_iso_y]
)
Igryl9l's picture

Hi Miauu, Thank you so much

Thanks again, the script works.

When the interface starts, I see the camera’s parameters if it is selected. When choosing another camera, I do not see its parameters.
Can I update the interface data when changing the camera?
If yes, please tell me how to do this?

miauu's picture

.

(
	try(destroyDialog ::Cam_P)catch()
-- 	Cam_P_iso_x = getinisetting "$plugcfg\\CamParam.ini" "Cam_P" "pos_x" as integer
-- 	Cam_P_iso_y = getinisetting "$plugcfg\\CamParam.ini" "Cam_P" "pos_y" as integer
	global miauuSelObjChangedNEC
	rollout Cam_P "Cam parameter" width:170
	(
		local camObj = undefined
		local camFilm_Width = 0
		local camFocal_length = 0
		local camFov = 0
		local camZoom_Factor = 0
 
		group"Options"
		(
			label lf_1 "Film gate" align:#left across:2
			spinner sf_1 fieldwidth:50 range:[0,999,camFilm_Width] type:#float scale:0.01 align:#right
			label lf_2 "Focal length" align:#left across:2
			spinner sf_2 fieldwidth:50 range:[0,999,camFocal_length] type:#float scale:0.01 align:#right
			label lf_3 "FOV" align:#left across:2
			spinner sf_3 range:[0,180,camFov] fieldwidth:50 type:#float scale:0.01 align:#right
			checkbox cf_1 "" width:25 height:25 align:#center offset:[0,-25]
			label lf_4 "Zoom factor" align:#left across:2 offset:[0,-5]
			spinner sf_4 fieldwidth:50 range:[0,999,camZoom_Factor] type:#float scale:0.01 align:#right offset:[0,-5]
		)
 
		function miauuSelObjChangedNEC_FN s e = 
		(
			if selection.count == 1 do
			(
				if superclassof selection[1] == camera do
				(
					camObj = selection[1]
					camFilm_Width = camObj.film_width_mm
					camFocal_length = camObj.focal_length_mm
					camFov = camObj.fov
					camZoom_Factor = camObj.zoom_factor
 
					sf_1.value = camFilm_Width
					sf_2.value = camFocal_length
					sf_3.value = camFov
					sf_4.value = camZoom_Factor
				)
			)
-- 			for a in e wheredo print (getAnimByHandle a)
		)
 
		on Cam_P close do
		(
			setinisetting "$plugcfg\\CamParam.ini" "Cam_P" "pos_x" ((GetDialogPos Cam_P).x as string)
			setinisetting "$plugcfg\\CamParam.ini" "Cam_P" "pos_y" ((GetDialogPos Cam_P).y as string)
		)
 
		on sf_1 changed val do $.film_width = val
 
		on sf_2 changed val do $.focal_length = val
 
		on sf_3 changed val do $.fov = val
 
		on sf_4 changed val do $.zoom_factor = val
 
		on cf_1 changed true do
		(
			if true then $.specify_fov = on
			else
			(
				$.specify_fov = off
			)
		)
 
		on Cam_P open do
		(
			miauuSelObjChangedNEC = nodeEventCallback selectionChanged:miauuSelObjChangedNEC_FN
			if selection.count == 1 do
			(
				if superclassof selection[1] == camera do
				(
					camObj = selection[1]
					camFilm_Width = camObj.film_width_mm
					camFocal_length = camObj.focal_length_mm
					camFov = camObj.fov
					camZoom_Factor = camObj.zoom_factor
 
					sf_1.value = camFilm_Width
					sf_2.value = camFocal_length
					sf_3.value = camFov
					sf_4.value = camZoom_Factor
				)
			)
		)
 
		on Cam_P close do
		(
			miauuSelObjChangedNEC = undefined
			gc light:true
		)
	)
	createDialog Cam_P --pos:[Cam_P_iso_x,Cam_P_iso_y]
)
Igryl9l's picture

Thank you very much

I managed to add data synchronization by your records. Now my interface is fully performing the task. Thanks so much for your answers, they help me study MaxScript.

Please tell me how to reset the interface data when resetting the target?

miauu's picture

.

What do you mean by "resetting the target"? When no camera is selected?

Igryl9l's picture

Yes

Scheme:
1) camera selected - data is updated.
2) no camera is selected (target reset) - the data is updated.
In the second case, if the target is reset, I want to see the data = 0
Just as when running a script without selecting a camera, we see data = 0

For example: I added the name of the camera to the interface - when I reset or select, I can see the changes in the name by analogy with the parameters. If nothing is selected, I will see "nothing"

Thanks

miauu's picture

.

(
	try(destroyDialog ::Cam_P)catch()
-- 	Cam_P_iso_x = getinisetting "$plugcfg\\CamParam.ini" "Cam_P" "pos_x" as integer
-- 	Cam_P_iso_y = getinisetting "$plugcfg\\CamParam.ini" "Cam_P" "pos_y" as integer
	global miauuSelObjChangedNEC
	rollout Cam_P "Cam parameter" width:170
	(
		local camObj = undefined
		local camFilm_Width = 0
		local camFocal_length = 0
		local camFov = 0
		local camZoom_Factor = 0
 
		group"Options"
		(
			label lf_1 "Film gate" align:#left across:2
			spinner sf_1 fieldwidth:50 range:[0,999,camFilm_Width] type:#float scale:0.01 align:#right
			label lf_2 "Focal length" align:#left across:2
			spinner sf_2 fieldwidth:50 range:[0,999,camFocal_length] type:#float scale:0.01 align:#right
			label lf_3 "FOV" align:#left across:2
			spinner sf_3 range:[0,180,camFov] fieldwidth:50 type:#float scale:0.01 align:#right
			checkbox cf_1 "" width:25 height:25 align:#center offset:[0,-25]
			label lf_4 "Zoom factor" align:#left across:2 offset:[0,-5]
			spinner sf_4 fieldwidth:50 range:[0,999,camZoom_Factor] type:#float scale:0.01 align:#right offset:[0,-5]
		)
 
		function ResetData =
		(
			camFilm_Width = 0
			camFocal_length = 0
			camFov = 0
			camZoom_Factor = 0
 
			sf_1.value = camFilm_Width
			sf_2.value = camFocal_length
			sf_3.value = camFov
			sf_4.value = camZoom_Factor
		)
 
		function miauuSelObjChangedNEC_FN s e = 
		(
			if selection.count == 1 then
			(
				if superclassof selection[1] == camera then
				(
					camObj = selection[1]
					camFilm_Width = camObj.film_width_mm
					camFocal_length = camObj.focal_length_mm
					camFov = camObj.fov
					camZoom_Factor = camObj.zoom_factor
 
					sf_1.value = camFilm_Width
					sf_2.value = camFocal_length
					sf_3.value = camFov
					sf_4.value = camZoom_Factor
				)
				else
				(
					ResetData()
				)
			)
			else
			(
				ResetData()
			)
		)
 
		on Cam_P close do
		(
			setinisetting "$plugcfg\\CamParam.ini" "Cam_P" "pos_x" ((GetDialogPos Cam_P).x as string)
			setinisetting "$plugcfg\\CamParam.ini" "Cam_P" "pos_y" ((GetDialogPos Cam_P).y as string)
		)
 
		on sf_1 changed val do $.film_width = val
 
		on sf_2 changed val do $.focal_length = val
 
		on sf_3 changed val do $.fov = val
 
		on sf_4 changed val do $.zoom_factor = val
 
		on cf_1 changed true do
		(
			if true then $.specify_fov = on
			else
			(
				$.specify_fov = off
			)
		)
 
		on Cam_P open do
		(
			miauuSelObjChangedNEC = nodeEventCallback selectionChanged:miauuSelObjChangedNEC_FN
			if selection.count == 1 do
			(
				if superclassof selection[1] == camera do
				(
					camObj = selection[1]
					camFilm_Width = camObj.film_width_mm
					camFocal_length = camObj.focal_length_mm
					camFov = camObj.fov
					camZoom_Factor = camObj.zoom_factor
 
					sf_1.value = camFilm_Width
					sf_2.value = camFocal_length
					sf_3.value = camFov
					sf_4.value = camZoom_Factor
				)
			)
		)
 
		on Cam_P close do
		(
			miauuSelObjChangedNEC = undefined
			gc light:true
		)
	)
	createDialog Cam_P --pos:[Cam_P_iso_x,Cam_P_iso_y]
)
Igryl9l's picture

Thank you

Works great.
When I create a camera, the data is updated.
When I delete the camera, the data is not updated.
I tried to add an interface update when using the delete function - it did not work.

fn (...)=
(
if selection.count <1 then ResetData ()
else
(
if actionMan.executeAction 0 "40020" then ResetData ()
)
)

Or should it be written differently?

Thanks.

jahman's picture

.

you can use same callback function for added / deleted / selectionChanged events of NodeEventCallback system

Igryl9l's picture

Thanks

It helped. I managed to add these events to the function.
Thank you so much for your help.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.