🔌 Smart Spline | Fluid way to handle splines for furniture design and complex structures. Download
  • Reading and drawing textures

    22
    0 評價
    22 貼文
    1k 瀏覽
    Dan RathbunD
    @dan rathbun said: The HTML5 Canvas element will not work well on PC yet because SketchUp uses the MSIE WebBrowser control for WebDialogs. Microsoft is lagging behind in their IE support of the specification. You can test by loading the HTML5 Bejeweled game into a WebDialog. It most likely will not run under XP. But runs fine under Win7 with MSIE v11 installed. Bejeweled.rb
  • GitHub as a Content Library Manager?

    6
    0 評價
    6 貼文
    414 瀏覽
    M
    @adamb said: It sounds what you need is an Asset Management System... I'll have to do some more investigation. I knew GitHub probably wouldn't have been quite right, and I appreciate the feedback. On to do more research. I might just use a private collection (or several) on 3DWH like was suggested earlier until I figure something out.
  • Group moves to origin when I doubleclick to select component

    20
    0 評價
    20 貼文
    1k 瀏覽
    Dan RathbunD
    @tt_su said: But you cannot return a single world position for a vertex unless you have some extra info. RIGHT.. I gotcha' We would need to let Ruby know the parent instance's transform. (Not automatic unless in user edit mode.) I guess we can do this now. We just create a copy of the instance's transformation, call it **t**: world_pt = edge.start.position.transform(t) I guess I was pondering how to automatically call #transform(t) upon all newly created Geom::Point3d instances, within a code block scope. So, yes I suppose an optional "tranform" class argument for Vertex#position would be handy. (It could be a Geom::Transformation instance, a Geom::Vector3d in world context, OR either an Array or Geom::Point3d offset from ORIGIN.) So it could look like: world_pt = edge.start.position(t) (2) So lets say you have collected a series of vertices (in an array verts.) And you want their world co-ordinates: world_pts = verts.map {|v| v.postion(t) } We have to use map, because the API's Array#tranform() and Array#tranform!() methods, refuse to apply a transform to an array with anything other than than 3 numerics. Even though each individual element has a transform method. Example, you have an array of Geom::Point3d objects, and you want to transform ALL elements the same. The Array class transform methods should do this IF the the elements are not numeric, and they respond_to?(:transform). (Add: Any element that does not "respond_to" is returned unchanged.))
  • View.draw2d(GL_POINTS, pts) on ATI with AA

    3
    0 評價
    3 貼文
    355 瀏覽
    thomthomT
    Yea, think so.
  • Rounding a value for export with a ":" separator

    7
    0 評價
    7 貼文
    491 瀏覽
    IltisI
    OK, this works well : begin # Open a file for writing File.open(filepath, "w"){ |file| selection = Sketchup.active_model.selection # Get an array of faces that are in the selection. faces = selection.grep(Sketchup;;Face) faces.each_with_index{ |face, index| # Write a label for the face. file.puts("Face#{index+1}") # Get a transformation object that translates from model space to 2d space of the face. t = Geom;;Transformation.axes(face.vertices.first.position, *face.normal.axes).inverse # Write all vertices to the file. blnFirstPoint = true first_point_u=0 first_point_v=0 face.outer_loop.vertices.each{ |vertex| # Get the point of the vertex and apply the transformation. point = vertex.position.transform(t) # Convert the coordinates u, v = point.to_a.map{ |c| c.to_f } if blnFirstPoint==true first_point_u = u first_point_v = v blnFirstPoint = false end #if # Write the coordinates to the file. file.puts("#{(u*10000*25.4).to_i.to_f/10000};#{(v*10000*25.4).to_i.to_f/10000}") } file.puts("#{(first_point_u*10000*25.4).to_i.to_f/10000};#{(first_point_v*10000*25.4).to_i.to_f/10000}") } } Thanks a lot! Renaud
  • Mac read_defaults?

    20
    0 評價
    20 貼文
    1k 瀏覽
    Dan RathbunD
    Well on the PC, we have been in the same boat. The API can read only string registry values. Many things are DWORD binary values. Often holding only 1 or 0 for true/false, on/off, etc. Such a simple thing that can not be read. A long time ago, I thought I filed a Feature Request for an application level options hash interface.
  • Get component definition name

    3
    0 評價
    3 貼文
    409 瀏覽
    alexandre skA
    ohhhhhh this one is for me: [image: dumbass.jpg] Thank you very much. I was expecting something very simple but not that simple. Starting to like ruby. I only know php and javascript, but this ruby is good. Thank you Jim
  • Find vertex resulting from a pushpull or transformation

    8
    0 評價
    8 貼文
    533 瀏覽
    Dan RathbunD
    The wrapper method in "sketchup.rb" is in need of an overhaul. Post your suggestions in thread: [Code] better inputbox() wrapper
  • Reading registry values withouts quotes

    2
    0 評價
    2 貼文
    284 瀏覽
    Dan RathbunD
    What Windows version and SketchUp version ? EDIT. Nevermind, just go to this post from last Thursday, 1st of May: Re: get registry string from ruby 2.0 (Also works with older versions, if user has the old "win32ole.so" file downloaded from the Plugins forum [link shown.])
  • Nicedit for SketchUp (javascript issue)

    9
    0 評價
    9 貼文
    2k 瀏覽
    inteloideI
    Hello, thank you for your answer. Actually the main reason why it didn't work, is beceause jQuery was required. Once added, it work fine. Inteloide
  • Tool: rak - like grep only optimized for source code repos

    2
    0 評價
    2 貼文
    377 瀏覽
    tt_suT
    Nice! Thanks for the link!
  • Web dialogs stealing focus within my tool.

    28
    0 評價
    28 貼文
    2k 瀏覽
    Dan RathbunD
    Dang it! That is news to me. Did ya'll hire someone to to be a TechWriter for the API? (Ya' need to badly.)
  • Push_tool

    5
    0 評價
    5 貼文
    358 瀏覽
    A
    Thanks guys. Yes, I was doing a pickhelper or ray intersection and figuring out the object being clicked on and added it to the global selection. That worked fine, but only allowed selecting one entity at a time. I wanted to switch to select tool so I can use the group selection features that are available in it. Like thomthom suggested, I managed to get that working by backing up the current tool before doing Sketchup.send_action("selectSelectionTool:") and then restoring the older tool on release. This probably won't retain the tool state since I'm actually exiting the tool and re-entering, but it seems to work for my purpose. Thanks again!
  • OnKeyDown: getting the charcater value from key

    32
    0 評價
    32 貼文
    2k 瀏覽
    Dan RathbunD
    Yea did you look at the C code by clicking the method in the CHM ? It has a kind of convoluted switch statement.
  • Plugin publishing questions.

    7
    0 評價
    7 貼文
    428 瀏覽
    G
    Sounds good. The draw step can be reversed or stopped by deleting the group the draw is writing to, but I don't have it enclosed in an operation. I can add that in. That's the only thing that really needs to be undone; I'm not really crazy about a single undo step rewriting the CNC environment variables and outputting the gcode to a file is a single step anyway that can't be reversed short of deleting the files from the filesystem.
  • Overwritten script!!!

    5
    0 評價
    5 貼文
    404 瀏覽
    D
    did you type it directly into 'Ruby Console' and is the session still open? if so, you can use the 'up arrow' to go back to it, otherwise it's a learning experience... EDIT: should have read the post in detail first, but I'll leave this up for others... if your on linux what editor did you write it in, most have history... john
  • Create file with accent in the path

    23
    0 評價
    23 貼文
    1k 瀏覽
    Dan RathbunD
    @tt_su said: @dan rathbun said: fail() #re-raise the last exception Never seen that method used before. Is that different from just calling raise? raise() is an alias for fail() See the doc on the Kernel module: http://www.ruby-doc.org/core-1.8.6/Kernel.html#method-i-fail The best practices guides I have read, suggest that fail be used instead of raise, for readability, I suppose. But I really did not understand the logic in the guide. (I think it was something like "raise" has more meanings as a verb than "fail" ?)
  • Is there a <select equivalent for <input onClick?

    7
    0 評價
    7 貼文
    791 瀏覽
    sdmitchS
    Thanks much Dan for the info. Looking back at by previous posts, I see that I never made it clear that the question is relative to a WebDialog associated with a plugin. Don't know if that matters but just so you know. Eureka I have found it. It was all a matter of where the onChange was. Because the onClick was part of each radio button statement, I assumed it was the same with the select list. Instead it just needed to be in the <select> statement itself. Thanks again to one and all for the links that put me on the right path to find the answer. def showme() @dlg=UI;;WebDialog.new("VerySimple", true,"Test",500,300,10,10,true) @dlg.set_html( "<html> <body> <form> <select onChange='tellSketchup(value)'> <option value='option1' >Option 1</option> <option value='option2' >Option 2</option> </select> ; Head Type<br><br> </form> <script type='text/javascript'> function tellSketchup(value) { window.location='skp;OptionChanged@'+value; } </script> </body> </html>" ) @dlg.show {} #show it @dlg.add_action_callback("OptionChanged") {|d,p| puts "OptionChanged value=#{p}" } end
  • Minimize WebDialog from code?

    5
    0 評價
    5 貼文
    402 瀏覽
    D
    maybe I'm missing the point... @dlg.set_size(100,100) @dlg.set_position(100,100) @dlg.set_size(1000,1000) @dlg.set_position(100,100) can switch between 2 sizes at the same position... john
  • EntitiesObserver Weirdness

    3
    0 評價
    3 貼文
    302 瀏覽
    K
    Hi Dan, Holding a reference does't make any difference. The only time the reference held by @m is actually stored is when the observer is assigned to Sketchup.active_model.entities. Also, I noticed that in cases where I have a new file, and I first add the observer to a group's entities collection, the observer does not alert onElementModified for the material. It only alerts for the face. Thanks, -- Karen

Advertisement