ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • Webdialog example

    6
    0 Votes
    6 Posts
    194 Views
    jolranJ
    Great info. I probably should get that windowiser4 plugin then. It does seam very handy as a plugin, as well Thanks
  • Sketchup API (Ruby) - offline copy

    14
    0 Votes
    14 Posts
    2k Views
    T
    You can use WinHTTrack to make a copy of the API on a hard-drive.
  • Temporarility Changing Materials

    7
    0 Votes
    7 Posts
    299 Views
    Dan RathbunD
    @joshb said: Thanks again Dan! Storing the material name works great. Your welky! However writing attributes into the model DOM.. is going to slow things down (and add extra items onto the undo stack.) Since this is temporary... why not just keep the references in memory? A Hash object will do fine: # a new Hash to hold the material refs for each entity prev_matls = {} # keep the entity refs held in an Array, like; ents = model.entities.to_a # use Ruby's built-in Array iterator to save material refs ents.each {|e| prev_matls[e]= e.material } # now the hash has unique keys because each entity ref is unique # # your view wizard.. whatever # # restore them; ents.each {|e| (e.material= prev_matls[e]) if prev_matls[e].valid? }
  • UI openpanel - path issue?

    3
    0 Votes
    3 Posts
    565 Views
    Dan RathbunD
    If you are asking, "Can UI.openpanel return a path?" yes... by hotwiring it... baseDir = Sketchup.find_support_file('Plugins') relDir = "examples" title = "Choose a Dir..." openpath = File.join(baseDir,relDir) my_path = UI.openpanel( title, openpath, "*." ) if my_path.nil? # the user cancelled the dialog else my_path = File.expand_path( File.dirname(my_path) ) end (Edited for clarity, added openpath local.) The filetype filter does not work on PC. (Windows itself is overriding the parameters, using MRU settings in the Registry for the File Open dialog.) Now if you are wondering if you can first set the working dir, and will the UI.openpanel go there? Not really,.. you must make the call with the wd: Dir.chdir('C;/') my_path = UI.openpanel( "Choose Dir...", Dir.getwd, "*." ) if my_path.nil? # the user cancelled the dialog else my_path = File.expand_path( File.dirname(my_path) ) end
  • Erasing entites problem?

    8
    0 Votes
    8 Posts
    380 Views
    TIGT
    face = entities.add_face($pt6, $pt8, $pt7, $pt5) is logical as you are adding a face from a set of points. I fail to see the full logic behind your suggested new API method face = entities.erase_face($pt6, $pt8, $pt7, $pt5) - but you could of course mimic it within your own method quite simply, using other existing API methods [which is what your suggested new API method would in effect have to do if it were implemented] - like this... def erase_face(entities, points_array, all_edges=false) face=entities.add_face(points_array) return false if not face or not face.valid? edges=face.edges face.erase! edges.each{|e| if e.faces.length==2 && e.faces[0].normal.dot(e.faces[1].normal) > 0.99999999 && e.faces[0].material==e.faces[1].material && e.faces[0].back_material==e.faces[1].back_material e.erase! elsif not e.faces e.erase! end } if all_edges return true end which you'd use like this... erase_face(entities, [$pt6, $pt8, $pt7, $pt5]) to erase the face if it can exist from the given points. OR like this... erase_face(entities, [$pt6, $pt8, $pt7, $pt5], true) to erase the face if it can exist from the given points, AND the 'true' argument to erase all of its edges too - but of course because other faces might also rely on some of these edges and unexpectedly vanish with them too there is a trap test not to remove those unless they are 'coplanar'... It returns 'false' if no face and 'true' if it is erased. PS: Please avoid using global variables like $pt6, when @pt6 would work within a module/class instance methods and @@pt6 across class use. You will rarely need to create $vars in your own code...
  • Trace what prevents an object from being GC'd?

    22
    0 Votes
    22 Posts
    906 Views
    Dan RathbunD
    @unknownuser said: (http://forums.sketchucation.com/viewtopic.php?f) of this topic":25oe0j3o] Did you dispose of all Locals, Constants, instance vars, and perhaps maybe even Procs that are within your subclass? That said... you should be able to have proc refs, if they are instance @refs because they are likely to have refs inside them that ref instance objects. If the class is a singleton (most WebDialogs are,) just limit the number of instances to 1, in the wrapping namespace, the same way you would for a tool instance.
  • Web page loaded while ruby processes?

    9
    0 Votes
    9 Posts
    246 Views
    fredo6F
    @thomthom said: Fredo uses timers to slice up the work, but it makes the total processing time a lot slower. Actually the overhead is reasonably small. The goal of this mechanism is just to give back control to the UI, in case the user has clicked or typed a key. This is not to perform heavy stuff while the script is itself busy with computation. Fredo
  • Find any methods that are never called?

    3
    0 Votes
    3 Posts
    143 Views
    thomthomT
    @tig said: add =begin...=end around the method and retest the script: Make sure to restart SU before retesting. Because a load will not remove the old method. Easy trap to fall into, as you won't notice something failed until you start the next time.
  • View.guess_target algorithem?

    7
    0 Votes
    7 Posts
    287 Views
    Chris FullmerC
    Oh yes, that zoom tool. I forgot about that one. I never use it, I'm a scroll wheel only person. And the scroll wheel does zoom to where the mouse cursor is. The actual zoom tool though yes, that also uses the mouse pointer to some degree. If you hold it over something close, you zoom quickly. hold it over something far and you zoom slower. Even if your mouse goes from being on top of something close to not on top of something int he same dragging event, the speed of zoom will vary. I'd never noticed that before. The orbit tool (again, my scroll wheel) doesn't do what I was thinking it does. It does seem to just orbit around the center of the screen, and the distance of the z axis seems to be based on some sort of target. I'm wondering if it has to do with the near and far culling planes? Perhaps evenly spaced between them? Chris
  • [Code] Creating attr like methods

    8
    0 Votes
    8 Posts
    1k Views
    thomthomT
    Doubledone!
  • Attribute accessor - get all as an array?

    13
    0 Votes
    13 Posts
    5k Views
    Dan RathbunD
    @chris fullmer said: That is great to know, because that is precisely what I will be doing with these ... Spooky! .. now I'm answering your questions before you ask them. (.. does anyone hear the "Jeopardy" theme?)
  • Entities relationship - Sketchup Ruby SDK

    14
    0 Votes
    14 Posts
    1k Views
    N
    Thanks for all the suggestions, pointers and tips. I am making progress exporting both raw entities and entities within components instances (including the transformation) It's not complete yet (some instance are place wrongly) but I should be able to figure the rest out (might be group handling etc) Thank you once again.
  • Importer in the same wind order

    3
    0 Votes
    3 Posts
    184 Views
    G
    thanks TIG. Now i must find a method for import all faces in correct wing order: 1)i see that there is a m_pMesh->GetPolygonPointIndex(m_nCurrPoly+1, m_nCurrPoint+1, &m_idx); is sufficent have the correct indexes of the vertexes for import all in the correct windorder ? 2) or i must separate the importation of vertexes like the sketchup example SkpToXml of the sdk? The sample project do that: extract the loops hr = pFace->get_Loops(&pLoops); long nLoops; hr = pLoops->get_Count(&nLoops); //If this is a simple face (no loops) if (nLoops==1){/////////////////////////////////////////////////////////////////is a simple face //import vertex in counterclockwise order CComPtr<ISkpLoop> pLoop; hr = pFace->get_OuterLoop(&pLoop); CComPtr<ISkpVertices> pVerts; hr = pLoop->get_Vertices(&pVerts); } else ///////////////////////////////////////////////////////////////////is a complex face tessellate it with: pFace->CreateMeshWithUVHelper(3, pUVHelper, &pMesh); and imports vertex in clockwise order????? //there i must place the m_pMesh->GetPolygonPointIndex??? and import in specific order???? ecc.... is sufficent???? Thanks a lot.
  • Open Source License?

    8
    0 Votes
    8 Posts
    209 Views
    Dan RathbunD
    The MIT License is consise. @unknownuser said: Copyright (c) <year> <copyright holders> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • Untagged deleted element after using outer_shell on group

    12
    0 Votes
    12 Posts
    651 Views
    Dan RathbunD
    BTW.. there might be some API call that also has the effect of triggering garbage collection. Try view.refresh() Hmm.. it also occurs to me, that Sketchup may be wanting to keep references to deleted entities around, just in case the user decides to do an undo. But a call to all_connected() should not return these entities in the result Array. If it does, then it's the all_connected() method that is bugged. You said that you were wrapping your code in your own operation... if you didn't (ie you just let Sketchup handle the undo,) I wonder if the error would also occur? Meaning it could be an operation bug.
  • Ruby Console access from C extension

    10
    0 Votes
    10 Posts
    421 Views
    T
    I have tried the last solution: rb_eval_string("$stdout.write(\"Message\n\")"); and it works well. I am using it for debugging purpose, so the speed is not important for me. Thanks!
  • Open SU vs open model - __FILE__ might vary

    10
    0 Votes
    10 Posts
    303 Views
    Dan RathbunD
    TIG's suggestion DOES work !!! File.identical?("C:/Program Files/Google/Google SketchUp 8/Plugins/testfile.rb", "C:/PROGRA~1/Google/GOOGLE~3/Plugins/testfile.rb") true Then, stripping off the filename and testing dir against dir: File.identical?("C:/Program Files/Google/Google SketchUp 8/Plugins", "C:/PROGRA~1/Google/GOOGLE~3/Plugins") true But it's still stupid, that the installer writes 32 bit quoted pathname, and the app overwrites it each time it starts up with a 16bit pathname. If I start SU7, i wonder if it will overwrite the registry key. Bet it will...
  • Using Polygon Mesh

    11
    0 Votes
    11 Posts
    2k Views
    Chris FullmerC
    @adamb said: @thomthom said: @adamb said: But if you like, I've got code that handles quads Quads? Whatcha mean? You give me a four-sided polygon (quadrilateral) , and I'm sure I can stretch to writing code to break it into triangles. Best response ever.
  • Writing out temp files - How to cleanly delete when done?

    23
    0 Votes
    23 Posts
    4k Views
    AdamBA
    @chris fullmer said: Currently, on Vista 64 when I create the folder in sketchup ruby, if I try to delete the folder through the windows explorer it tells me the folder is currently being used in another app. And I get an error as well when I try to delete the open folder through another instance of SketchUp. I just don't know how it will react in other windows versions and on a Mac, especially since SU on OS is MDI. It might not be able to differentiate which instance of SU created the folder and which is trying to delete it. But it would be interesting to test. Chris, Not being able to delete a folder/file on Windows typically means there is a process somewhere with a 'handle' to the file/folder. Yes, it is pathetic that Windows still cannot handle stuff like this - every other OS can.. but anyway.. First double check you really are releasing the File Descriptor handle you use in Ruby. If you the file isn't really closed, you won't be able to delete it. Adam
  • Meaningless Menu Separators

    5
    0 Votes
    5 Posts
    215 Views
    Dan RathbunD
    @thomthom said: You mean so that separators only adds a separator between the native tools and the plugin tools? And.. I agree with the above for Main menus (incl. "Plugins",) and the right-click Context menu.

Advertisement