sketchucation logo sketchucation
    • 登入
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🔌 Smart Spline | Fluid way to handle splines for furniture design and complex structures. Download

    Drawing with GL

    已排程 已置頂 已鎖定 已移動 Developers' Forum
    24 貼文 4 Posters 1.5k 瀏覽 4 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • CadFatherC 離線
      CadFather
      最後由 編輯

      ..was trying to fit a 'rule of thirds' on the screen, but trying to avoid using styles.

      this is what i'm aiming at:

      ratio.jpg

      as plan B, i tried saving the current style as a variable, load my 'ratio style with the grid', and reload the previous style upon exit of the tool.

      Incidentally, i found no way to add a style that's already 'in model' - has to be from a saved file. (also no way to save a style to disk from ruby it seems). 😒

      1 條回覆 最後回覆 回覆 引用 0
      • D 離線
        driven
        最後由 編輯

        that's doable as a watermark...
        but, you need to generate the watermark to match the users viewport width/height...
        that's not as hard as it seems, you can use a webdialog with those as 'client' width/height...

        in the webDialog you add a html5 canvas to draw the grid...
        the blank canvas is centred on the page...
        its height is vph and it's width is 'paper' width [ vph x paper ratio ]...

        grid width is (canvas width minus line weights) ÷ 3
        height is (vph minus line weights) ÷ 3
        line weights e.g 0.5 x 5

        your body background color will show as page margins and the canvas bg needs to be white...

        once drawn, write the image to file then load it as a watermark...

        you need to make the white bg transparent, I'm not sure how on 'windose' from code...

        I think you can toggle watermarks from ruby, but it may need 2 scenes...

        I could dig out some similar code, but you might think it's unrelated...

        john

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 條回覆 最後回覆 回覆 引用 0
        • D 離線
          driven
          最後由 編輯

          heres a simple test to see if watermarks will do what you want...
          it just your drawgl grid as a watermark with a little tweak, so no dark margins
          to toggle

          
          Sketchup.active_model.rendering_options["DisplayWatermarks"]=false Sketchup.active_model.rendering_options["DisplayWatermarks"]=true
          

          and add this as background, use stretch...unzip first...

          is this along the right lines...

          learn from the mistakes of others, you may not live long enough to make them all yourself...

          1 條回覆 最後回覆 回覆 引用 0
          • CadFatherC 離線
            CadFather
            最後由 編輯

            thanks John, already did that though (screenshot above is a watermark).

            the problem with this system is that you are forcing a new style on the user: if the user has a sketchy style on, you cannot have the bars and keep the sketchy style. (in other words we cannot load watermarks without loading a style as well).

            that's why i mentioned about another route: find user current style > save it as variable > load the 'grid' style > restore user style from variable when finished.

            alas, no way to get the previous style back in. whether from the 'in model' style, or trying to save it to a temp directory and loading it back from there. (at least i found no info at all anywhere).

            PS least of all the api docs! 😲

            1 條回覆 最後回覆 回覆 引用 0
            • 1
            • 2
            • 2 / 2
            • 第一個貼文
              最後的貼文
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement