[Plugin][WIP] Layers Panel - Dev
-
Correct. Make a method under your own namespace that takes the layer as an argument.
Not as pretty, but it'll work and it will be safe from clashing with anything else.
-
Ok, here is a new version.
- Added Toolbar and menu item (Window > Layers Panel), with toggle
- Change things you TT told me : Undo, +operator, filename...
- Deleting layers now work properly. The method is wrapped in my namespace. When a layer has geometry, you are promped to choose to delete the content or move it to the default layer.
- Added a menu for some options. For now you can only purge layers.
- I also don't have bugsplats anymore. Don't know why exactly... If people get some, please tell me.
Still no saving, I'm getting used to ruby before attacking this big piece.
Also, I can't get my WebDialog callbacks to work if the dialog is not in a global variable. I tried local, instance, and class variables, nothing works. What am I doing wrong ?
-
Hmm, so a class variable in a class ? That makes sense ^^
Thanks for the tip, I'll try that. -
I hope that naming the Class "TEST" didn't confuse you since the class name doesn't have anything to do with the variables (var test = true) in html.
I guess what i am trying to say is that the "var test" in html has nothing to do with "Class TEST" in ruby.
Not sure if you are confusing them both but just in case.
Note: Will edit the name of the class on my last post to "PLUG".
-
Hi,
@jiminy-billy-bob said:
Also, I can't get my WebDialog callbacks to work if the dialog is not in a global variable. I tried local, instance, and class variables, nothing works. What am I doing wrong ?
If you want to change something from ruby to web-dialog you can do this...
In Html & Javascript:
<html> <head> <title>Example</title> </head> <body onLoad="startup(), stopwatch(this.value);"> </body> </html> <script> var delay = 1000/5 ; #this will update 5 frames per second var timerID = false ; var test = true ; #this is the value you will change from ruby function startup() { nextFrame(); } function stopwatch() { SD=window.setTimeout("stopwatch();", 100); } function nextFrame() { try { test = test setFrame() ; top.timerID = self.setTimeout("nextFrame()", delay) ; } //try catch (e) { alert("push_frame; " + e) ; } } //nextFrame() function setFrame() { url = 'skp;push_frame@' ; url += '&test=' + test; window.location.href = url ; } </script>
In Ruby:
module SU_PLUG class PLUG @@model = Sketchup.active_model ; @@dir = File.dirname(__FILE__) # this plugin's folder @@path = File.join(@@dir, '/Folder/') @@dlg = "test.html" ; @@test_dlg = nil ; def initialize() @test_1_file = File.join(@@path, @@dlg) if @@test_dlg == nil @@test_dlg = UI;;WebDialog.new("Test", false, "Test", 300, 600, 70, 95, true) ; @@test_dlg.add_action_callback("push_frame") do |d,p| push_frame(d,p) end end @@test_dlg.set_size(300, 600) ; @@test_dlg.set_file(@test_1_file) ; @@test_dlg.show() ; end #def def push_frame(dialog,data) params = query_to_hash(data) ; # parse state information if params['test'].to_s == "true" #Example of a condition. change = false script = "top.test= " + change.to_s + ";" #this sets test=true to test=false dialog.execute_script(script); #this execute it end end #def def unescape(string) if string != nil string = string.gsub(/\+/, ' ').gsub(/((?;%[0-9a-fA-F]{2})+)/n) do [$1.delete('%')].pack('H*') end end return string end #def def query_to_hash(query) param_pairs = query.split('&') param_hash = {} for param in param_pairs name, value = param.split('=') name = unescape(name) value = unescape(value) param_hash[name] = value end return param_hash end #def end #class end #module
Hope this helps and again very good plugin!
-
Ruby uses 2 space indentation. HTML & Javascript 4 space indentation.
NOTHING uses 3 or odd number spaced indents ! -
@jiminy-billy-bob said:
Also, I can't get my WebDialog callbacks to work if the dialog is not in a global variable. I tried local, instance, and class variables, nothing works. What am I doing wrong ?
See this other post: Re: Webdialog scripting issues
Use
local
vars INSIDE methods as temporary variables. They get garbage collected when the method ends.Use
@@vars
INSIDE modules or for class-wide access.Use
@vars
in class instance methods (define and init them inside theinitialize
method.) -
Thanks a lot, I'll try that.
-
@dan rathbun said:
Ruby uses 2 space indentation. HTML & Javascript 4 space indentation.
NOTHING uses 3 or odd number spaced indents !Only Python require a certain indentation - Ruby, HTML and JS doesn't care. It's just coding convention within the team/project you're working with.
-
Please, don't ever give up on this plugin, it'd save my life! I wish I could help
-
I won't give up ! I just don't have time curently. I will at the end of july.
No worries -
just posting so I'll get updates on this thread.
-
I made another thread to discuss the behaviour of the plugin : http://sketchucation.com/forums/viewtopic.php?f=323&t=52225
Feel free to participate
-
Thanks for your present!This is a great plugin, but I have a problem,I created a layer group,which contains a number of layers,but when I restart the plugin Panel,everything was back to the way they were,the group disappeared, the new layer still exist。
-
Yep, it doesn't save anything yet ^^
See the first post :@jiminy-billy-bob said:
ToDo :
- **Saving ! For now, every time you refresh the webdialog, or exit SU, the sorting/nesting disappears.**So it's useless as is.
It will come. Just not now
It's obviously at the top of my todo list. -
hi
I just wondered if you had ever seen this, it has some nice ideas, to take forward
http://sketchucation.com/forums/viewtopic.php?p=162487#p162487
I did some work on the mac version, but Chris and Jim had already done the tricky bits...
john
-
Hey guys !
I finally got a working version (See first post for download). It saves sorting/nesting (Except group hiding/collapsing)
I still wouldn't recommand using it in production though, as it may produce bugsplats, and it still behave strangely with the undo stack.There are still a lot of bugs, so I need you guys to help me track them and getting methods to reproduce them.
I updated the first post with what's working and what's not.I don't think it works on mac, though I'm not able to test...
For now, I tested only on win7 SU2013 IE8-10, with no bugsplats so far.Feedback (about bugs or features) would be highly appriciated !
Thanks
-
Once I hide a Layer I can't unhide it unless I nest it in a Layer Group
Win8
Great tool
-
woooot wooot!
-
@rich o brien said:
Once I hide a Layer I can't unhide it unless I nest it in a Layer Group
Win8
Great tool
Weird, it works for me on win8 with SU2013 and IE10.
Which versions of SU and IE are you using ?
Advertisement