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!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

    [Plugin] Boolean helper update 08122011

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

      You don't need to 'select-all' in the code, just use model.entities.to_a as the collection of things to transform in the scale up/down - that way everything gets caught in the scaling up/down changes.

      A screen-note wouldbe useful to remind you that you have scaled... then the code can erase it when you've scaled down...

      TIG

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

        👍 I like where this is going!

        3D Printing with SketchUp Book
        http://goo.gl/f7ooYh

        1 條回覆 最後回覆 回覆 引用 0
        • liquid98L 離線
          liquid98
          最後由 編輯

          @ TIG

          yeah, "select all" is user language.

          model.entities.to_a = programmers language 😉

          Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

          1 條回覆 最後回覆 回覆 引用 0
          • liquid98L 離線
            liquid98
            最後由 編輯

            Working on the feedback of the scale action (X = one time scaled up XX =two times etc.)
            I have some variable (array) filled with X characters. Its called $xfeedback

            To put it on screen I use:

            @xnote = model.add_note $xfeedback.to_s, 0.01, 0.02.

            That works. But to update it I would like to delete the screen-note entity before showing it again like this:

            model = Sketchup.active_model entities = model.active_entities entities.erase_entities(@xnote) if @xnote

            I know to delete something with erase_entities it has to be an array. So I tried also this:
            entities.erase_entities(@xnote.to_a) if @xnote

            but it's not working.

            Code structure is like this:

            <span class="syntaxdefault"><br />require </span><span class="syntaxstring">'sketchup.rb'<br /><br /></span><span class="syntaxdefault">$xfeedback </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">[</span><span class="syntaxstring">"X"</span><span class="syntaxkeyword">,</span><span class="syntaxstring">"X"</span><span class="syntaxkeyword">,</span><span class="syntaxstring">"X"</span><span class="syntaxkeyword">,</span><span class="syntaxstring">"X"</span><span class="syntaxkeyword">]</span><span class="syntaxdefault">  </span><span class="syntaxcomment"># Test situation presuming 4 times scaled up.<br /><br /></span><span class="syntaxdefault">module Test<br /><br />class Scaledown<br />    <br /><br />def initialize</span><span class="syntaxkeyword">()</span><span class="syntaxdefault"> <br />         </span><span class="syntaxcomment"># Scaling action<br /></span><span class="syntaxdefault">         <br />     model </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br />     entities </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities<br />     if entities</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">!=</span><span class="syntaxdefault"> nil<br />    <br />    l </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> $xfeedback</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_i </span><span class="syntaxkeyword">-</span><span class="syntaxdefault"> 1  <br />    $xfeedback</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">delete_at</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">l</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    <br />     model </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br />    entities </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_entities<br />    entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">erase_entities</span><span class="syntaxkeyword">(@</span><span class="syntaxdefault">xnote</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> if </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">xnote<br /><br />    </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">xnote </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_note $xfeedback</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_s</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0.01</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0.02<br /><br /><br /><br />    else <br />    nil<br />    end</span><span class="syntaxcomment">#if<br /><br /><br /><br /><br /><br /><br /></span><span class="syntaxdefault">end</span><span class="syntaxcomment">#def<br /></span><span class="syntaxdefault">end</span><span class="syntaxcomment">#class<br /></span><span class="syntaxdefault">end</span><span class="syntaxcomment">#module             &nbsp;</span><span class="syntaxdefault"></span>
            

            Please help

            Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

            1 條回覆 最後回覆 回覆 引用 0
            • TIGT 離線
              TIG Moderator
              最後由 編輯

              Shouldn't it be @@xnote ?
              Anyway, something like...
              entities.erase_entities(@xnote)
              should work... or use [@xnote] to make it an array, if it MUST be one (?)...
              However, this will work too
              @xnote.text='newtext'
              to change it ???

              TIG

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

                may not be of any help, but

                when you create a screen note SU creates a new Text entity (each time)

                "#Sketchup::Text:0x1ef0a000", "#Sketchup::Text:0x1f0131a4", etc...

                so I guess if you capture those you can delete them.

                john

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

                1 條回覆 最後回覆 回覆 引用 0
                • liquid98L 離線
                  liquid98
                  最後由 編輯

                  Hello friends,

                  I made some improvements to the boolean-helper plugin:

                  • it scales everything in the model
                  • it gives feedback on the total scale-factor
                  • it auto zooms to the model-extents.

                  But I need some help:

                  When the model is scaled up, feedback is generated in the form of a sketchup::text
                  entity. My problem: when the the model is deleted (not select all), the text entity remains on the screen ( entities[0]) while there is no model.

                  So I have to monitor that.

                  How do I do that??

                  I came up with this solution:

                  <span class="syntaxdefault">if  entities</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">class </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Text </span><span class="syntaxkeyword">&&</span><span class="syntaxdefault"> entities</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> nil<br />         </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">xnote </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> entities</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault">         </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">notetext </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">"   "<br /></span><span class="syntaxdefault">         </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">xnote </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_note </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">notetext</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0.01</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 0.99</span>
                  

                  But if I put this code in booleanhelper.rb it only runs when the user invokes it.
                  While it has to run all the time.

                  I've also read something about Sketchup::EntityObserver. Is that relevant in this case???

                  Thnx for your help

                  Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

                  1 條回覆 最後回覆 回覆 引用 0
                  • mitcorbM 離線
                    mitcorb
                    最後由 編輯

                    Well, for those who work in Imperial units==inches, it would be cool if you could set the scale factor to overcome the small faces problem but type in the VCB the same numbers as you would if you had not scaled it. Basically, to do away with a bunch of mental math for every value. When finished, reset the scale factor to 1. There's a flaw here somewhere??

                    I take the slow, deliberate approach in my aimless wandering.

                    1 條回覆 最後回覆 回覆 引用 0
                    • liquid98L 離線
                      liquid98
                      最後由 編輯

                      @mitcorb said:

                      Well, for those who work in Imperial units==inches, it would be cool if you could set the scale factor to overcome the small faces problem but type in the VCB the same numbers as you would if you had not scaled it.

                      Hi mitcorb,

                      That's a nice idea, but I have no clue to achieve it..

                      Indeed, the script I'm working on scales up as much as you want and than scales everything down to scalefactor 1.
                      In scaled up state there's a screen-note reference to the actual scale-factor.

                      Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

                      1 條回覆 最後回覆 回覆 引用 0
                      • TIGT 離線
                        TIG Moderator
                        最後由 編輯

                        Liquid98

                        About the screen-text...
                        Do you mean that it disappears if there is suddenly no other model geometry ?
                        As soon as any new geometry is added it should reappear ??
                        I don't see the problem ? On the rare occasions when the user has deleted the entire model [and why would they do that?] the scaling becomes irrelevant anyway, so they can just delete it ?

                        To spot if the only thing left is your screen-text and then erase with an observer to watch for this use

                        
                        class OnlyScreenTextLeftEntitiesObserver < Sketchup;;EntitiesObserver
                          def onEraseEntities(entities)
                            return if entities[1]
                            entities[0].erase! if entities[0].class==Sketchup;;Text and entities[0].text==$xfeedback.to_s ###??
                          end
                        end
                        # Attach the observer - do this once at startup
                        Sketchup.active_model.entities.add_observer(OnlyScreenTextLeftEntitiesObserver.new)
                        
                        

                        TIG

                        1 條回覆 最後回覆 回覆 引用 0
                        • liquid98L 離線
                          liquid98
                          最後由 編輯

                          Hi TIG,

                          @tig said:

                          I don't see the problem ? On the rare occasions when the user has deleted the entire model [and why would they do that?] the scaling becomes irrelevant anyway, so they can just delete it ?

                          I admit, that situation won't occur very often. But I only want to tackle it to learn new stuff... 😛

                          When I put your code in a .rb file, like this:

                          <span class="syntaxdefault">    require </span><span class="syntaxstring">'sketchup.rb'<br /><br /></span><span class="syntaxdefault">    class OnlyScreenTextLeftEntitiesObserver </span><span class="syntaxkeyword"><</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">EntitiesObserver<br />      def onEraseEntities</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">messagebox </span><span class="syntaxstring">"OK"<br /></span><span class="syntaxdefault">     end<br />    end<br />  <br />   <br />    Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_observer</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">OnlyScreenTextLeftEntitiesObserver</span><span class="syntaxkeyword">.new)</span><span class="syntaxdefault"> </span>
                          

                          and then start sketchup, create some entities and delete them,

                          Nothing happens... Why??

                          Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

                          1 條回覆 最後回覆 回覆 引用 0
                          • TIGT 離線
                            TIG Moderator
                            最後由 編輯

                            Well if it did work every time you erased something you'd get the messagebox...
                            The EntitesObserver is known to be buggy... if we did get it to work and erased an entity within it it'd probably crash anyway - so my snippet probably wasn't the best idea 😒
                            How about using a selectionObserver...onBulkChange() - you select the things and then erase them and the selection changes... and then looking at model.entities if no [1] and [0] meets test erase it ...
                            http://code.google.com/apis/sketchup/docs/ourdoc/selectionobserver.html

                            TIG

                            1 條回覆 最後回覆 回覆 引用 0
                            • liquid98L 離線
                              liquid98
                              最後由 編輯

                              I updated the booleanhelper plugin! Please see the first post of this topic.

                              Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

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

                                hi,

                                I believe I just exposed a bug, doing another testhttp://forums.sketchucation.com/viewtopic.php?f=180&t=38858&p=354541#p354541

                                when I have 'auto paint tool' Mac preference set, your twee tekst and LEEEEEG message boxes pop up every time I select or delete something even though I wasn't using your tool.

                                appears to be "Sketchup::SelectionObserver" related.

                                I'd rather use this then that, but I'd like the option of both...

                                cheers

                                john

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

                                1 條回覆 最後回覆 回覆 引用 0
                                • liquid98L 離線
                                  liquid98
                                  最後由 編輯

                                  Hi John,

                                  Just download and install latest version -see first post of this topic.

                                  Good luck!

                                  Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

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

                                    cheers,
                                    I'll let you know if I have any issues,,,

                                    john

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

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • C 離線
                                      CT4
                                      最後由 編輯

                                      Thank you Thank you Thank you. I model small parts for RC aircraft and run into so many problems when I try and lathe them or intersect them. This fixes all of the problems.

                                      1 條回覆 最後回覆 回覆 引用 0
                                      • liquid98L 離線
                                        liquid98
                                        最後由 編輯

                                        It's always nice to hear that my script helped you out! Apparently it works also on a Mac; never tested it 🎉 🎉

                                        Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

                                        1 條回覆 最後回覆 回覆 引用 0
                                        • cottyC 離線
                                          cotty
                                          最後由 編輯

                                          Thank you for this helpful plugin!

                                          my SketchUp gallery

                                          1 條回覆 最後回覆 回覆 引用 0
                                          • sboupS 離線
                                            sboup
                                            最後由 編輯

                                            @liquid98 said:

                                            This is my modest contribution to the community:

                                            Booleanhelper

                                            The Boooleanhelper plug-in lets you quickly scale up and down your model.
                                            This is especially useful for those people who use Sketchup for 3d printing.
                                            Performing boolean operations or lathe operations on small models (mm size) is problematic in Sketchup, because Sketchup doesn't handle small faces very well.
                                            By scaling up the model these problems disappear. After all operations are done
                                            you can scale down your model to its original dimensions.
                                            Also useful to close small holes in your model.

                                            Your opinions and suggestions are welcome!

                                            Features:

                                            • Visual feedback on scale-factor.
                                            • Scale down at once.
                                            • It is possible to save your work, and scale down later. (feedback not yet provided)
                                            • Auto zoom extents.

                                            Installation:
                                            Open the zipfile and copy booleanhelper.rb and the folder called Booleanhelper into the SU plugins directory.

                                            Have fun!!

                                            If you have problems with unsolicited messageboxes, please download the latest version below:

                                            Wonderfull. Thanks ☀

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

                                            Advertisement