🏢 PlaceMaker | 25% off for February including new Google Earth data imports! Learn more
  • Problems with script

    4
    0 Votes
    4 Posts
    234 Views
    TIGT
    You should NOT change a collection of entities you are iterating through... NO-NO= Sketchup.active_model.entities.each{|e| e.erase! if e.layer.name=='_4D_Finish_Text' || e.layer.name=='_4D_Start_Text' } YES-YES= Sketchup.active_model.entities.to_a.each{|e| e.erase! if e.layer.name=='_4D_Finish_Text' || e.layer.name=='_4D_Start_Text' } Note how the entities is made into frozen array [.to_a] before processing... To remove such items from inside all definitions use Sketchup.active_model.definitions.each{|d|d.entities.to_a.each{|e| e.erase! if e.layer.name=='_4D_Finish_Text' || e.layer.name=='_4D_Start_Text' }) EDIT: typo corrected '.to_a' added to final example
  • [talk] Using Ruby Modules

    33
    0 Votes
    33 Posts
    29k Views
    J
    Discussion of Wiki purpose and motives moved here.
  • Class similar to Length class

    8
    0 Votes
    8 Posts
    400 Views
    Dan RathbunD
    @viskiz said: I'm interested how Length class is made? It is simply a subclass, which inherits methods from it's superclass. class Distance < Float # add custom methods here end P.S.: DO NOT make changes to the Length class and then publish this in a plugin or script !!
  • Can i draw the whole building structure with code?

    31
    0 Votes
    31 Posts
    3k Views
    chrisglasierC
    I see that you are progressing well with the "technology" side of csv data storage but I wonder (because I am interested in alternative methods) how you are coping with the complexity of the information itself. I have been always wary of csv because I associate it with spreadsheets and though I have tried very hard from the early days of Lotus 123 I have not found a way to use them to "turn" data to cope with its 3D nature. What I mean by turn is illustrated by the diagram to the left which suggests it is natural to use a cross section to review the number of floors in a building but plan section to review each floor's spaces. I think this is sufficient to demonstrate data is 3d in nature (or perhaps more accurately access to it). The animation I have demonstrated before allows me to cope with it in a 2D UI. Information that is often presented as schedules - rebar, door, sanitaryware, ironmongery(hardware) and so on - can be dealt with in the same way, but the properties of the real (as opposed to code) objects require a data or backup display so that you can see collections of key/value pairs for editting. So assuming you agree basically with what I describe, it would be would interesting to see both a UI design and the structure of the csv or hash solution to compare with the UI and Javascript object notation (json) that I currently use. Cheers!
  • Ruby Singleton Class

    4
    0 Votes
    4 Posts
    2k Views
    Dan RathbunD
    @kwalkerman said: I thought this was one of the Ruby native classes? There are 2 catagories of Ruby Base Classes: Standard Included These are loaded along with the Ruby Interpreter. (They are bundled inside the DLL.) Extended Library These must be loaded when needed by using the require('libfilename') method. @kwalkerman said: Any idea why SU can't find it? Because Windows Sketchup does not come with a full Ruby Installation. (Some platforms: Linux, Apple OSX, etc. come "out-of-the-box" with a full Ruby Installation, but this is the OS OEM's doing, and not Google's.) In either case Sketchup is not preset to find the Standard Ruby Library folders. You would need to run a script like my example: See: [code] Ruby LOAD PATHs script for (Win32) @kwalkerman said: Is there any way to restore the file and/or the source code so that I can reference it? On Windows you need to go get the Windows One-Click Installer to install Ruby on your system. See the section: Ruby on Windows on the RubyLang.org Downloads page: http://www.ruby-lang.org/en/downloads/ I have not tried v.1.8.7 with Sketchup yet, I usually recommend the latest v.1.8.6 After install... you'd need to backup the 'msvcrt-ruby18.dll' file in the Sketchup program folder (or rename it to: 'msvcrt-ruby180_p10.dll' as that is the actual version and patch level that ships with Win32 Sketchup.) Then COPY (not move,) the interpreter dll from your new install's bin folder (usually C:/ruby{ver}/bin/) to the Sketchup program folder, renaming the copy to: 'msvcrt-ruby18.dll' (The Ruby guys have started putting all 3 version numbers into the filenames, so you might see it named: 'msvcrt-ruby187.dll'. Just be sure to leave it named as is, in the real Ruby bin folder; But Sketchup is hard-coded to load an exact interpreter dll filename.) The purpose / idea here is to be using the same version Library files as the interpreter your running.
  • Adding Entities without modifying the undo stack

    4
    0 Votes
    4 Posts
    248 Views
    TIGT
    The model.start_operation() options are notoriously flaky... but might improve if the API ever gets updated...
  • Dynamically Associated Text

    6
    0 Votes
    6 Posts
    414 Views
    TIGT
    Search out my Height above Datum Text Tag code... http://forums.sketchucation.com/viewtopic.php?p=193238#p193238 This tool adds a piece of text at the picked point and later if that text is moved its observer reads its Z value and updates itself automatically. In your case instead of it checking its location have it check the area of a given face [don't use ids as these change session to session instead stamp each bit of text AND it associated face with a guid - perhaps based on the time * rand] and have the face update the text. I already have an 'AreaTag' tool on my 'to-do list' [but currently it's a far off number 9]
  • [code] loading from the Standard Ruby Libs

    2
    0 Votes
    2 Posts
    1k Views
    K
    Dan, Very helpful, as always. So... For future... this is where you can download the library files if you need to: http://www.ruby-lang.org/en/downloads/ Thanks again! -- Karen
  • Flip edge

    2
    0 Votes
    2 Posts
    263 Views
    K
    @kolem said: in a quadrangular that isn't co-planar you need an edge going across it so it will create the 'face', is there any way to flip the edge, i saw in Google's API, Sandbox you can but the file is *.rbs Can't you just get the endpoints and redraw the edge? You can actually flip an edge without redrawing it, but it's much more complicated. -Kwok
  • Observer and new components

    2
    0 Votes
    2 Posts
    192 Views
    L
    Sorry for bumping but here some update: The ToolsObserver helped me to find out, that the ComponentTool (21013 - Maybe something else on Mac it is called onentToo) is activated if a user click on a component in the library. If i would know, which definition or at least definitionname this component has, i could implement an own tool to place the component. Maybe $dc_observers.get_latest_class has a function to retrieve the name, or another variable? Because when i look in the active_model.entities, there are only the existing entities but not the one at the cursor.. i can't believe, that there is no variable or method to get this information. Perhaps i do it totally wrong and there is another simple solution letting the choosen component snaps to specified faces/components (no the snaping in SketchUp is not very useful) frustrating^^
  • Ruby to trigger DC onClick Function

    3
    0 Votes
    3 Posts
    1k Views
    M
    thanks for the info, Dan I have read that article and I think my problem was that I was looking for the easy way out. I was wishing for a simple way to run the "OnClick" attribute, in particular, without having to create the animation object myself. It's easy to change a simple attribute like material, or lenZ but the interactive nature of OnClick and the tweening of the ANIMATE function make it a little over my head. But I guess this is how I learn. Thanks, Mike
  • [Bug] NaN in a normal's value

    8
    0 Votes
    8 Posts
    294 Views
    T
    @tig said: Looking at the face itself you have managed to form a face with a double edged zero area inner 'loop' ??? I have separated this face from a big file received from an user. I don't know how he managed to achieve it. I will have to run a NaN check while exporting to prevent errors in an exported file. It would be much better if SU could fix the face using 'ModelInfo\Statistics\FixProblems'.
  • OnPlaceComponent: place the instance in a group

    6
    0 Votes
    6 Posts
    356 Views
    L
    Thanks everybody. Wasn't the solution i hoped for but instead i wrote a name organized system, which perfectly fits our needs. Now there are other problems, hope i can get a solution for them larrywayn
  • Painting a quadrangular

    10
    0 Votes
    10 Posts
    411 Views
    K
    thanks a lot!
  • [info] Using Ruby Modules

    6
    0 Votes
    6 Posts
    3k Views
    Dan RathbunD
    Condensed, Simplified and Reposted from another topic thread. Modules are important and very necessary. If you (speaking generally to all readers and especially newbies,) do not understand the importance of modules, then you do not understand how Ruby operates and how code is (and should be,) loaded. Modules separate your code from other people's code, and prevent your code from "crapping" on the ObjectSpace (which is the same as "crapping" on everyone else's modules and classes, including Google's and Ruby's.) ANY script that defines methods, instance variables, class variables or constants in the ObjectSpace IS "crap." It does not matter if Google did it in their examples, it is still "crap." Not only should you be using A module around your script... you should be using nested modules. The outermost is your TOP_LEVEL namespace. Any tool or plugin you create should be in a nested module (submodule,) of your TOP_LEVEL namespace. This also allows individual tools or plugins to be removed from memory when they are no longer being used. (It also means Google incorrectly put their modules at the toplevel, when they should have been within module Google. What happens in the future when Layout gets an API, and/or Picasa gets a Ruby API that integrates to Sketchup and Layout? But that could be a whole other discussion topic.) Concerning indenting... anticpating a chorus of whiney voices, thus: "Oh man, nested modules mean I have to waste so much space on the left of my code, and push the "meat" of my rubies way to the right! And then I have to hit that TAB key all the time on every line... boohoo!" No you don't! Ruby allows multiple scope defintions ! If I wish to define a class within a submodule of my toplevel module, I can do so and only have 1 indent: # The Outer namespace modules must exist before referencing them. require('myfolder/MyTopLevel.rb') require('myfolder/myplugin/MyPlugin.rb') class MyTopLevel;;MyPlugin;;ThisClass def initialize(*args) # INIT CODE GOES HERE end # def end # class MyTopLevel;;MyPlugin;;ThisClass I can also save an indent when defining a plugin module by doing: # The Outer namespace module must exist before referencing it. require('myfolder/MyTopLevel.rb') module MyTopLevel;;MyPluginTwo class<<self private def method_one # .. code .. end public def method_two # .. code .. end # .. etc .. end # self end # module MyTopLevel;;MyPluginTwo EDIT: Ruby v1.8.0 does not allow the TopLevel scope operator prefix, ie: class **::**MyTopLevel::MyPlugin::ThisClass %(#4000BF)[v1.8.6 does allow it. It basically tells Ruby to start looking at the TopLevel for an indentifier, instead of backing up thru each nesting level from the current level. (I've removed the use of it in these examples, as many users will be running v1.8.0 on Win32, and not know how to update their Sketchup Ruby.)] instead of doing this: module MyTopLevel module MyPluginTwo class<<self private def method_one # .. code .. end public def method_two # .. code .. end # .. etc .. end # self end # module MyPluginTwo end # module MyTopLevel So choose a TopLevel namespace (module name,) that is unique. Use part of your surname. Or if your plugins will be distributed under a brand or company name, then that would be a good toplevel module name. Or you could use your SCF screen name, as long as it's unique. Just don't use a trademarked brandname(s) if your not the owner of the trademark!! Please do not use this thread to discuss issues relating to Using Ruby Modules, instead please use the talk thread: [talk] Using Ruby Modules
  • Right Click-&gt;Hide

    16
    0 Votes
    16 Posts
    824 Views
    K
    never mind i got it working, thanks for the help
  • Windowizer

    86
    0 Votes
    86 Posts
    8k Views
    3
    Can't wait for this window maker..I just made some 3d bricks....
  • Automating Sketchup from Excel

    6
    0 Votes
    6 Posts
    7k Views
    Dan RathbunD
    Here's another forum link along these lines: Excel to SU ( 29/7/08 version ) [has code for download]
  • Ruby scripts lack style

    24
    0 Votes
    24 Posts
    1k Views
    J
    @thomthom said: Watch it Jesse - behave yourself. You will get nowhere fast with this attitude. What attitude? @thomthom said: Chris has a very good point: where are your examples? Where is the work you have done for the community? Don't try to discredit me by questioning my resolve ThomThom. I have been preaching freedom to slaves on this list for ~1.5 years. I have been trying to open your minds to new possibilities, out of the box thinking styles, clean coding styles, better API, better languages, etc, etc. But most importantly i have tried to bring freedom to the slave mindset around here. @thomthom said: If you really want to be helpful and guide people - then start producing something yourself. Provide a starting point of what you want to achieve - then you might get people listening. Sure i want to help, but with all the negative energy why should i? Instead trying so hard to discredit me, how about saying Yes, i would like to help keep the code base clean and written in a proper style. Yes i would like to make the API better. Yes i would like to make the Docs better. @thomthom said: Right now, and given your history, I can't help but feel that you are trolling and have no intention do any other than that. I really hope you are not one of these people that are entertained by starting quarrels. I can't believe you would call ME a troll. All i have ever done was come here to help. Givin out my spare time and for what? Just because you don't agree with my statements does not mean i am a troll.
  • Any way to show/hide component axes via Ruby

    3
    0 Votes
    3 Posts
    695 Views
    DavidBoulderD
    Thanks! I would have searched a while for that.

Advertisement