ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • How to modify texture color with code?

    6
    0 Votes
    6 Posts
    155 Views
    A
    I think when setting a color to a textured material, the change becomes visible immediately, however the API does not differ between colorizing (checkbox in the materials browser) and color-shifting (pointer on the color wheel). Assuming you rotate the color wheel of a material A and get material B: [image: Z4QK_colorize.png] We can then read the color value of B: ` material.materialType 2 color = material.color Color(200, 147, 62, 255)then reset it to the texture image's original look: material.color = nil nilThis way we get A. material.materialType 1then trying to set it again: material.color = color Color(200, 147, 62, 255) material.materialType 2` This time it is also colorized (C) and we have no control about it.
  • Attributes in Sketchup - Probably a stupid question

    10
    0 Votes
    10 Posts
    1k Views
    thomthomT
    @fdarma said: Well, I have no idea that such an instance definition existed. On that topic, a detailed breakdown of how instances and definitions work in SketchUp: http://www.thomthom.net/thoughts/2012/02/definitions-and-instances-in-sketchup/ If you are fresh to SketchUp plugins I recommend you also check out this: http://www.thomthom.net/thoughts/2012/01/golden-rules-of-sketchup-plugin-development/
  • How to get the absolute coordinates of faces?

    7
    0 Votes
    7 Posts
    3k Views
    liquid98L
    Hi Ibswu, Check this: http://sketchucation.com/forums/viewtopic.php?f=180&t=48769 -- Liquid
  • New SketchUp Developers Tools - TestUp

    18
    0 Votes
    18 Posts
    727 Views
    S
    @driven said: I did wonder the same after cloning the new version and losing that fix, at the same time I added </body> > <script> bodyLoad() </script> and deleted it the top tag, again. I'm away for a few days but will try your version hack, does it work with gems? john The only reason it wouldn't work with gems is that SketchUp doesn't set up a library load path to anything except their own stuff. To get any other ruby code you need either to copy it into SketchUp's area or manipulate the ruby load path before you access it. Steve
  • Need openssl.so

    4
    0 Votes
    4 Posts
    299 Views
    B
    Thanks , TIG and Dan, I have decided to install Ruby, though it seem a little complex to me
  • An animation for a walk through in a model using ruby

    2
    0 Votes
    2 Posts
    91 Views
    Dan RathbunD
    @sachi said: User has to change the scene(click on the scene tab) manually to display the animation(to go to the next scene). No the user chooses from the menu: View > Animation > Play For Ruby YOU use the Animation class. Or just change the selected_page via the Pages collection.
  • Wrapping HTML in ruby, why?

    3
    0 Votes
    3 Posts
    60 Views
    jolranJ
    Aha, I see. So embedding HTML is more for convenience sake then. I remember even over half a year ago there where issues on Safari, thought they whould have been fixed by now. Kind of the answer I was hoping for though, if I understood it correctly. Thank you.
  • 500 Plugin Requests

    14
    0 Votes
    14 Posts
    2k Views
    Dan RathbunD
    @dan rathbun said: @tig said: So who is to produce the list of [REQ] posts that have been answered / unanswered ? (1) Can moderators set a topic to "Solved" against a certain post, with the new "solution feature" (green check button) ?? The answer to (1) I'd say is YES. Here's an image of one of my posts.[image: 8HVb_solved_post_in_topic_list.PNG] I personally changed the title prefix from "[Issue]" to "[Closed]", but it was Gábor that actually marked it solved. (He reminded me of the "solution feature" in doing so.)
  • Model.import not working for newbie.

    13
    0 Votes
    13 Posts
    232 Views
    timberlineT
    Thanks, That plug-in will do nicely. I have imported a test file and it worked well.
  • Allow to start a plugin just once

    4
    0 Votes
    4 Posts
    78 Views
    Dan RathbunD
    @tig said: Then later use @dlg to change its url, show it etc, and set/reset all other options available etc... This is important! The dialog instance is not destroyed when you close it. You can re-open it again. And if you had data from the dialog, stored in Ruby vars, you can reset them back into the dialog's Javascript vars, after it reopens.
  • Add_face(edearray) not working?

    11
    0 Votes
    11 Posts
    376 Views
    thomthomT
    You can get a type of entity faster by using grep. (See this thread: http://sketchucation.com/forums/viewtopic.php?f=180&t=48885 ) <span class="syntaxdefault"></span><span class="syntaxcomment">#&nbsp;Get&nbsp;an&nbsp;Array&nbsp;of&nbsp;all&nbsp;of&nbsp;the&nbsp;selected&nbsp;Edges<br /></span><span class="syntaxdefault">edges&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">selection</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">grep</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Edge</span><span class="syntaxkeyword">)&nbsp;</span><span class="syntaxdefault"></span>
  • Make OSX WebDialog alert of script errors?

    6
    0 Votes
    6 Posts
    88 Views
    Dan RathbunD
    The MSDN page says there are no standards that apply to onerror (its IE only.) You could it on both the document and window objects just to be sure. If Safari is DOM Level 3, then you may need to use: %(#8000BF)[window.addEventListener("error",*fHandlerName*,*bCapture*)] [window.addEventListener](http://msdn.microsoft.com/en-us/library/ff975245(v) DOM Level 3: Error Example: http://msdn.microsoft.com/en-us/library/hh772306(v=vs.85).aspx Or you could %(#8000BF)[catch] the errors with JS: [url=http://msdn.microsoft.com/en-us/library/4yahc5d8(v=vs.85).aspx:3cyk4r6q]try ... catch ... finally[/url:3cyk4r6q] [url=http://msdn.microsoft.com/en-us/library/85fscz6h(v=vs.85).aspx:3cyk4r6q]throw[/url:3cyk4r6q] [url=http://msdn.microsoft.com/en-us/library/dww52sbt(v=vs.85).aspx:3cyk4r6q]Error object[/url:3cyk4r6q]
  • [Code] Grepping entities

    19
    0 Votes
    19 Posts
    2k Views
    dkendigD
    actually, here's the benchmark code I ran class Magic;def initialize(&block) @block=block;end def ===(other) @block.call(other) end end def GetVrayImportantArrayFromGrepDrawingelement(entities) return entities.grep(Sketchup;;Drawingelement){|ent| false == (ent.class == Sketchup;;Edge) ? ent ; nil}.compact end def GetVrayImportantArrayOfTypesFromGrep(entities,typeHash) for curType in typeHash.keys() typeHash[curType] = entities.grep(curType ) end end def GetVrayImportantArrayFromGrepMagic(entities) return entities.grep(Magic.new {|ent| ent if(ent.class == Sketchup;;ComponentInstance or ent.class == Sketchup;;Group or ent.class == Sketchup;;Face)}) end def GetVrayImportantArrayFromLoop(entities) vrayImportant = Array.new() for ent in entities.to_a if ent.class == Sketchup;;Face or ent.class == Sketchup;;ComponentInstance or ent.class == Sketchup;;Group vrayImportant.push(ent) end end return vrayImportant end def RunBenchmarkOnEntities(entities) testHash = Hash.new() testHash[Sketchup;;Face] = [] testHash[Sketchup;;ComponentInstance] = [] testHash[Sketchup;;Group] = [] grep_drawing_ele_result = grep_magic_result = compare_loop_result = nil grep_drawing_ele_start_time = Time.now.to_f grep_drawing_ele_result = GetVrayImportantArrayFromGrepDrawingelement(entities) grep_drawing_ele_end_time = Time.now.to_f grep_types_start_time = Time.now.to_f grep_types_result = GetVrayImportantArrayOfTypesFromGrep(entities,testHash) grep_types_end_time = Time.now.to_f grep_magic_start_time = Time.now.to_f grep_magic_result = GetVrayImportantArrayFromGrepMagic(entities) grep_magic_end_time = Time.now.to_f compare_loop_start_time = Time.now.to_f compare_loop_result = GetVrayImportantArrayFromLoop(entities) compare_loop_end_time = Time.now.to_f puts "drawing_ele_test time; #{grep_drawing_ele_end_time - grep_drawing_ele_start_time}, resulted in #{grep_drawing_ele_result.size} elements found" puts "types_test time; #{grep_types_end_time - grep_types_start_time}, resulted in #{testHash.values.flatten.size} elements found" puts "magic_test time; #{grep_magic_end_time - grep_magic_start_time}, resulted in #{compare_loop_result.size} elements found" puts "loop_test time; #{compare_loop_end_time - compare_loop_start_time}, resulted in #{compare_loop_result.size} elements found" return nil end RunBenchmarkOnEntities(Sketchup.active_model.entities)
  • EntitiesObserver and attributes

    7
    0 Votes
    7 Posts
    165 Views
    R
    Great, this solved my problem! Thank you very much Dan!
  • [PDF] Git vs Mercurial code repositories

    4
    0 Votes
    4 Posts
    733 Views
    Dan RathbunD
    UPDATED TOPIC - added PDF in first post.
  • How to find loops edges from selection

    7
    0 Votes
    7 Posts
    133 Views
    B
    thanks TIG, I worked it out by classify_point and raytest
  • Operations not commited

    2
    0 Votes
    2 Posts
    48 Views
    Dan RathbunD
    (1) It's easy to see why the 2nd op is aborted because you call model.abort_operation instead of committing it. (2) Perhaps some other plugin is also creating ops and "gluing" their's transparently between your 2 ops ?? I always disable all other 3rd party plugins when developing!* (But I leave the OEM Dynamic Components extension ON.) (3) Do yourself and us a big favor.. wrap your operations and trap any errors that cause the ops to abort. See [Code] wrapping operations
  • Unload / reload plugin without closing SketchUp

    17
    0 Votes
    17 Posts
    2k Views
    thomthomT
    Yea - the key is that you're plugin is not the only one operating and observer events can trigger in the middle of other operations. That's why I talked about caching the observer data until you find a "safe point" to execute. Mapping out this is important to avoid headache. Keeping observers to a minimum is best IMO - reduces overhead and risk of conflicts. Consider each observer if you really need it. I'm a bit more liberal with observers when I use them within the operation of my own custom Tools. (Within a Tool class) as I then assume I have greater control over the environment.
  • Hightlight/select component with mouse over

    7
    0 Votes
    7 Posts
    823 Views
    F
    WOW! Thanks sdmitch!! That's way over my pay grade, Damn! I tested it and it works great, though I must admit I'll have to study the code a lot to figure out how you did it and even then I'm not sure I'll get it.
  • Ruby &quot;good practice&quot; using constants?

    23
    0 Votes
    23 Posts
    3k Views
    Dan RathbunD
    @brewsky said: And after thinking on this, maybe TT's way of just making a module as a base-object for the plugin is a better approach than my BimTools-class. Because is't only used once, the module-approach seems more fitting... Oh hell yes. If you need only one copy of a code object, then generally it should be a module. If you need multiple copies of a code object (usually because the code must adapt to many other instance objects,) then you make it a class, and instantiate instances that are syncronized to a particular instance object. Often coders try to avoid using a module, because they think it's a static kind of object, and they believe it is harder to use than a class instance. What they miss is, that a module definition, is really an instance of class Module. So for example, your nested module Brewsky::BimTools::Manager is actually an instance object, and the preceeding identifier is the reference to the instance. If you remember this... then it can be easier to understand how using an anonymous singleton proxy class instance inside your Module class instance, makes sense. Imagine the Module class is "the hen". It lays an egg, which is your nested Manager module instance, that could be created thus: ` Brewsky::BimTools::Manager = Module.new { plugin managerial code here }But the Ruby interpreter calls the new()` constructor for you on the C-side of things. (Ie, the defintion block syntax for scripts, was invented for human happiness and readability; Ruby itself does not really need it.) But having methods in modules communicate (call each other,) works a bit different than in a class definition. Instance method definitions in a module, are meant for Library Mixin modules. (Read up on the include and extend methods.) They become different kinds of methods, depending on whether they are mixed into a class or module, and whether include and extend is used to do the mixing.) So at first blush, the coder thinks they must define all methods in a module as module functions that must be called with self.method_name(), ... they find this cumbersome, and they switch back to using a class defintion, and using only one instance of it. (A sort of psuedo-singleton class.) BUT.. the egg can have a membrane inside it's shell. This membrane analogy is the anonymous singleton proxy class instance created with the following syntax: module Brewsky module BimTools end end module Brewsky;;BimTools;;Manager # module variables and constants declared here MGR_VERSION ||= '1.2.3' @@bimmenu ||= nil class << self # self evaluates to the module instance # Everything in here acts like a class # instance BECAUSE IT ACTUALLY IS ! # In here we can access the module @@vars directly. # In here we define instance methods, not module methods. # But if they are public, they can be called like module # functions, from anywhere outside the module. private def get_version() MGR_VERSION end # In here we can call any other method in here, # without module qualification. public def version() get_version() end end # proxy class # Out here we can call any of the methods inside # the proxy class directly, without qualification. unless @@bimmenu @@bimmenu = UI.menu('Plugins').add_submenu('BIMTools') @@bimmenu.add_item('Version') { UI.messagebox("BIMTools ver #{version()}") } end end # module Brewsky;;BimTools;;Manager # 99.9% of the time, there is no good reason to # have any executing code outside your namespace. EDIT(2012-12-16): changed post title to "Why use a module instead of a class ?"

Advertisement