sketchucation logo sketchucation
    • Login
    1. Home
    2. scottlininger
    3. Posts
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 7
    • Posts 168
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Mac WebDialog & Flash

      Tomasz,

      Unfortunately, we do not have a solution at this time, and I can't predict how long it might be before we do.

      Thank you so much for all your help in identifying and tracking down this problem! I wish I had a simple solution.

      One idea, if you're in the mood for exploring some more, might be to see if AS3 could communicate with javascript via URL fragment identifier, like myFlashpage.html#some_custom_data. You may be able to set/get data via that string after the #.

      A related idea might be to see if you can set the URL of a hidden iframe via flash and have JS read that URL to pull out some encoded data.

      Cheers,

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: Negative scaling/mirroring

      Pyroluna,

      That's an interesting idea. I'll add a note to our issue tracker.

      I definitely see scenarios where scale would be more intuitive than a length...

      Thanks!

      posted in Dynamic Components
      scottliningerS
      scottlininger
    • RE: Resizing a DC via Ruby?

      Jim,

      Couple of things I had to do to get the behavior you want:

      1. Rebuild the DC so there is no naked geometry. I turned the "post" into a subcomponent that sets its LENZ to the parent LENZ. (Naked geometry in DCs is particularly dumb. When in doubt, make everything a subcomponent instead of faces and edges.)

      2. Add a couple lines of code that store the unscaled size onto the component instance before you redraw it. This gives the plugin the information it needs to scale correctly after the import.

        model = Sketchup.active_model
        entities = model.entities
        selection = model.selection
        ins = selection[0]
        new_post = model.definitions.load("c;/temp/PeggedPost_noNakedGeometry.skp")
        ins.definition = new_post
        lenx, leny, lenz = ins.unscaled_size
        ins.set_last_size(lenx, leny, lenz)
        $dc_observers.get_latest_class.redraw_with_undo(ins)
      

      Cheers, πŸ˜„

      posted in Dynamic Components
      scottliningerS
      scottlininger
    • RE: Mac WebDialog & Flash

      Thomasz,

      So I spent some time trying to get it to work, and I'm having similar problems on the Mac.

      I can get AS2 to work fine using FSCommand and SetVariable, but not AS3.

      I'll file a bug internally and try to learn some more. Keep me posted if you make any progress.

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: Mac WebDialog & Flash

      @thomthom said:

      @unknownuser said:

      I know that this is possible. I'm doing it inside the Get Photo Textures dialog in SU 7.2.

      ... point two? ❓

      Doh. Silly typo... I meant 7.1 πŸ˜‰

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: Mac WebDialog & Flash

      Tomasz,

      I know that this is possible. I'm doing it inside the Get Photo Textures dialog in SU 7.2. A flash movie sends data to JS and thereby to ruby. But it's a lot of code and I just haven't had time to figure out a minimal example.

      It could be that I was using the old FSCommand bridge instead of ExternalInterface...

      I'll take a look as soon as I can. In the meantime, if you're charging to get it working you might do some searching on FSCommand and see if that's a method that would suit your needs.

      Are you doing all of this locally, or is there some web-hosted content involved?

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: Mac WebDialog & Flash

      Tomasz,

      The problem isn't the flash at all. You just need to change this line...

      @dlg.set_url html_path
      

      To this...

      @dlg.set_file html_path
      

      The string that find_support_file returns is a file path, not a url. When I changed the line in your sample, I saw your Flash movie. πŸ˜„

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: Vertices and selection

      Alex,

      You can transform vertices by using Entities.transform_entities method.

      There is no built in way to get at something by id. You could populate a hash yourself, though. Something like...

      entities_by_id = {}
      some_id = nil
      for ent in Sketchup.active_model.entities
        entities_by_id[ent.entityID.to_s] = ent
        some_id = ent.entityID.to_s
      end
      
      # And then get back to stuff like this
      my_last_ent = entities_by_id[some_id]
      
      

      Cheers,

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: Mac WebDialog & Flash

      Tomasz,

      Flash has worked for me in a ruby webdialog on the mac. We use it in the Get Photo Texture extension, for example.

      How are are initializing your flash movie? Are you using javascript to create the <object><embed> tags? Or manually writing them into your html? If you're using JS, it might be trying to detect that flash is installed or some such, and getting confused about which browser it is running in.

      Simple test: create a WebDialog and point it to some public websites that run flash, like Streetview or YouTube.

      The JS code that has worked for me in the past is something like...

      <body onload="onLoad()">
      <script>
      function onLoad() {
        var path = 'myMovie.swf';
        var html = ['<object classid="clsid;d27cdb6e-ae6d-11cf-96b8-444553540000" ',
            'codebase="http://download.macromedia.com/pub/shockwave/cabs/',
            'flash/swflash.cab#version=9,0,0,0" ',
            'id="flash">',
            '<param name="allowScriptAccess" value="always" />',
            '<param name="allowFullScreen" value="false" />',
            '<param name="movie" ',
            'value="', path, '" />',
            '<param name="quality" value="high" />',
            '<param name="scale" value="noscale" />',
            '<param name="swLiveConnect" value="true" />',
            '<param name="salign" value="lt" />',
            '<param name="wmode" value="transparent" />',
            '<param name="bgcolor" value="#ffffff" />',
            '<embed src="', path, '"',
            '  quality="high" scale="noscale" swLiveConnect="true" salign="lt"',
            '  wmode="transparent" bgcolor="#ffffff"',
            '  style="position;absolute; z-index;5"',
            '  name="myFlash" align="middle" allowScriptAccess="always"',
            '  allowFullScreen="false" type="application/x-shockwave-flash"',
            '  pluginspage="http://www.macromedia.com/go/getflashplayer" />',
            '</object>'];
        document.getElementById('someDiv').innerHTML = html.join('')
      }
      </script>
      

      Let me know if that helps. It could be some security stuff, too, but let's start with this... πŸ˜„

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: Move child component in dynamic component

      Hello Dan! Sorry I missed this post. Here are two solutions to your problem. (I'm sure there are others, too.)

      1. Instead of moving the "sub" DCs with Ruby and asking the parent to redraw, have the subDCs position themselves based off of some custom attributes in the parent. You script would set these attributes, like sensor_1_x to 5.9, sensor_2_y to 25.0, etc. Then when you fire a redraw, the children will puppet themselves properly. (But, if the user tries to manually reposition them, it will ignore them... maybe not what you want.)

      2. Add a couple of more lines to you existing script...

      selection = Sketchup.active_model.selection
        view = Sketchup.active_model.active_view
      
        for i in 0..10
          puts selection[0].definition.entities[0].transformation.origin
          selection[0].definition.entities[0].transformation = Geom;;Transformation.translation([0.m, -1.m, 0.m])
          puts selection[0].definition.entities[0].transformation.origin
      
          # DCs keep track of their "last size" in some attributes.
          # This allows them to infer whether they have been scaled
          # manually by the user.
          #
          # In this case, you are changing the bounding box of the DC
          # by moving its subparts, and so it thinks that the scale
          # tool has been applied, and is making some bad repositioning
          # decisions based on that. Doh!
          #
          # These are the methods that the DC plugins uses to tell the DC
          # to "recalculate" its bounding box. Do this after your translation
          # and things are happier. (I can explain more if you want...)
          lenx, leny, lenz = selection[0].unscaled_size
          selection[0].set_last_size(lenx, leny, lenz)
      
          $dc_observers.get_latest_class.redraw_with_undo(selection[0])
          view.refresh
          sleep(1)
      
      posted in Plugins
      scottliningerS
      scottlininger
    • RE: [ruby doc] Model - undocumented methods

      @dan rathbun said:

      Is it ( Model.get_product_family ) really to be considered as deprecated ??

      Dan,

      Now that the get_product_family method has been added to the API docs and our internal unit test suite, it is no longer at danger of being removed. In 2008 the thing existed, of course, but since it wasn't documented there was some doubt about its future.

      It's so cute and quirky, we've decided to keep it. πŸ˜‰

      (I agree with you that it's attached to the wrong object, BTW. But once a method's in the wild it's really, really hard to change it.)

      Cheers,

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: New API doc - typos and questions

      @dan rathbun said:

      @unknownuser said:

      As soon as we close out the issues in this thread, I will remove it from the forums.

      Don't you dare!

      πŸ˜„

      All great points, Dan. There is a valuable historical record here, and there are a lot of posts that aren't simple docs corrections. No reason to remove it. More what I'm getting at is to make it clear where different kind of posts are best shared, as you said. This is the community's site, not mine, so ultimately it's the community's decision! πŸ˜„

      Cheers,

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: New API doc - typos and questions

      New notes should be posted directly to the api site. That way folks visiting the docs can see them immediately and can vote on the most helpful ones. As soon as we close out the issues in this thread, I will remove it from the forums.

      πŸ˜„

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: New API doc - typos and questions

      Yes, you can finally comment directly in the API docs (scroll to the bottom of most of the pages). Hopefully this will help the community share their insights into the API.

      We are still working through the list of comments from this thread, so don't feel as if you must copy and paste your (excellent) feedback into the site. But you can if you want to. πŸ˜„

      Cheers,

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: Prince IO Sketchup Game Demo

      Hmm. Todd's cleaned up version was working on mac. I'll take a look...

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: Dynamic Component Redraw

      Hey guys,

      There is no observer for DC redraw. I did think of a trick you could try, however.

      The "functions" that can be called as part of a DC formula are defined in a class called DCFunctionsV1. Any protected methods inside that class are discovered by the DC plugin by reflection and can be called inside a DC spreadsheet formula. Since every formula is run each time a DC is redrawn, you can call your own ruby code this way.

      For example, let's make a new DC spreadsheet function that shows a messagebox:

      1. Save this script as customDCFunctions.rb into your plugins directory.
      # Adds custom DC spreadsheet functions.
      class DCFunctionsV1
        
        protected
        
        # Shows a messagebox from DC formula.
        # Example Formula; =messagebox("something")
        def messagebox(param_array)
          val = param_array[0]
          UI.messagebox(val.to_s)
          return val
        end
      
        # Returns first thing, alphabetically, in list of params.
        # Example Formula; =firstAlpha("bob", "cal", "amy", "dan")
        def firstalpha(param_array)
          return param_array.sort.first
        end
      
      end
      
      1. Restart SU, and create a new DC. Add a custom attribute called "onredraw" (or whatever you want) with the following formula:
      =messagebox("Hello")
      

      Whenever that DC is redrawn (manipulate it with the scale tool, for example), you'll see your messagebox. You could just as easily call some more complex code. People who have your script installed will get the behavior you want. People without it won't, of course, so you'd need to be careful about that.

      Hope that gets you started. πŸ˜„

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: New API doc - typos and questions

      Santa's got nothing on me. πŸ˜‰

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: New API doc - typos and questions

      Thanks for all the feedback, Dan! Keep 'em coming.

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: Importing and placing components

      Not sure if this would do the same, but you might try view.refresh.

      http://code.google.com/apis/sketchup/docs/ourdoc/view.html#refresh

      Cheers,

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • RE: Setting dynamic attributes to expressions?

      Thom,

      There is not an overview. The internal methods were never intended to be an API, so mucking with them could lead to corrupted DCs. Go forth with caution.

      If there are specific things you'd like to accomplish, let me know and I can try to share snippets.

      posted in Developers' Forum
      scottliningerS
      scottlininger
    • 1 / 1