sketchucation logo sketchucation
    • Login
    1. Home
    2. abakobo
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    A
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 8
    • Posts 22
    • Groups 1

    abakobo

    @abakobo

    10
    Reputation
    1
    Profile views
    22
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    abakobo Unfollow Follow
    registered-users

    Latest posts made by abakobo

    • RE: Solved: how to get the ruby version?

      Found it...

      it's the RUBY_VERSION const!

      cheers

      posted in Developers' Forum
      A
      abakobo
    • Solved: how to get the ruby version?

      Hi

      I've been trying "ruby -v" in console but doesn't work (on SU2013 at least)
      I can get the Sketchup version with Sketchup.version and .version_number but then I would have to know wich build use wich ruby...
      I remember I could get that info in SU ruby console one time but I can't find it by googling! I just find "ruby -v".

      thx

      ako

      posted in Developers' Forum
      A
      abakobo
    • RE: Saving all instance variables of an object

      Bug posted in the GitHub Issues field!

      posted in Developers' Forum
      A
      abakobo
    • RE: Saving all instance variables of an object

      I never did that but will learn how to.
      Glad to participate... πŸ˜„

      posted in Developers' Forum
      A
      abakobo
    • RE: Saving all instance variables of an object

      I'm trying to save all the .visible? .caption(for lbls) and .value(for inputs) for now.

      I would like to create a window where there's a "add item" on the window that add a SKUI_group on the window corresponding to the new item...
      My object have only two instance variables for now, the number of items(an int) and the SKUI window.

      For the non customisable plugin I could save the .visible? .caption and .value by listing them manualy in my Save method but with a customizable window it would probably be painful...

      thanks for your answers
      AND THANKS A LOT FOR SKUI (sorry for shouting but i really mean it)

      P.S. I noticed a little bug: I have to initialise myself the .visible of each visible unmodified SKUI items before saving them because it was returning nil with the .visible? method if .visible= was never used.

      posted in Developers' Forum
      A
      abakobo
    • Prevent quit without saving in webdialog window

      Hi

      Is it possible to prevent the closing of a Webdialog window (or even better with SKUI) in order to get the famous "File has not been saved: /cancel/save/quit anyway/" window.

      This while quiting the webdialog window and/or while quiting SU with that window still open.

      thanks

      ako

      posted in Developers' Forum
      A
      abakobo
    • RE: Saving all instance variables of an object

      I tried to save an object containing an SKUI window object (using marshal) and had a bad type error... I suppose it's not possible to save an SKUI window with marshal due to it's limitations:

      *Marshal can't dump following objects:

      anonymous Class/Module.
      
      objects which related to its system (ex: Dir, File::Stat, IO, File, Socket and so on)
      
      an instance of MatchData, Data, Method, UnboundMethod, Proc, Thread, ThreadGroup, Continuation
      
      objects which defines singleton methods*
      

      I did it manualy this time but wonder if there's something similar to Marshal with what I would be able to save objects containing SKUI windows for later use.

      I remeber i saw somthing with a name looking like "yalm"..
      Would Pstore do it?

      Many Thanks

      ako

      posted in Developers' Forum
      A
      abakobo
    • RE: Saving all instance variables of an object

      Hi

      I decided to use Marshal as I suppose I won't do better! 😜 (though it's version dependent and has some security issues)

      I found some code examples modified and ran it... cool stuff. But there are two things I don't understand in the code I copied!

      
      class MyObject 
      	
      	def initialize(value)  
      		@value = value 
      		@arr= [4,5,6]
      	end  
      	attr_accessor ;value, ;arr
      	
      	def incr
      		@value=@value+1
      	end
      	
      end  
      
      
      obj=MyObject.new(99)
      
      file_name=UI.savepanel("Save","",".oob")
      
      File.open(file_name, 'w+') do |f|
      	Marshal.dump(obj, f) 
      end
      
      
      File.open(file_name) do |f|  
      	@obj2 = Marshal.load(f)  
      end  
      
      obj3=@obj2.clone
      obj3.incr
      puts obj3.value,obj3.arr
      
      

      Why must I use @ or $ for my obj2?

      And why the code below doesn't close the file in comparaison to the one above. Is that the "block form" advised in Dan's post? I miss the mechanics of that "do ||" statement, I tought it was just a looping tool. ---> I read this now: http://blog.rubybestpractices.com/posts/gregory/009-beautiful-blocks.html

      
      f=File.open(file_name, 'w+')
      puts f
      Marshal.dump(obj, f)
      
      #need f.close!
      
      

      Thanks a lot for your answers!

      ako

      posted in Developers' Forum
      A
      abakobo
    • References not behaving the same with string vs My_object

      Hi

      I realised my own_objects and basic objects like strings are not referenced the same way!

      
      class MyObject 
      	attr_accessor ;value
      	def initialize(value)  
      		@value = value 
      	end
      end 
      
      obj1=MyObject.new('hip')
      obj2=obj1
      obj2.value='hop'
      puts obj1.value                     # ==> return 'hop'
      puts obj1.object_id,obj2.object_id  # ==> they have the same id! (pointer?)
      
      a='hip'
      b=a
      b='hop'
      puts a                             # ==> return 'hip'
      puts a.object_id,b.object_id       # ==> they have a different id! (reference?)
      
      

      How can i know the type of object I use will automaticaly clone when a copy is modified ?
      Can I force ruby to act the same with all objects (clone any copied object using = without the need to use the .clone method)?

      Thanks

      ako

      posted in Developers' Forum
      A
      abakobo
    • RE: Saving all instance variables of an object

      Thank you very much!

      This helped me a lot and I have ALL the infos I needed!

      ako

      posted in Developers' Forum
      A
      abakobo