sketchucation logo sketchucation
    • Login
    1. Home
    2. niccah
    3. Posts
    ⚠️ Attention | Having issues with Sketchucation Tools 5? Report Here
    N
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 18
    • Posts 90
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: UI::WebDialog => set_html => large HTML pages

      Thanks guys for the hints! I got a message from Noel!

      posted in Developers' Forum
      N
      niccah
    • RE: UI::WebDialog => set_html => large HTML pages

      @thomthom said:

      Btw, what are you creating?

      Oh, I started a big big project...

      On the one hand I love to play with my milling machine, on the other hand, I'm very interested to learn to write some Sketchup plugins.

      So my project:

      You can select some faces of your model, enter some dimensions of your milling tool and you get the right GCode. Now, I'm coding the userinterface of this plugin.

      I hope, I can publish first beta versions in the next fex month...

      posted in Developers' Forum
      N
      niccah
    • RE: UI::WebDialog => set_html => large HTML pages

      @thomthom said:

      If you're new to WebDialogs in SketchUp you want to have a look at this thread: http://sketchucation.com/forums/viewtopic.php?f=180&t=23445#p198883

      Oh, that was the perfect hint. You are right, I'm realy new to WebDialogs. So I read a lot the last few days and now, I know, my question was stupid 😄

      However, thanks for your endurance!

      posted in Developers' Forum
      N
      niccah
    • RE: UI::WebDialog => set_html => large HTML pages

      @thomthom said:

      It's not really clear to me what the "problem" is. Can you specify?

      Oh sorry... okay, let me explain the "problem" a little bit more in detail...

      I have a plugin for Sketchup and I need a formular, where I can set a lot of options. So, I'm using a WebDialog and the content is written in a string.

      • advantage: I can insert some ruby variables (for example: "<input type="text" value="" + rubyVariable + """
      • disadvantage: The Webdialog gets larger and larger, so the string gets larger and larger => the code gets unclear.

      Now, my question is: can I write all the html code in an external file? So, normal text file, I can import with "File.open...". But then, I can't use some ruby variables in the html code.

      So, for me (a more or less Ruby newby), it is not clear what's the best way to handle large WebDialogs.

      @thomthom said:

      By the way: set_html doesn't work under OSX after an Safari update.

      Oh, that's an important hint... how I can handle this problem? Thanks a lot, ThomThom for your help!

      posted in Developers' Forum
      N
      niccah
    • UI::WebDialog =&gt; set_html =&gt; large HTML pages

      Heyho!

      I have a simple question...

      I'm using the folowing code:

      html = "<html>..." + someVars + "...</html>" dlg = UI::WebDialog.new("...", true, "...", 600, 200, 50, 50, true); dlg.set_html html dlg.show

      Well, its no a perfect solution, when I use large html codes. So, what do you think, is the best way, to insert a large html page?
      It is possible to include a full html- file? But then, I guess, I can't use some ruby vars in the html code.

      What's your standard solution for that "problem"?

      Thanks for all your help!!

      Wish you a relaxed weekend...

      posted in Developers' Forum
      N
      niccah
    • RE: Add_edges with a LOT of edges

      I tried to scale this points at first...

      ` points << [(xOld.to_f10000).mm, (yOld.to_f10000).mm, (zOld.to_f*10000).mm]

      group = Sketchup.active_model.entities.add_group
      group.entities.add_edges points

      new_transform = Geom::Transformation.scaling 0.0001
      group.transformation = new_transform`

      And, oh my goodness, it works!

      Thanks TIG again for your hints!!!

      posted in Developers' Forum
      N
      niccah
    • RE: Add_edges with a LOT of edges

      Okay, I found a solution:

      Google Product Forums

      favicon

      (productforums.google.com)

      They said: I have to enlarge the model to 1000x... insert all the points and scale them back after that... What do you think?

      posted in Developers' Forum
      N
      niccah
    • RE: Add_edges with a LOT of edges

      @tig said:

      There is a known limitation of tiny edge/facet creation [~0.1mm ?] smaller lines will fail to form.

      Oh shit, you are right! That's exactly the problem... all missing lines are smaller than 0.1 mm. The problem is, I have to display these small edges, because I need this "smooth" curvature.

      Puh, is there a possibility to change this limitation of about 0.1 mm?

      Thanks TIG for your fast answer!!!

      posted in Developers' Forum
      N
      niccah
    • Add_edges with a LOT of edges

      Hey at all!

      I'm coding a plugin, which can import GCode from a textfile, means simple x / y / z coordinates.
      Now, I would like to display the path of the milling tool. So, I collected all points in an array and wrote

      
      points << [xOld.to_f.mm, yOld.to_f.mm, zOld.to_f.mm]
      
      entities = Sketchup.active_model.entities
      curve = entities.add_edges points
      

      The result is very strange...
      http://arbeitenkannstduspaeter.eu/SketchupProblem.png

      So, it seams, that a lot of edges are missing.

      When I use add_curve, it takes a looooong time to show the result and there are some other strange mistakes, but especialy in this region, the "path" of the milling tool looks good. So I don't think, it is a problem of my textfile.

      Do you have an idea, what happens here?

      Thank you very much for your help!

      posted in Developers' Forum
      N
      niccah
    • RE: Menus & Tools

      @dan rathbun said:

      @niccah said:

      Just a small question: Why you are writing " Sketchup.require"? Are there any differences to the "normal" require?

      FYI: The "normal" require (and load,) comes from module Kernel.

      Sketchup.require and Sketchup.load can call the internal decryption for rbs files, but the Kernel ones cannot.

      Okay, this sounds logic! Thanks for the information!

      posted in Developers' Forum
      N
      niccah
    • RE: Menus & Tools

      @thomthom said:

      @paulg said:

      Thanks for that,the require method includes code from the tool file into the menu file same as require sketchup.rb?

      require and load will both make the ruby interpreter load and execute the content of the file you specify. You must use this when you need to use another file. require if different from load in that it ensure the file is loaded only once. I recommend you read up on these methods as they are essential to Ruby.

      I had a similar problem: I could start a plugin in a folder just once. At a second click, nothing started. So, with your help, I could fix it! (I replaced "require" by "load").

      Just a small question: Why you are writing "Sketchup.require"? Are there any differences to the "normal" require?

      Thanks Thomthom for your helpful explanations!!

      posted in Developers' Forum
      N
      niccah
    • RE: Update a WebDialog

      Hey guys!

      I have to pick up this topic again!

      My problem: I have a WebDialog to create "Tools" - when a user created a new Tool, one has to update the webdialog.

      In my case, it looks like this:

      
      html = " .... "
      	dlg = UI;;WebDialog.new("Model2GCode - Tools", true, "Model2GCode - Tools", 800, 300, 50, 50, true);
      	dlg.set_html html
      	dlg.show
      	
      	dlg.add_action_callback("saveNewTool") {
      
      }
      
      

      Is there a possibility to close the WbDialog, "jump" to the start of the script and open it again? I tried a lot, but I didn't get a running solution.

      Thanks for all your help!

      posted in Developers' Forum
      N
      niccah
    • RE: Newbie question - execute jar file in ruby

      @dan rathbun said:

      Yes I tried it also, and got no output.
      I tried in in a command shell and got java errors.

      Sorry I cannot help you with java.

      Why use java when SketchUp uses Ruby ??

      I'm coding a plugin for Sketchup to get a GCode for a CNC milling maschine for a 3D Model. So, multithreading would be very nice to accelerate the calculating. The ruby version of Sketchup doesn't support something like that. So I try to use an external Java application for the main calculations.

      posted in Developers' Forum
      N
      niccah
    • RE: Newbie question - execute jar file in ruby

      Thanks Dan Rathbun!!

      By using your method - I get an empty output.

      
      output = nil
      output = `java -jar Model2GCode.jar #{ARGSTRING}`
      if not output
        if $? != nil || $? != 0
          puts("The error code returned was; #{$?.to_s}")
        else
          puts("No error code was returned.")
        end
      else
        UI.messagebox output
      end
      
      

      I see the UI.messagebox, but it is empty.
      My Java code is just a

      System.out.println("Hello world!");
      

      As I read in some forums, the "output" of the java application should be the "System.out.println"'s. So, I'm confused, why it doesn't work?!

      posted in Developers' Forum
      N
      niccah
    • RE: Newbie question - execute jar file in ruby

      You are the best!

      With the help of your tips I could solve the "Exec format error"! Thanks your very very much!

      The next problem: 😆

      I wrote two very easy jar files:

      1th version: just: System.out.println("Hello world!"); => but with the following code, I get a false.

      
      output = nil
      output = `java -jar Model2GCode.jar #{ARGSTRING}`
      result=$?.success?
      
      

      2nd version: Thread.sleep(10000); => I get a false too.

      When I start the jar file outside of sketchup, everything is fine.

      Do you have an idea, what can I do? I'm not sure, if it is an problem of Sketchup, Ruby or Java...

      Thanks you for all your help!

      posted in Developers' Forum
      N
      niccah
    • RE: Newbie question - execute jar file in ruby

      @tig said:

      As long as you are not passing any arguments to the jar file, then
      Dir.chdir('C:/some/path/to/the/correct/dir') UI.openURL('Model2GCode.jar')... UI.openURL('file:/'+path2jar')
      ...

      Unfortunately not - I want to send some information to the jar file. But UI.openURL() is a nice function too - I will keep it in my mind! Thank you!

      I have a further question:

      This java file can take serveral minutes to execute. So it would be nice, if I can get some signals from the java code to be sure, everything is okay.

      Does the following idea work?

      • after each step in the Java code, it should be send a short message to ruby
      • I can be sure, that every step of the java code should not be longer than 10 seconds
      • if I get no new messages after 10 seconds, I will cancle the ruby code

      If you think, it is an good idea to do this in such a way, than I don't know exactly, how I can "control" the messages of the Java code.

      If I write: output = Model2GCode.jar #{ARGSTRING}
      and the Java code send every seconds a message - gets the output "longer" and "longer"? Or will the Java code "overwrite" the "old" output?

      I hope, you know what I mean? It's hard for me to write what I am thinking 😄

      Thank you very much for your help!

      posted in Developers' Forum
      N
      niccah
    • RE: Newbie question - execute jar file in ruby

      @dan rathbun said:

      oldDir = Dir.getwd
      > Dir.chdir('C;/some/path/to/the/correct/dir')
      > output = nil
      > output = `Model2GCode.jar #{ARGSTRING}`
      > delay = 0.5
      > tid = UI.start_timer( delay, true ) {
      >   if output
      >     UI.stop_timer(tid)
      >     Dir.chdir(oldDir)
      >   end
      > }
      > 
      

      Oh thank you very much. Now, I just get an error like this: "Error: #<Errno::ENOEXEC: Exec format error - Model2GCode.jar", but I think that's a problem of my jar file!

      Thanks a lot for your help!

      posted in Developers' Forum
      N
      niccah
    • Newbie question - execute jar file in ruby

      Hey!

      I think it is a very basic question, but I can't solve it.

      I would like to execute a jar file in Sketchups ruby.

      My serveral experiments:

      output = Model2GCode #{ARGSTRING} => no such file found
      output = Model2GCode.jar #{ARGSTRING} => no such file found
      output = Model2GCode -jar #{ARGSTRING} => no such file found

      I think I have to give them the right folder. (the jar file is in the same folder as the rb file).

      Do you have any ideas?

      Thank you very much for your help!

      posted in Developers' Forum
      N
      niccah
    • RE: Multithreading - Queue?!

      @thomthom said:

      Do you have a snippet of multi-threaded SketchUp Ruby code? I'd be very interested! 😲

      hehe, okay, here it is....

      @unknownuser said:

      facesCount = FACE.length # wieviel Flächen habe ich?
      $facesPerThread = facesCount.divmod($opt.cpuCores.to_i) # Wieviel Flächen bekommt jede CPU?

      thread = Array.new
      $j = 0
      $opt.cpuCores.to_i.times do |i|

        $k = ($j-1) + $facesPerThread[0]
      
        # Der Rest der Flächen wird noch auf die einzelnen CPUs aufgeteilt
        if $facesPerThread[1] > 0
        	$k += 1
        	$facesPerThread[1] -= 1
        end
        
        		#UI.messagebox $k
      
        thread[i] = Thread.new do
        	for l in  $j..$k do
        		#UI.messagebox FACE[l]
        		out = FACE[l].isInCylinder
        		break if out
        	end
        	
        	out
        end
        
        # Startpunkt für den nächsten Thread
        $j = $k + 1
      

      end

      thread.each do |tmp|
      tmp.join
      end

      I tested it with some simple models and I saved some single seconds.... not too much, but faster then without any threads....

      I'm very interested to hear what do you think about it...

      posted in Developers' Forum
      N
      niccah
    • RE: Multithreading - Queue?!

      @thomthom said:

      Muliti-threading in SketchUp Ruby is a no-go. 😞 There's a few topics here on the forum about threading - and all just ends in misery...

      hm, okay, strange... in my case it works very fine. I just though to push the performance a little bit more.

      Oh okay, I didn't know, that Sketchup uses a "old" version of Ruby ...

      Thanks for your help!!

      posted in Developers' Forum
      N
      niccah
    • 1 / 1