Notifications
Clear all

[Closed] Trouble with event handler execute string

Hi. I am having trouble with the button event handler part of this code. It yields either a “expected while’ or ‘expected factor’, or it throws a ’ no get function for undefined’, no matter what combination I use of string, do loop, etc… Any help would be much appreciated,

 
ctrlcentre = circle radius:5
rotate ctrlcentre (angleaxis -91 [1,0,0])
 
morphs_used =#("up","down","turnaround")
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 += " )
"
attStr += "rollout Weights \"Weights\" 
"
attStr += "("
attStr += " local range=[-2.00,2.00,1.00]
"
attStr += "group \"Upper Left Position\" (
"
 
for j = 1 to morphs_used.count do (
 
attStr += " slider "+ morphs_used[j] + "Sl \""+ morphs_used[j] + "\" range:range ; 
" 
 
	)
attStr += ")
"
attStr += "group \"Upper Right Position\" (
"
 
 
 
attStr += "button resetAll \"Reset All\"	
"
 
attStr += "on resetAll pressed " do ( for k = 1 to morphs_used.count do ( 
 
 
attStr+="	ctrlcentre.modifiers[#Attribute_Holder].custAttributes[1][k].value = 1.0
" ; 
 
)
)
		 attStr += " )
"
	 attStr += " )"
 
attdeff = execute attStr
 
custAttributes.add ctrlcentre.modifiers[1] attdeff
	
6 Replies

one bug is here for sure:


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

AH…do you have any idea how it should go Denis?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

yes, i do… but this is your code, your idea, your challenge… and i don’t want to rob you

Yes, please rob me…I’m ready to be robbed of my challenge. Ive already been robbed of time trying to figure the thing out…

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

delete objects
ctrlcentre = circle radius:5
morphs_used =#("up","down","turnaround")
attStr = ""
addmodifier ctrlcentre (EmptyModifier ())
(
	attStr += "attdef = attributes facialctrl
"
	attStr += "(
"
	attStr += "	parameters facialctrl rollout:Weights
"
	attStr += "	(
"
	 
	for k = 1 to morphs_used.count do 
	( 
		attStr += "		" + morphs_used[k] + " type:#float ui:" + morphs_used[k] as string + "Sl
"
	)
	 
	attStr += "	)
"
	attStr += "	rollout Weights \"Weights\"
"
	attStr += "	(
"
	attStr += "		local range = [-2,2,1]
"
	attStr += "		group \"Upper Left Position\"
"
	attStr += "		(
"
	 
	for k = 1 to morphs_used.count do 
	(
		attStr += " 			slider " + morphs_used[k] + "Sl \""+ morphs_used[k] + "\" range:range
" 
	)
	
	attStr += "		)
"
	attStr += "		group \"Upper Right Position\"
"
	attStr += "		(
"
	attStr += "		)
"
	attStr += "		button resetAll \"Reset All\"	
"
	attStr += "		on resetAll pressed do
"
	attStr += "		(
"
	
	for k = 1 to morphs_used.count do 
	( 
		attStr+="			" + morphs_used[k] + " = 1
"
	) 
	
	attStr += "		)
"
	
	attStr += "	)
"
	attStr += ")"
	ok
)
 
format "%
" attStr

attdeff = execute attStr
custAttributes.add ctrlcentre.modifiers[1] attdeff

next time at least format your code for easy reading…

Thank you Denis…! You have my vote for forum attendee of he year