ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • How to protect your plugins code

    5
    0 Votes
    5 Posts
    1k Views
    Dan RathbunD
    @tlnguyen said: So is there a way to protect our ruby code? and is there a way to remotely control its use? Do you mean license management ? "Control it's use"... in what way(s) ??
  • Ruby API Pages.add bug(s)

    4
    0 Votes
    4 Posts
    105 Views
    T
    Doc and code drifting is quite possibly one of the biggest issues affecting code maintainability. I've never quite got over the idiocy of a few people I've worked with that really took to heart the attitude of "documents and comments? Why do you think it's called 'code'?" Certainly when I was managing a team I didn't let anyone get away with that - at least where I could detect it… An old colleague came up with a pithy way to describe what ought to happen - "don't document the code, code the document!" I didn't know that there is a separation between Page and View; now I do, so thanks for that. The specific problem I had with my code was that with no named page in a fresh drawing simply adding a page, hiding everything, adding my new layer, adding the copy of the selected component and updating the page left an apparently mangled drawing because there was still only one page visible and it no longer had the main model visible. I can see that going down well with anyone trying out a new plugin! As a workaround I've made it add a default new page before adding my 'real' new page so that at least there is no nasty surprise.
  • Integration tool by using paste in place

    15
    0 Votes
    15 Posts
    271 Views
    N
    oh ok! Thanks to all ! I understand now
  • Move or Transform group found using entityByName() script??

    4
    0 Votes
    4 Posts
    112 Views
    L
    Okay, I managed to move entire array of groups however my project didn't save and because I did it after days of trial and error I can't now recreate my snippet but maybe someone knows how I can move that array of groups to another place (if I could get this first step again i should be able to get the rest). I'm pretty sure I used tranformation to get destination but can't figure it out. Please help!!
  • FTP zip file upload

    8
    0 Votes
    8 Posts
    843 Views
    J
    Wow! This is thorough! I can't thank you enough for your insights. You've given me several paths to take as a solution to this. If I can convince users of the plugin to use a full Ruby library and install it, that will limit the number of hoops needed to pass through. Having a prerequisite library doesn't sound all that bad now that it can be easily suggested to potential users of a plugin. Thanks a Million, Dan. I'll keep the community updated on what I go with.
  • Given a [x,y,z] delete a text note. Need help, Solved

    8
    0 Votes
    8 Posts
    355 Views
    dukejazzD
    Its a new day and I tried the code again. the code works! Thanks TIG on Fri Jun 01, 2012 6:35 am #first note written some min early..... Sketchup.active_model.entities.add_text "Text note 1",(Geom::Point3d.new(x1,y1,z1)) #-Given a [x,y,z] delete a text note. #erase note 1 Sketchup.active_model.active_entities.to_a.each{|e| e.erase! if e.is_a?(Sketchup::Text) and e.point==Geom::Point3d.new(x1,y1,z1) } #-Thus Given a [x,y,z] delete a text note...Solved by TIG #New note 2 written by it self Sketchup.active_model.entities.add_text "Text note 2",(Geom::Point3d.new(x1,y1,z1)) Ya! Ho!
  • Determine User Operating System

    4
    0 Votes
    4 Posts
    146 Views
    Dan RathbunD
    I have collected some links to Platform differences in the [ Code Snippets ] index.
  • Plugin beachballs seemingly randomly on first load

    7
    0 Votes
    7 Posts
    287 Views
    M
    @stuarth said: Hi I'm seeing a strange issue with a plugin I built in OS X. The first time it's run after loading SketchUp it will occasionally beachball. Not every time, and there's no special action taken on the first run that would explain its behavior. If it runs successfully the first time, it will run without problem again in the same session. Has anyone seen a similar problem? Where would you start to debug it? Mac "beachballs" differently regardless of your plugin. I have a lot of plugins and the time to load is "variable". Sometimes it beachballs for a while, sometimes not. It's almost like there is a cache somewhere, that is emptied after a while. It seems the first time I load SU in a while it takes more time, then it goes faster. Not as clear cut but kind of. So the correlation may not be with YOUR plugin. That said however, careful for loose ends as that will greatly lengthened the beachballing in general (make the short one long and the long one longer)
  • How to Write variable value into test.txt file

    8
    0 Votes
    8 Posts
    797 Views
    I
    I got it!!!! file.open works fine in webconsole, but inside script box dont! becouse open method is private.. so this is the code File.send(:open,'c:\foo.txt', 'wb') {|f| f.write $f } send "force" access to the method open. i think script box try to access File class and has no access. Sorry for my english i hope you guys understand and tnx for the help.
  • How to unload a .so file?

    18
    0 Votes
    18 Posts
    1k Views
    W
    @dan rathbun said: @wikii said: @dan rathbun said: How are you doing on the so file version situation ?? I ask the author of the plugin.He told me that plugin use degist.so from 1.8. Well they need to update the plugin, as SketchUp 8 on Win32 uses Ruby v1.8.6-p287 ... Thank you! He told me he will.
  • Script to bring all components from library into SU model

    23
    0 Votes
    23 Posts
    666 Views
    S
    As we say in the west country "Thats the badger mi babber!!" Works a treat now TIG - brilliant! Thanks again for ALL your help with this and you patience
  • [code] Cleanup After execute_script

    4
    0 Votes
    4 Posts
    1k Views
    Dan RathbunD
    And in Chris' edition.. if a developer wanted to avoid being cleaned up, he need only set an id attribute on the script object.
  • [Code] Ruby LOAD PATHs script (Win32) : ver 3.0.1

    19
    0 Votes
    19 Posts
    15k Views
    Dan RathbunD
    @26delta said: This creates an interesting problem. The error was introduced by the Rayelectron package which works with a file named "win32api.so". Somehow, in all the confusion, my Win32API.so file got overwritten by win32api.so. The files are identical, but differently named. Obviously the problem was created by whomever in the "Rayelectron" project, decided it would be a good idea (NOT!) to create an extension with the same name as a standard Ruby library source object file. (Because most Operating Systems are case-aware, but case tolerant... the OS will treat the filename the same, no matter how a command or shortcut may have the text 'cased'.) BUT.. internally, the require method (for some reason...,) will only load a file if it matches casewise the part of function name following "Init_" I always wondered why the programmers did not just copy the function a few times and rename it, thus: // C function Init_Win32API(){ init(); } function Init_WIN32API(){ init(); } function Init_win32API(){ init(); } function Init_win32api(){ init(); } The only good thing from this is that a hacker/pirate cannot "steal" (violate copyright,) an so file by renaming it. ~
  • Ruby code to extract watermark

    15
    0 Votes
    15 Posts
    3k Views
    A
    You can actually display watermarks. model = Sketchup.active_model opts = model.rendering_options opts['DisplayWatermarks'] = true/false Yep, there is no function to get/set watermark image, though there is actually a way around it. "Watermarks are part of a Style. You would have to have a preset Style with the watermark, and change the Style with the API." - quote by Dan. Create a style or two, add watermarks to each, and set them via Ruby API: styles = Sketchup.active_model.styles styles.selected_style = styles['Style Name'/style index#] Reference: Watermark via Ruby API
  • Hole plugin

    18
    0 Votes
    18 Posts
    235 Views
    N
    ahahah AHAHAHAHAHA !!! Thank you thomthom !! It works great !!! Many many many .... (ctrl+C, ctrl+V) ... many thanks !!
  • Here's another mystery to me

    10
    0 Votes
    10 Posts
    225 Views
    thomthomT
    @michaelv said: that seems to be the illogical logic of what is happening. Welcome to the world of SketchUp Ruby API scripting!
  • Given a x,y,z location to move a selected group help! solved

    4
    0 Votes
    4 Posts
    231 Views
    dukejazzD
    Thank you, Sdmitch for your help History v1.1 May 27 -fix move iteration problems scaleGroupFloat_dj Ver 1.1 Copyright 2012, May 27 DukeJazz: James Cochran http://forums.sketchucation.com/viewtopic.php?f=323&t=45254&p=404860#p404860 My final form #sents ss =Sketchup.active_model.selection if ss.empty? then UI.messagebox ("Please Select. a goup.");return end sents = [];ss.each{|e|sents.push(e)} #_API____Geom::move! new_transformation entity_group=Sketchup.active_model.active_entities.add_group(sents) Geom::Transformation.new [x1,y1,z1] entity_group.move!(Geom::Transformation.new [x2,y2,z2]) entity_group.explode
  • Layer Names to Array

    13
    0 Votes
    13 Posts
    334 Views
    K
    I use webconsole.rb Copyright (C) 2006 Jim Foltz and have not looked for updates. Keith
  • Detecting duplicate components

    7
    0 Votes
    7 Posts
    124 Views
    Dan RathbunD
    @tim said: @dan rathbun said: Also if you have the DynamicComponents extension loaded, it adds some scaling methods to Group and ComponentInstance. Undocumented Geom::Transformation methods? ... If it is only added by an extension, I imagine I'd have to check that it exists and is active on the target system. if the DC extension is loaded, Then: ` defined?($dc_observers) >> global-variable defined?(DCObservers) >> constant` The keyword defined? returns nil (so evals false,) if the arg is undefined. And further if the DC extension is loaded: Geom::Transformation.method_defined?(:rotx) %(#008000)[>> true] %(#000000)[As well as:] roty rotz xscale yscale zscale Sketchup::ComponentInstance.method_defined?(:scaled_size) %(#008000)[>> true] %(#000000)[As well as:] local_transformation last_scaling_factors unscaled_size %(#000000)[(and one that only the DC extension should call:] set_last_size %(#000000)[)] .
  • Tricky Behavior project_to_line method

    7
    0 Votes
    7 Posts
    226 Views
    Dan RathbunD
    We all know the API dictionary needs an overhaul. I will agree it should mention that an array for arg2 will be converted to a Geom::Vector3d

Advertisement