sketchucation logo sketchucation
    • Login
    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!
    ⚠️ Update | Sketchucation Tools 5.0.8 released with licensing improvements and bugfixes Download

    [Code] ComponentInstance-add_entities v1.9

    Scheduled Pinned Locked Moved Developers' Forum
    33 Posts 5 Posters 26.3k Views 5 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.
    • TIGT
      TIG Moderator
      last edited by

      @thomthom said:

      Is there a way to know if the Outliner is open? If so, can't you use Sketchup.send_action 21513 to toggle the Outliner off and have it work on both platform?

      It would be good if it were cross-platform BUT the "send_action 'number'" only works on a PC...
      If someone has a Mac fix please let me know...
      The toggleWindows script lets you 'rollup' any open window by name on a PC...

      TIG

      1 Reply Last reply
      Reply Quote 0
      • TIGT
        TIG Moderator
        last edited by

        Version 1.1
        It can sometimes BugSplat if the Outliner window is open when it runs...
        so it can now be forced to rollup first - using Jim's code ideas - you'll need
        'toggleWindows.rb' and 'Win32API.so' - sorry it's for Windows only - Mac users ???
        If you are on a PC and don't install toggleWindows.rb/Win32API.so then it'll still work
        BUT please close the Outliner to avoid BugSplats !

        Version 1.1 20090401
        AT-ComponentDefinition-delete.rb version used.
        Recursive version now keeps layer/material.
        Possible Outliner window rollup added.

        You should download the following files:
        ComponentInstance-add_entities.rb
        AT-ComponentDefinition-delete.rb [ http://www.sketchucation.com/forums/scf/viewtopic.php?p=145255#p145255 ]
        for PC users the zip file contains 'toggleWindows.rb' and 'Win32API.so'...

        They are added to the first page in this thread...[ http://www.sketchucation.com/forums/scf/viewtopic.php?p=145009#p145009 ]

        TIG

        1 Reply Last reply
        Reply Quote 0
        • TIGT
          TIG Moderator
          last edited by

          Version 1.2 is here [ http://www.sketchucation.com/forums/scf/viewtopic.php?p=145009#p145009 ]
          It now has the 'definition.delete' code built-in as that is now greatly simplified thanks to AlexM's insights...
          I'm awaiting Scott's feedback on cross-platform Sketchup.send_action(21513) etc - I don't think they are Mac friendly... However if they are we can make the v1.1 Outliner crash work-around for PC and Mac...

          .

          TIG

          1 Reply Last reply
          Reply Quote 0
          • thomthomT
            thomthom
            last edited by

            Does Mac also have the issue with the open Outliner? It's not specific to the way Windows redraws stuff?

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

            1 Reply Last reply
            Reply Quote 0
            • TIGT
              TIG Moderator
              last edited by

              @thomthom said:

              Does Mac also have the issue with the open Outliner? It's not specific to the way Windows redraws stuff?

              Don't know - are there any Mac users out there getting BugSplats with the Outliner being open during script runs that affect groups/instances ???
              Any Mac users doing 'send_action' - please try to open/close the Outliner and try Sketchup.send_action(21513) etc and report back...
              It would be good to have extended common 'send_actions' for both PC and Mac - I know that some 'numerical' ones don't work on Mac...

              TIG

              1 Reply Last reply
              Reply Quote 0
              • thomthomT
                thomthom
                last edited by

                I have an old Mac Mini at home I can test the send_actions on.
                Not sure if it's reliable to test the Outliner issue due to it's age and lack of power...

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

                1 Reply Last reply
                Reply Quote 0
                • TIGT
                  TIG Moderator
                  last edited by

                  @thomthom said:

                  I have an old Mac Mini at home I can test the send_actions on.
                  Not sure if it's reliable to test the Outliner issue due to it's age and lack of power...

                  Thanks - Scott's taking his time coming back... I suspect it's not going to be straight forward...

                  TIG

                  1 Reply Last reply
                  Reply Quote 0
                  • M
                    Matt666
                    last edited by

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

                    Frenglish at its best !
                    My scripts

                    1 Reply Last reply
                    Reply Quote 0
                    • TIGT
                      TIG Moderator
                      last edited by

                      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 Reply Last reply
                      Reply Quote 0
                      • M
                        Matt666
                        last edited by

                        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 Reply Last reply
                        Reply Quote 0
                        • TIGT
                          TIG Moderator
                          last edited by

                          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 Reply Last reply
                          Reply Quote 0
                          • H
                            HPW
                            last edited by

                            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 Reply Last reply
                            Reply Quote 0
                            • TIGT
                              TIG Moderator
                              last edited by

                              @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 Reply Last reply
                              Reply Quote 0
                              • A
                                AlexMozg
                                last edited by

                                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 Reply Last reply
                                Reply Quote 0
                                • TIGT
                                  TIG Moderator
                                  last edited by

                                  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 Reply Last reply
                                  Reply Quote 0
                                  • TIGT
                                    TIG Moderator
                                    last edited by

                                    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 Reply Last reply
                                    Reply Quote 0
                                    • H
                                      HPW
                                      last edited by

                                      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 Reply Last reply
                                      Reply Quote 0
                                      • thomthomT
                                        thomthom
                                        last edited by

                                        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 Reply Last reply
                                        Reply Quote 0
                                        • H
                                          HPW
                                          last edited by

                                          @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 Reply Last reply
                                          Reply Quote 0
                                          • thomthomT
                                            thomthom
                                            last edited by

                                            @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 Reply Last reply
                                            Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better πŸ’—

                                            Register Login
                                            • 1
                                            • 2
                                            • 2 / 2
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement