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

    [Code] ComponentInstance-add_entities v1.9

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

      I reported this Mac bug here... I hope outliner test will be positive...

      Frenglish at its best !
      My scripts

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

        v1.3 is here http://www.sketchucation.com/forums/scf/viewtopic.php?p=145009#p145009
        IT has an unneeded initial 'require ...' removed: otherwise it's unchanged...

        TIG

        1 條回覆 最後回覆 回覆 引用 0
        • M 離線
          Matt666
          最後由 編輯

          Hi TIG.
          I start to play with your cool function!
          Just one bug for the moment, line 139. group.definition, and no definition function for groups.
          I think you didn't copy the function in the script... 😉

          class Sketchup;;Group
          	def definition
          		return self.entities[0].parent
          	end
          end	
          

          Frenglish at its best !
          My scripts

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

            Matt = thanks for pointing this out - I had 'group.definition' load from a separate ruby - that I hadn't posted...
            I've now added it to this file for the avoidance of doubt...

            v1.4 now here: http://www.sketchucation.com/forums/scf/viewtopic.php?p=145009#p145009

            Being able to get a group's definition is very useful in many other cases...

            TIG

            1 條回覆 最後回覆 回覆 引用 0
            • H 離線
              HPW
              最後由 編輯

              So now we have this great addition to the toolset, what is the best way of delivery?
              The file gets copied into the Plugins-Directory.

              What should our own installer should do?
              Check the existence of the file and install it if not present?
              Check date and install it if a newer version is available?

              Can the ruby-code check if the method is installed?
              If not use a copy installed in the own subfolder?

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

                @unknownuser said:

                The file gets copied into the Plugins-Directory.
                Your own installer should check the existence of the file and install it if not present, BUT also check any existing file's modification-date and install if you have a newer version.

                Yes to all, this is the best way for all plugins...

                TIG

                1 條回覆 最後回覆 回覆 引用 0
                • A 離線
                  AlexMozg
                  最後由 編輯

                  Method 'group.definition'....
                  More correct would be the code:

                  
                  class Sketchup;;Group
                     def definition
                        self.entities.parent
                     end
                  end
                  
                  

                  Because, when group is empty
                  there is an error at the use of code: self.entities[0.parent]
                  The group may be empty soon after its inception.
                  For example:

                  group = Sketchup.active_model.active_entities.add_group
                  definition = group.definition
                  

                  Request to replace a code on more correct, because I use this method in the developments.
                  ❗

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

                    Following AlexM's point I have adjusted to code to avoid empty group errors...
                    v1.5 is now here... http://www.sketchucation.com/forums/scf/viewtopic.php?p=145009#p145009

                    TIG

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

                      An oversight has been corrected...

                      v1.6 all definition.behavior(s) now fully copied across. 20090702 download it from... http://forums.sketchucation.com/viewtopic.php?p=145009#p145009

                      TIG

                      1 條回覆 最後回覆 回覆 引用 0
                      • H 離線
                        HPW
                        最後由 編輯

                        I run into a problem when I use add_entities from a startup-ruby.
                        The code line:

                        @kombi_group_sel_def.instances[0].add_entities(@kombi_group_list)
                        
                        

                        throws an error : undefined method `parent' for nil:NilClass

                        My ruby (zAutostart.rb) loads after the ComponentInstance-add_entities.rb

                        When I disable the call in my ruby and start the command from the console it runs without problems.

                        1 條回覆 最後回覆 回覆 引用 0
                        • thomthomT 離線
                          thomthom
                          最後由 編輯

                          Are you sure you have an instance of that definition in your model?

                          Thomas Thomassen — SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          1 條回覆 最後回覆 回覆 引用 0
                          • H 離線
                            HPW
                            最後由 編輯

                            @thomthom said:

                            Are you sure you have an instance of that definition in your model?

                            Yes, because when I outcomment my call and type it in the console after start-complete it works.

                            Therefor I build just a workaround:

                            
                             wsh = WIN32OLE.new('Wscript.Shell')
                             if wsh.AppActivate(skpbasename+".skp - SketchUp")
                              sleep(1)
                              wsh.SendKeys('{F2}')
                              sleep(1)
                              wsh.SendKeys('convert_acad_import{ENTER}')
                             end
                            
                            

                            Seems that ruby's on startup have problems to use other stuff from other startup-rubys.

                            1 條回覆 最後回覆 回覆 引用 0
                            • thomthomT 離線
                              thomthom
                              最後由 編輯

                              @hpw said:

                              Seems that ruby's on startup have problems to use other stuff from other startup-rubys.

                              Hm.. maybe you're calling a ruby that isn't loaded. Have you added an require statement for all the rubys you depend on?

                              Thomas Thomassen — SketchUp Monkey & Coding addict
                              List of my plugins and link to the CookieWare fund

                              1 條回覆 最後回覆 回覆 引用 0
                              • H 離線
                                HPW
                                最後由 編輯

                                Cannot be true, because the error come from inside the add_entities-code.
                                Otherwise the error would tell about unknown method.

                                1 條回覆 最後回覆 回覆 引用 0
                                • thomthomT 離線
                                  thomthom
                                  最後由 編輯

                                  Maybe things aren't ready immediately when SU loads the plugins...
                                  Have you tried using a timer to delay the execution of your script instead of having to send keystrokes`?

                                  Thomas Thomassen — SketchUp Monkey & Coding addict
                                  List of my plugins and link to the CookieWare fund

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

                                    require 'toggleWindows.rb' ?

                                    TIG

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • H 離線
                                      HPW
                                      最後由 編輯

                                      @thomthom said:

                                      Maybe things aren't ready immediately when SU loads the plugins...
                                      Have you tried using a timer to delay the execution of your script instead of having to send keystrokes`?

                                      I tried a 'sleep' with some diferent values without any success.

                                      @tig said:

                                      require 'toggleWindows.rb' ?

                                      I had it yet for closing the outliner.
                                      With my workaround it is working fine now.
                                      (Automated DWG-Creation and SKP-Conversion(Acad-Blocks to SU-DC with non-editable prop) in a Batch process.)

                                      1 條回覆 最後回覆 回覆 引用 0
                                      • thomthomT 離線
                                        thomthom
                                        最後由 編輯

                                        @hpw said:

                                        I tried a 'sleep' with some diferent values without any success.

                                        sleep prevents everything else to process. If you use a timer you allow the rest to continue processing.

                                        Thomas Thomassen — SketchUp Monkey & Coding addict
                                        List of my plugins and link to the CookieWare fund

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

                                          v1.7 is now available - now any Attribute Dictionaries the Definition might have are kept when the Definition is reworked with the new entities...

                                          http://forums.sketchucation.com/viewtopic.php?p=145009#p145009

                                          .

                                          TIG

                                          1 條回覆 最後回覆 回覆 引用 0
                                          • H 離線
                                            HPW
                                            最後由 編輯

                                            Using 1.7 instead of 1.6 gives me this error:

                                            @unknownuser said:

                                            convert_acad_import
                                            Error: #<NoMethodError: C:/Programme/Google/Google SketchUp 7/Plugins/ComponentInstance-add_entities17.rb:188:in add_entities': undefined method each' for nil:NilClass>
                                            C:/Programme/Google/Google SketchUp 7/Plugins/ComponentInstance-add_entities17.rb:188

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

                                            Advertisement