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

Creating components from existing objects

Scheduled Pinned Locked Moved Developers' Forum
12 Posts 5 Posters 292 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.
  • T Offline
    thomthom
    last edited by 16 Aug 2012, 20:47

    Are your script also generating the geometry you want to place in the component? If so, then you should just add it directly to the component definition.

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

    1 Reply Last reply Reply Quote 0
    • S Offline
      sdmitch
      last edited by 17 Aug 2012, 01:41

      This seems to work.

      mod = Sketchup.active_model
      ent = mod.entities
      sel = mod.selection
      
      wgrp=ent.add_group ent.to_a #create a group containing all existing entities
      wcmp=wgrp.to_component #convert the group to a component/instance.
      wcmp.definition.name="World" #give it a name
      
      

      Nothing is worthless, it can always be used as a bad example.

      http://sdmitch.blogspot.com/

      1 Reply Last reply Reply Quote 0
      • A Offline
        ArunYoganandan
        last edited by 17 Aug 2012, 17:26

        @thomthom said:

        Are your script also generating the geometry you want to place in the component? If so, then you should just add it directly to the component definition.

        Hi Tom,

        The geometries are generated by the users as they go along. I'm trying to make this a tool so as and when the user switches to the tool, all of the currently existing models (except certain objects) become part of the miniature view

        1 Reply Last reply Reply Quote 0
        • A Offline
          ArunYoganandan
          last edited by 17 Aug 2012, 17:42

          @sdmitch said:

          This seems to work.

          mod = Sketchup.active_model
          > ent = mod.entities
          > sel = mod.selection
          > 
          > wgrp=ent.add_group ent.to_a #create a group containing all existing entities
          > wcmp=wgrp.to_component #convert the group to a component/instance.
          > wcmp.definition.name="World" #give it a name
          > 
          

          Ahhh! group to component! Thank you so much 😍

          1 Reply Last reply Reply Quote 0
          • A Offline
            ArunYoganandan
            last edited by 17 Aug 2012, 17:55

            Another question on a related note.

            Is there a way to set the Level Of Detail on the miniature component instance alone?
            It seems to be affecting performance with large models like castles and for the size at which I'm rendering the miniature, I couldn't care if its quality went down

            1 Reply Last reply Reply Quote 0
            • S Offline
              sdmitch
              last edited by 17 Aug 2012, 18:11

              There is always a way but at what cost. The code would no doubt expand from 3 lines to 3000.

              Nothing is worthless, it can always be used as a bad example.

              http://sdmitch.blogspot.com/

              1 Reply Last reply Reply Quote 0
              • T Offline
                TIG Moderator
                last edited by 17 Aug 2012, 19:55

                Beware... if ents is model.entities and that's not the current 'active_entities' context then ents.add_group(ents.to_a) or ents.add_group(model.selection.to_a) etc will Bugsplat!

                So... always ensure that the ents=model.**active_**entities and the objects you are trying to add to the new group are in the same context - hence the recommendation for 'selection' because the user can't manually select things that are not in the current active context...

                TIG

                1 Reply Last reply Reply Quote 0
                • A Offline
                  ArunYoganandan
                  last edited by 21 Aug 2012, 23:49

                  @tig said:

                  Beware... if ents is model.entities and that's not the current 'active_entities' context then ents.add_group(ents.to_a) or ents.add_group(model.selection.to_a) etc will Bugsplat!

                  So... always ensure that the ents=model.**active_**entities and the objects you are trying to add to the new group are in the same context - hence the recommendation for 'selection' because the user can't manually select things that are not in the current active context...

                  TIG thanks. Will keep that in mind

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    Dan Rathbun
                    last edited by 22 Aug 2012, 00:20

                    You might play with the Fog settings. Adjust the near and far clipping planes. (But this is really not LOD.)

                    I'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • A Offline
                      ArunYoganandan
                      last edited by 23 Aug 2012, 18:04

                      @dan rathbun said:

                      You might play with the Fog settings. Adjust the near and far clipping planes. (But this is really not LOD.)

                      Thanks Dan. Will give that a try

                      1 Reply Last reply Reply Quote 0
                      • A Offline
                        ArunYoganandan
                        last edited by 23 Aug 2012, 18:04

                        @sdmitch said:

                        There is always a way but at what cost. The code would no doubt expand from 3 lines to 3000.

                        I'm on a framerate sensitive medium, so anything I can do to improve frame rate would be useful. It would be great if you have any tips on how to set the LOD for the miniature.

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        1 / 1
                        • First post
                          11/12
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement