⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update
  • Calculate edge "profiles"?

    3
    0 評價
    3 貼文
    804 瀏覽
    A
    TIG, your profetional! Everything works, the way you said [attachment=1:ylsl8vni]<!-- ia1 -->SelectEdgesInProfiles.png<!-- ia1 -->[/attachment:ylsl8vni] Here's a little plug I've got for a little testing. [attachment=0:ylsl8vni]<!-- ia0 -->SelectEdgesInProfiles.rb<!-- ia0 -->[/attachment:ylsl8vni] %(#00BF00)[Select Edges in Profiles Date - Monday, July 16, 2012 Version 1.0.1 Main thing on how to locate the edges in profiles is by TIG Written by Anton Synytsia Not a plugin, but written for simple use of testing Menu Location: UI_menu:plugins/selectEdgesInProfiles Usage: Select grp(s) or/and component instance(s) and then select the menu item Yet, Unsolved bugs: Selects edges that camera doesn't sees. TIG.getEdges function doesn't yet search the group for edges found inside the parent group.] Changes: Fixed the selection of edges behind the faces, the edges that camera doesn't even sees. Save to Plugins directory
  • Find point, axis and a rotation angle

    11
    0 評價
    11 貼文
    951 瀏覽
    TIGT
    There are several Examples of Tool .rb files shipped with Sketchup - e.g. LineTool. These will show how to construct and then call a Tool class, which then has access to lots of methods relating to user input - mouse, keys etc - without you having to reinvent them from scratch... Also see the API docs... https://developers.google.com/sketchup/docs/ourdoc/tool
  • How to add an entity to entities?

    3
    0 評價
    3 貼文
    119 瀏覽
    lbsswuL
    @thomthom said: You're aware of the API documentation, right? https://developers.google.com/sketchup/docs/classes The Entities class has many method to add entites - depending what you want to add: https://developers.google.com/sketchup/docs/ourdoc/entities You're not talking about adding an existing entity to a different Entities collection? I am sorry I made a mistake about the concepts of Sketchup::Entity and Sketchup::ComponentInstance. I have two car models, and I should use entities.add_instance to add a car.
  • How to get the center of a ComponentDefinition array?

    5
    0 評價
    5 貼文
    176 瀏覽
    lbsswuL
    @tig said: If you meant ComponentInstance then they each have bounds. Make a new empty bounding-box object [ bb], and then add each of the instance.bounds to that bb.add(instance.bounds). The center is bb.center......... Thanks for your tip. I will test the code.
  • VCB greyed out

    3
    0 評價
    3 貼文
    340 瀏覽
    Dan RathbunD
    Duke, ya need to get your files and folders organized (so you stop using global variables.) Separate the code into 3 files, thus: file: "Plugins/CKD_Thicken_ext.rb" ### # "Plugins/CKD_Thicken_ext.rb" require('sketchup.rb') require('extensions.rb') module CKD module Thicken @@plugin = SketchupExtension.new "Thicken", "CKD/Thicken/CKD_Thicken.rb" @@plugin.version = '1.0' @@plugin.creator = 'CKD (aka "Duke")' @@plugin.copyright = '2012, CKD' @@plugin.description = 'Uses JPP to thicken the select face/s directly or inside the selected groups' Sketchup.register_extension( @@plugin, true ) end # module Thicken end # module CKD file: "Plugins/CKD/CKD_module.rb" # ------------------------------------------------------------------------- # "Plugins/CKD/CKD_module.rb" module CKD @@topmenu = UI.menu('Plugins') @@submenu = @@topmenu.add_submenu('CKD') @@menuitem = {} def self.menuitem() return @@menuitem end def self.submenu() return @@submenu end def self.topmenu() return @@topmenu end end # module CKD file: "Plugins/CKD/Thicken/CKD_Thicken.rb" # ------------------------------------------------------------------------- # "Plugins/CKD/Thicken/CKD_Thicken.rb" require('sketchup.rb') require('jointpushpull.rb') require('CKD/CKD_module.rb') module CKD;;Thicken @@tool = nil class ThickenTool def initialize(caller_class) @caller = caller_class @thickness = 100.mm end def activate @model = Sketchup.active_model @selected = @model.selection Sketchup.set_status_text("Thickness", SB_VCB_LABEL) Sketchup.active_model.active_view.invalidate end def deactivate(view) view.invalidate @model = nil @selected = nil end def resume(view) @model = Sketchup.active_model @selected = @model.selection Sketchup.set_status_text("Thickness", SB_VCB_LABEL) Sketchup.active_model.active_view.invalidate end def suspend(view) nil end def onUserText(text, view) UI.messagebox("what") # call method thicken() here ? end def enableVCB? return true end def thicken model.start_operation("Thicken") # # change model here # model.commit_operation rescue Exception => e model.abort_operation puts("Thicken Error!\n#{e.message}") puts(e.backtrace) end end #Class ThickenTool class << self # Proxy class def tool() if @@tool.nil? @@tool = CKD;;Thicken;;ThickenTool.new(self) end # return @@tool # end end # Proxy class # RUN ONCE unless file_loaded?( 'CKD;;Thicken' ) CKD;;menuitem["Thicken"]= CKD;;submenu.add_item("Thicken") { Sketchup.active_model.select_tool( CKD;;Thicken;;tool ) } file_loaded( 'CKD;;Thicken' ) end end # module CKD;;Thicken
  • List of keyboard keys constants

    3
    0 評價
    3 貼文
    741 瀏覽
    K
    Thanks for your answer TIG, using non modifier keys is indeed a bad idea inside a tool, because they are already bound to lots of different tools. I also discovered that the int values corresponding to keystroke can be accesed like this valueFor_W_Key = ?W a bit weird, but it works. I ended up not using keys
  • Modifying or extending SU native tools

    5
    0 評價
    5 貼文
    1k 瀏覽
    Dan RathbunD
    Most of the native tool ids are defined as global constants, that begin with "CMD_" List them, at the Ruby Console: Object.constants.grep(/CMD/).sort The tool state integers vary from tool to tool, and some tools do not use them at all.
  • How to upload skp to server by ruby plugin?

    10
    0 評價
    10 貼文
    1k 瀏覽
    Dan RathbunD
    There are already several Ruby bindings written for curl. http://rubygems.org/search?utf8=%E2%9C%93&query=curl Maybe one could be made to work under SketchUp ??
  • Wrap gem under own namespace

    14
    0 評價
    14 貼文
    512 瀏覽
    thomthomT
    The string you feed create_makefile should relate to the init function in your C extension. As you see from the Hello World example, extconf contains this: create_makefile( 'SX_HelloWorld' ) And in the C source you have the init function: void Init_SX_HelloWorld( void ) Note how "Init_" is prepended of the name you feed makefile - and it's case sensitive. @anton_s said: change the vcvars32.bat path to your current vcvars32.bat path, and run it to compile. I have found after making the tutorial that it is easier to just launch the command prompt shortcut that ships with Visual Studio. It's there in it's folder in the start menu. The environment is set up automatically.
  • Can you adjust the &quot;strength&quot; of a transformation?

    8
    0 評價
    8 貼文
    390 瀏覽
    TIGT
    The object's 'position' is relatively easy to find - it's just the t=object.transformation.to_a for the xyx point as an array of the last few elements thus: point=[t[-4],t[-3],t[-2]]... OR transformation.origin ! The transformation's scale and rotation interact with each other, so they are much more complex to extract from the transformation array... but not impossible - there are already some earlier post discussing this...
  • Js / DOM / HTML questions

    6
    0 評價
    6 貼文
    128 瀏覽
    Dan RathbunD
    @dan rathbun said: What I'm I'm wondering is if I can do this, for cross-platform: %(#8000BF)[document.head] OK I understand now (those new MSDN pages are so confusing!) %(#8000BF)[document.head] is part of HTML 5. http://stackoverflow.com/questions/7557868/document-head-document-body-to-attach-scripts and http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#dom-document-head
  • Pollution Private methods of Class

    9
    0 評價
    9 貼文
    332 瀏覽
    J
    Sandbox Tools are responsible for most of them: @unknownuser said: CalcTriangleProperties CheckEntity CountDuplicates Equal2D Equal2D2 FacesAreTriangles GetAllVertices GetCursorID GetFaceNormal GetFaces GetPolyNormal GetTransformedVertexPositions GetVertsInWCS In2DCircle InPlane IsAlreadySelected LineFaceIntersection NegIfEven PointInArray PutsTransform RemoveNonFunctionalVerts SegmentsCross2D SelectAllConnected TriangulateDelaunay VectorScalarMult getOffsetPolygon getOffsetPolygon2 getOffsetPolygon3 isOdd paramT sign tellPctComplete
  • How to import several models to designated positions

    13
    0 評價
    13 貼文
    658 瀏覽
    Dan RathbunD
    When I first listed the methods, I thot for a moment (until I looked twice,) that the seventh method was named eat_me! ...
  • Bulletproof sample code for a plugins menu ???

    12
    0 評價
    12 貼文
    359 瀏覽
    TIGT
    Now you understand how to debug! Missing _item ... ...@KSORsubmenu.add**_item**... My typo - which occurs twice when the item is added to the submenu [or it wasn't thanks to the typing error ] Edit those two 'add' lines in your script and it should then work. I have edited the original post so other browsers won't get confused...
  • Leaving out one field in inputbox ???+

    6
    0 評價
    6 貼文
    240 瀏覽
    K
    Thx to Aerilius - very usefull explanation !
  • Sketchup and open-uri

    4
    0 評價
    4 貼文
    663 瀏覽
    D
    Sorry for the late reply. So basicly what I want to do is upload files to and from a restful api using multipart/form data that are not in sketchup format. ie, export obj file > upload to server > delete obj file or download stl file > import to sketchup > delete stl file after giving up on net stuff through ruby which all seemed to crash sketchup I started looking into accomplishing this through the web dialog with ajax. While it works for communicating with the api in other ways and solves a lot of my problems. It is still not possible to upload or download a file with out the file dialog (and for good reason) but I want something more seamless. So far the closest thing I have found is https://github.com/danawoodman/google-sketchup-file-downloader but it isn't working. Thanks for your help, I will keep at it and appreciate any more help Thanks!
  • [Code] Executing a cmd without the black screen (Windows)

    17
    0 評價
    17 貼文
    7k 瀏覽
    Dan RathbunD
    One issue is there is what I consider a bug in the Ruby Win32 source. If you try to set ENV["RUBYSHELL"] to "Wscript" it will not work because the source always wants to inject a " -c" switch into the command. Problem is, Microsoft wrote Wscript.exe and Cscript.exe to poop out if any unknown switches are in the command. (I think cmd.exe just ignores unknown switches.) So any way, the normal Ruby means of changing the shell that %x and ` Kernel.`` use, will actually not work on Windows.
  • System command without window

    2
    0 評價
    2 貼文
    62 瀏覽
    thomthomT
    Never mind - found this thread: http://forums.sketchucation.com/viewtopic.php?f=180&t=36973&start=0
  • How to get the saved file path

    13
    0 評價
    13 貼文
    3k 瀏覽
    OricAtmosO
    Hey, I ran into the same problem as Nick60 today and was glad I found this thread with an nice solution. However there's still one use case with a problem: when the user saves the model with "Save copy as..." the side-car file will be saved under the wrong name. Any suggestions how this could be fixed?
  • Entities.intersect_with crash

    10
    0 評價
    10 貼文
    400 瀏覽
    K
    @unknownuser said: ?? The API docs really need to expand with more info on this method! yeah - most confusing method in the API!

Advertisement