sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    DC components and ruby

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 349 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B Offline
      BillW
      last edited by

      Just to pass on my experiences.

      I thought I would convert one of my plugins to use DC components which look perfect for editing afterwards. The DC components in question allow scaling in only one axis.

      On calling the plugin, I copy into the current file a virgin DC component (if necessary), place as the user has specified with screen hits and edit the DC to match the length required as shown in the code below. Note: I built the DC in centimeters which requires some mod to the value passed, although looking at it now I guess values are always passed in inches.

        # set DC attributes
        compdef = comp.definition 
        ad = compdef.attribute_dictionary "dynamic_attributes"
        divlen = (ad["_lengthunits"] == "CENTIMETERS") ? 2.54 ; 1.0
      
        shedlen = ((@numbays * @baysize) + (@curoutloff * 2)).to_cm / divlen
        ad["_leny_nominal"] = shedlen.to_s
        $dc_observers.get_latest_class.redraw_with_undo(comp) 
      
      

      All fine and dandy as the user can use the scale tool to modify the length.

      The problem is that the DC component mechanism puts such a heavy load on building the geometry that what
      is pretty much instantaneous with my SU6 version which does the build within the plugin, the DC component takes 20 seconds to build. I suspect there is a bucket load of observers to manage.

      I am now thinking of reverting back to my previous version and see if I can reuse the DC Component>Component Options code to have a version specific to my plugins which at least allows value changes.

      For the guys at Google, in a perfect world, I would like to have a simple way of incorporating a Component>Component Options dialog (maintained by Google) into my code with hooks for calling my draw code. In my time, I have done a lot of Vectorworks plugin development and by way of comparison, setting up a plugin interface is very easy.

      1 Reply Last reply Reply Quote 0
      • scottliningerS Offline
        scottlininger
        last edited by

        That's a great idea, Bill. I've added it to the feature request list.

        Cheers,

        • Scott Lininger
          SketchUp Software Engineer
          Have you visited the Ruby API Docs?
        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement