Notifications
Clear all

[Closed] string function problem

Hi. Wrote this code as a custom attribute to be executed as a str but the reset button doesn’t work even tho it is placed on the ca, because as it doesn’t recognize ‘morphs_used’ (undefined), even tho the code places the sliders on the custom attribute as expected and morph used is of global scope.


 
 
fn  placeParameters  ctrlsplines =
(
 --ctrl = $
 ctrlcentre = getnodebyname ctrlsplines
 
 --morphs_used = #("lLwrLipUp")
  if ctrlcentre.modifiers[1] != undefined then 
   
  ( deleteModifier ctrlcentre  1)
 
 addmodifier ctrlcentre (EmptyModifier ())
   attdeff = ""
 attStr = ""
	attStr += "attdef = attributes facialctrl
"
	attStr += "(
"
 attStr += " parameters facialctrl rollout:Weights 
"
 attStr += " (
"
 for i = 1 to morphs_used.count do 
 ( 
 attStr += " " + morphs_used[i] + " type:#float ui: "+ morphs_used[i] as string+"Sl 
"
  --attStr += " " + morphs_used[i] + " type:#float ui: "+ morphs_used[i] as string+"Sp 
"
 )
 attStr += " )
"
 attStr += "rollout Weights \"Weights\"   
"
 attStr  += "("
 attStr  += " local range=[-2.00,2.00,1.00]
"
 attStr  += "group \"Upper Left Position\"  (
"
 
 for j = 1 to TUpl.count do (
	  
 attStr += " slider  "+ Tupl[j] + "Sl \""+ TUpl[j] + "\" range:range ;   
" 
						   
	)
 attStr += ")
"
 attStr += "group \"Upper Right Position\"  (
"
	
 for j = 1 to TUpr.count do (
	 attStr += " slider  "+ Tupr[j] + "Sl \""+ TUpr[j] + "\" range:range ;   
"
 )  
 attStr += ")
" 
 attStr += "group \"Lower Left Position\"  (
"
	
 for j = 1 to TLwl.count do (
	 attStr += " slider  "+ TLwl[j] + "Sl \""+ TLwl[j] + "\" range:range ;   
"
 )  
 attStr += ")
" 
 attStr += "group \"Lower Right Position\"  (
"
	
 for j = 1 to TLwr.count do (
	 attStr += " slider  "+ TLwr[j] + "Sl \""+ TLwr[j] + "\" range:range ;   
"
 )  
 attStr += ")
" 
 
 
 
 attStr += "button resetAll \"Reset All\"	
"
 attStr += " on resetAll pressed do ( for k = 1 to morphs_used.count do ( $.modifiers[#Attribute_Holder].custAttributes[1][k].value = 1.0 ;   )   )
"
		attStr += " )
"
	 attStr += " )"
	   
  attdeff = execute attStr
 
 custAttributes.add ctrlcentre.modifiers[1] attdeff
	
  
	 
 
)
1 Reply
 lo1

in the code generating the sliders you are using:

attStr += " " + morphs_used[i] + " type:#float ui: "+ morphs_used[i] as string+"Sl 
"

while on the reset button you are using:

" on resetAll pressed do ( for k = 1 to morphs_used.count do (

notice the difference?