Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2009
    Posts
    71
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Loopy problem - variable ignoring block

    Code:
    def Skel_poser.run_frames(time,lframe)	
    		keyframes = {}
    		model = Sketchup.active_model
    		d = model.attribute_dictionaries['kframes']
    		d.each_pair do | key,value |
    			a =  1
    			value.each do| v |
    				if v.nil?
    					v = [[1,0,0],0]
    				end
    				v << time * a
    				a += 1
    			end
    			keyframes[key] = value
    		end
    		return keyframes
    	end
    This code runs fine if there are no empty elements in the value array. If there are puts v shows the change from nil to the new array but value shows the original nil.

    What have I done wrongly ... please!
    Last edited by chrisglasier; 01-27-2011 at 04:27 AM. Reason: Resolved

  • #2
    New Coder
    Join Date
    Dec 2009
    Posts
    71
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Solved

    Code:
    def Skel_poser.run_frames(time,lframe)	
    		keyframes = {}
    		model = Sketchup.active_model
    		d = model.attribute_dictionaries['kframes']
    		d.each_pair do | key,value |
    			a =  1
    			new_value = []
    			value.each do| v |
    				if !v
    					v = [[1,0,0],0]
    				end
    				v << time * a
    				a += 1
    				new_value << v
    			end
    			keyframes[key] = new_value
    		end
    		#p keyframes
    		return keyframes
    	end


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •