sketchucation logo sketchucation
    • Login
    1. Home
    2. kdasilva
    3. Posts
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🔌 Smart Spline | Fluid way to handle splines for furniture design and complex structures. Download
    K
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 10
    • Posts 30
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: [solved!!]onMouseMove show component instance

      @tig said:

      Use @ variables so they pass across methods.
      Add the component-definition's instance at the ORIGIN [ instance=entities.add_instance(definition, Geom::Transformation.new)].
      In the Tool's onMouseMove() method set a point to the cursor's input_point.position, set a transformation to that point and instance.transform!(transformation).
      In the Tool's onLeftButtonDown() method set the point to the current cursor's input_point.position, set a transformation to that point and instance.transform!(transformation),
      Stop the onMouseMove() code using a @state variable and 'case' tests...

      Thanks TIG, I admit I'm not 100% sure how to implement what you said. From what I gathered I got this:

      
      def onMouseMove flags, x, y, view
        if @clicked == false
          @pt1.pick view, x, y
          newpt = Geom;;Transformation.new( @pt1.position )
          @insert_tree_1.transform!( newpt )
        end
      end
      	
      def onLButtonDown flags, x, y, view
        @pt1.pick view, x, y
        newpt = Geom;;Transformation.new( @pt1.position )
        @insert_tree_1.transform!( newpt )
        @clicked = true
        reset	
      
      

      I start the the instance at the origin like you said (i assume that because the transformation.new moves from the origin if only a point is given?)
      but when I move my mouse the tree is waaay back in the distance, not where my mouse is. Is this an issue with the pick?

      thanks for the help~

      korbin

      posted in Developers' Forum
      K
      kdasilva
    • [solved!!]onMouseMove show component instance

      Hello, perhaps this next question is hoping for too much, but I was wondering if I can have it so the model instance follows the mouse around before it is placed down.

      i.e. just like when you add a model from Google 3D warehouse

      I am inserting prepackaged component definitions that the user is asked to place over the map (ie trees onto the basemap) and I am using a tool which takes the insert location from a click, however the model will only appear after the click is made. I just want it to follow around the mouse first so the user can get a sense of the scale.

      is this possible? From what I have found I am leaning towards no....but I figured I would throw the question out here before I wrote it off.

      Cheers
      -korbin

      posted in Developers' Forum
      K
      kdasilva
    • RE: [solved] taking points at intervals from a line

      Wow, thanks for all the help, and that fixed it up no problem.

      Dan - I also got rid of all of the global variables...in some cases I used class variables I hope thats not bad coding...changes to a variable in one method needed to be consistent in other methods for some parts in the tool

      (your all definitely getting a thank you foot note in my thesis!)

      Cheers,
      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • RE: [solved] taking points at intervals from a line

      @dan rathbun said:

      @kdasilva said:

      how can I get 10 Point3d's evenly spread out along this line that I can use as anchors for my text....

      Divide the line by 9

      <span class="syntaxdefault">arr</span><span class="syntaxkeyword">=[]<br /></span><span class="syntaxcomment"># load array with the txt values in order<br /></span><span class="syntaxdefault">pt  </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> edge</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position<br />vec </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> edge</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">line<br />num </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> dict</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">size</span><span class="syntaxkeyword">-</span><span class="syntaxdefault">1<br />seg </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> vec</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length </span><span class="syntaxkeyword">/</span><span class="syntaxdefault"> num<br />vec</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> seg<br />arr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each_with_index </span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">i</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault">  pt</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">offset</span><span class="syntaxkeyword">!(</span><span class="syntaxdefault">vec</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> if i</span><span class="syntaxkeyword">></span><span class="syntaxdefault">0<br />  entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_text</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> arr</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">i</span><span class="syntaxkeyword">],</span><span class="syntaxdefault"> pt </span><span class="syntaxkeyword">)<br />}</span><span class="syntaxdefault"> </span>
      

      I am trying my hardest to get this to work, unfortunately I have been unsuccessful thus far.....i put in:

      def draw_vision_field
        vision_field = ["test1", "test2", "test3", "test4", "test5"]
        pt = $line.start.position
        puts pt
        vec = $line.line
        puts vec
        num = vision_field.size - 1
        puts num
        seg = vec.length / num
        puts seg
        vec.length = seg
        vision_field.each_with_index {|e,i|
          pt.offset!(vec) if i > 0
          $ents.add_text( vision_field[i], pt )
        } 
      end
      

      I just put a test array to print for now. I added the puts in order to try and debug, I am getting this error message regarding the length= function on a vector...also the last number before the word error (the vec.length /num ), weirdly enough is always 0, i removed the /num and it always prints as 2, no matter how long the line is i make)

      
      (-350507.397831", 21906.712364", 0")
      (-350507.397831", 21906.712364", 0")
      (0.131501105216966, 0.991316023943281, 0.0)
      4
      0
      Error; #<NoMethodError; undefined method `length=' for [Point3d(-350507, 21906.7, 0), Vector3d(0.131501, 0.991316, 0)];Array>
      (eval);70;in `draw_vision_field'
      (eval);55;in `draw_the_line'
      (eval);28;in `onLButtonDown'
      (eval);73
      

      also... where does the method each_with_index come from? I can't find it in the sketchup api, and I could only find each_index in the ruby-doc http://www.ruby-doc.org/core/classes/Array.html#M000232

      thanks for the help

      korbin

      posted in Developers' Forum
      K
      kdasilva
    • [solved] taking points at intervals from a line

      Hello, I am trying to get my head around how I can collect 3DPoints from a edge my users enter for a tool

      essentially, the user draws a line on that line I want to display text at equal intervals along it. The text is not constant, it is taken from an attribute dictionary.

      What I am hung up on is splitting my edge. I am trying to use the .split method based on a fraction created by the number of attributes in the dictionary, however my math is failing me in the sense that once I do the first split, I cant seen to get another split evenly placed down the line. Is there an easier way to do this?

      For example:

      lets say the user creates a line from [0,0,0] to [100,100,0] and there are 10 attributes

      how can I get 10 Point3d's evenly spread out along this line that I can use as anchors for my text....

      Any help would be greatly appreciated!

      Cheers
      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • RE: Execute_script trouble

      @tig said:

      Try making
      js_update_command = "UpDateVisionList("+ updated_visions_div +")"
      as
      js_update_command = "UpDateVisionList(\""+updated_visions_div+"\")"

      awesome! that totally worked, and i know i wouldn't of thought to do that myself.

      So do those escapes keep the quotations around the word so JS knows its a string and not some undeclared variable?

      Thanks a ton TIG

      (It worked without adding the ;, but thanks for the response)

      posted in Developers' Forum
      K
      kdasilva
    • Execute_script trouble

      Hello, I am starting to get the hang of the webdialogs when being used to makes changes in Sketchup, however I have hit a snag while attempting to use the execute_script.

      How do I format the information I am trying to pass to JS through the a functions parameters. In my simple test of just trying to pass a string in the parameters and having it printed in the HTML file i keep getting an error message stating: 'test' is undefined, sounds to me like its not taking its value as a string...or I'm not formating it right..or defining it? (from what i have looked at I haven't seen a need to define it)

      Ruby (this is inside an action_callback that works fine)

      
          updated_visions_div = "test"
          js_update_command = "UpDateVisionList("+ updated_visions_div +")"
          web_dialog.execute_script(js_update_command)
      
      

      JavaScript

      
      function UpDateVisionList(incoming)
       {
       	document.getElementById("field_of_visions").innerHTML = incoming;
       }
      
      

      Once I hit the button that triggers the command a scripting error in the webdialog appears telling me "test" is undefined

      I have played with a few different ways, but from what I have read I don't see why this is not working. Most likely I am missing something obvious! 9 time out of 10 thats the case anyways. Could someone please educate me on whats up?

      Cheers~
      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • RE: Webdialog Question on .show

      Thanks Karen,

      I understand what your saying, however I am a bit more curious on how does the webdialog deal with multiple HTML files, I am building a series of functions in a .js file that connects to a number of HTML files and each HTML file will will send and receive data to Sketchup. Can one webdialog object send and receive these commands to the correct page seeing how it seems to keep track of which page one is on? Or will things start to get a bit hairy

      Cheers
      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • Webdialog Question on .show

      Hello, I was doing some testing with web dialogs and i came across something I was curious about.

      I opened a new WebDialog of a simple html saved locally, within that HTML I had a hyperlink to another HTML file in the same directory, they link worked fine so I closed it down. However when I told the ruby console to show the webdialog again it was still on the second HTML page.

      How does the webdialog know to open the second HTML file? It would seem it is storing its previous location somewhere, can anyone tell me where/how this works?

      Cheers,
      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • Few Quick Question for Tool

      Hello, this is obviously my first post, I hope I am in the right forumn....because I hesitate to call myself a developer, but I am building a tool.

      Context: For my Honours thesis I am building a plugin for sketchup that walks community members through a urban design methodology. I would be happy to give more information if anyone is interested.

      my background comes from GeoWeb programming, so I'm no pro at Ruby, Although I did just read through all of "Automatic Sketchup, Creating 3-D Models in ruby" (huge props to Matthew Scarpino for writing it).

      I just had a few questions I to clear up right now, but I will not doubt be back with more:

      1. I am debating on how to best approach my GUI, as it is a key part of my tool. It will need to have a lot of descriptions/text as well as collect deal with a lot of input from the users. Is the UI class enough to handle this....should I move to the more robust Web Dialog? Currently I am leaning towards web dialogs.

      2. Sorry if this one is a stupid question but: 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. 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? perhaps some sort of empty entity I dump information into.

      3. is there a reason they added:

      Added in SketchUp 8.0+:
      addBuilding:
      getPhotoTexture:
      selectImageIglooTool:
      selectNorthTool:

      to the send_action method but didn't include the new "add_location" tool button? I was hoping to bring this up for the users so they wouldn't have to search down the button.

      Thanks all for now~

      Cheers

      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • 1 / 1