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

    Topics

    • K

      Quick theoretical question

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      12
      0 Votes
      12 Posts
      387 Views
      M
      Super helpful, as always. Thanks.
    • K

      Attribute dictionary in callback

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      8
      0 Votes
      8 Posts
      328 Views
      TIGT
      @kdasilva said: I appreciate all your help, but I am still unsure on why my get get_attribute method would return nil in a different call back? is there a scope issue I am not accounting for? the get_attribute works within the same callback so I am lead to believe that the instance name is working as a key... Did you check that the 'key' was acceptable ? You were setting the attribute for the model etc ? Rather that try an do it directly in the call_back make a method and run it with self.callback1() etc... What you are trying to do is relatively straightforward ... just break it into logical steps......
    • K

      .execute_script interesting quirk

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      7
      0 Votes
      7 Posts
      263 Views
      thomthomT
      @dan rathbun said: I think there is a whole topic on this concerning "Javascript:void(0);" vs "Javascript:return;" one of which needs to be in the HREF tag, the Ruby callback needs to be in the onClick call. To avoid triggering an A HREF link, and instead execute some other JS code, you return false to the onclick event.
    • K

      Transformation Troubles

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      6
      0 Votes
      6 Posts
      305 Views
      Dan RathbunD
      @kdasilva said: From what I read I am guessing this has something to do with the transformation matrix ...but I can't seem to figure out how to navigate it. Martin Rinehart wrote a Tutorial that has a lesson on transformations and an explanation of the Matrix. See this post for links: http://forums.sketchucation.com/viewtopic.php?f=180&t=27182#p235251 ( ...follow the white rabbit. )
    • K

      [solved] Scale to length

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      5
      0 Votes
      5 Posts
      225 Views
      K
      Ah i see the to_f worked perfectly, for some reason I was trying to convert it into feet with decimal places last night, not sure why....my brain was not quite as sharp after about 15 hours of coding/writing last night~ cheers Korbin
    • K

      [solved!!]onMouseMove show component instance

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      32
      0 Votes
      32 Posts
      4k Views
      K
      Still trying to figure it out. Tested it by putting the code directly into the Ruby Console and putting it into a rb-file. Try with a freshly started Sketchup 2014 and delete 'Sophie' (but leave her in the component definitions). First I executed in the Ruby Console: @model = Sketchup.active_model @ents = @model.entities @defs = @model.definitions inst = @defs["Sophie"] @model.place_component inst,false Place her anywhere but not on the origin 0,0,0 Second run this: @ents.each {|e| next unless e.is_a?(Sketchup;;ComponentInstance) puts e.transformation.origin } You get the proper coordinates of Sophie. Now I delete all Sophies but leave her in the component definitions. I wrap the above code into a plugin. I need to add an observer so the code can pick it up again (place_component breaks the code). I load it and start it with: MB_place_instance.activate The first placed instance always returns 0,0,0 as the origin. Add another one (activate again) and it returns the origin of the first added instance etc... Looks like its returning the definition and not the placed instance. There must be some logic in it but I fail to see it... require 'sketchup.rb' module MB_place_instance class MyDefObserver < Sketchup;;DefinitionObserver ### create an observer (place_component breaks the code and returns to SU) ### def onComponentInstanceAdded(definition, instance) puts "observer has fired; " + instance.to_s MB_place_instance.refire(instance) # go back to the tool end end def self.activate @model = Sketchup.active_model @ents = @model.entities @defs = @model.definitions inst = @defs["Sophie"] @observer = MyDefObserver.new @model.definitions[0].add_observer(@observer) @model.place_component inst,false end #def def self.refire(instance) @defs[0].remove_observer(@observer) # delete the observer @observer = nil # delete the observer in case previous method fails GC.start # collect garbage @ents.each {|e| next unless e.is_a?(Sketchup;;ComponentInstance) puts "looking with each; #{e.transformation.origin}" } puts "directly adressing passed instance; #{instance.transformation.origin}" end #def end #module ### start in RubyConsole with; MB_place_instance.activate
    • K

      [solved] taking points at intervals from a line

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      16
      0 Votes
      16 Posts
      878 Views
      K
      Ah, thanks for all the tips, guys! The line[1] vector will be useful, as long you are after the forward edge direction. I tried to use it yesterday, but couldn't because the polyline direction did matter in my case. And the second argument in .offset(). I didn't realize there was a second argument and was scaling my vector, instead. Actually, I only recently realized you could scale a vector by vector.length= and had been doing it a harder way, before. -Kwok
    • K

      Execute_script trouble

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      6
      0 Votes
      6 Posts
      244 Views
      thomthomT
      @kdasilva said: So do those escapes keep the quotations around the word so JS knows its a string and not some undeclared variable? Yes. The string you send to execute_script is processed by JS eval() in the webdialog. So remember that all strings you send to execute_script is processed and evaluated twice, once in Ruby and once in JS. Though, the code will be easier to re4ad and understand if you avoid escaping quotes. js_update_command = "UpDateVisionList('#{updated_visions_div}')"
    • K

      Webdialog Question on .show

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      5
      0 Votes
      5 Posts
      658 Views
      Dan RathbunD
      Make sure to read WebDialogs - The Lost Manual (by ThomThom) The webdialog is an instance of your custom WebDialog class. When you .close() the window, the instance object still exists, and when you .show() it your only opening up the window again. On PC you can use the block argument to do something in the javascript. (It is bugged on the Mac.) <span class="syntaxdefault">webwin</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">show </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">  webwin</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">execute_script</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"window.location='startpage.html';"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> <br /></span><span class="syntaxkeyword">}</span><span class="syntaxdefault"> </span>
    • K

      Few Quick Question for Tool

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      233 Views
      Dan RathbunD
      @kdasilva said: 2) ... How would you recommend saving the variables that keep track of the various inputs my users put in if they want to re-open Sketchup. If the variables are specific to a certain model.. then attributes attached to the model. If they are general to a plugin and will be used with more than one model, then look at Sketchup.read_default and Sketchup.write_default methods. (It's best to convert all data to strings that will be written into the Windows Registry.) Or you can use a Settings Hash convert it to a string with .inspect() and write it out to a file. An easy way is to use Marshal.dump() and Marshal.load() (but there are versioning issues.) It's not that hard to open a File object and use it's write() or puts() method to send the string to the file. That way you won't have marshaling version isssues, and as you need to open the file IO object in both cases, it's not much difference, either way. @kdasilva said: I can store variable information with attributes for entities...but if i wanted to say have arrays that hold different community visions for the model, I don't think I can assign attributes to the model can I? Any Entity subclass inherits the attribute methods. And also they are defined for Sketchup::Model class. So for instance you can attach attributes to a Layer or a (Scene) Page because they are Entity subclasses (not just to the Drawingelement subclasses.)
    • 1 / 1