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!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Mac and Windows 'New Model' differences...

    Scheduled Pinned Locked Moved Developers' Forum
    17 Posts 4 Posters 1.7k Views 4 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.
    • sdmitchS Offline
      sdmitch
      last edited by

      I had already made the 'sel' change in my copy of the code.

      Like before, the file created on the desktop is the same for with_selection and empty_selection. With_selection leaves me with an empty Untitled model.

      I get no errors output to the RC.

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

      http://sdmitch.blogspot.com/

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        does finding the send actions work the same on a PC?

        i.e. if I set 'copy' as a Shortcut, and then run Sketchup.get_shortcuts the wording returned can be used as a send_action string?

        john

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

        1 Reply Last reply Reply Quote 0
        • D Offline
          driven
          last edited by

          I removed the previous send_action()'s but added in Sketchup.send_action('makeGroup:') which should work on both platforms...

          on a mac I get this, does it work the same on a PC?

          auto_create.gif

          ##########################################################################################
          # first is quicker if selection is empty?...
          def empty_selection
          	new_skp = File.expand_path("~/Desktop/john_test1.skp")
          	begin
          	  Sketchup.active_model.save_copy(new_skp) # [0.14629]
          	rescue # for un-saved original
          	  Sketchup.active_model.save(new_skp) # original closes [1.222455]
          	end
          	Sketchup.open_file(new_skp) #with save_copy() original stays open [1.920228]
          	Sketchup.active_model.rendering_options['BackgroundColor'] = 'red'
          end
          
          # faster than collecting and deleting unwanted items...
          def with_selection
          	new_skp = File.expand_path("~/Desktop/john_test2.skp")
           	sel = Sketchup.active_model.selection
          	ins = sel[0].to_component
          	defn = ins.definition
          	# named only to check if it's been undone...
          	defn.name = "Explode Me Later"
          	defn.save_as(new_skp)
          	# revert original
          	3.times {Sketchup.undo}
          	Sketchup.open_file(new_skp) # original stays open time depends on the selection size...
          	Sketchup.active_model.rendering_options['BackgroundColor'] = 'green'
          end
          
          def auto_create
          	t1 = Time.now
          	sel = Sketchup.active_model.selection
          	sel.empty? ? empty_selection ; with_selection
          	p time = Time.now - t1
          	UI.messagebox(time)
          end
          
          

          john

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

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

            Your undocumented:
            Sketchup.send_action("makeGroup:")
            doesn't work on [my] PC - BUT:
            Sketchup.send_action(21182)
            does work on [my] PC [but of course that doesn't work on MAC !]

            But if you are working with creating a group from a Selection, then you can use the cross-platform API methods, thus:
            group = Sketchup.active_model.active_entities.add_group( Sketchup.active_model.selection.to_a ); Sketchup.active_model.selection.add( group )
            which mimics those other platform specific 'send_actions' on either OS...

            TIG

            1 Reply Last reply Reply Quote 0
            • G Offline
              Garry K
              last edited by

              auto_create
              0.12499
              1

              I get a big red screen - that is all
              My default template is set to mm with a precision of 0.001

              1 Reply Last reply Reply Quote 0
              • D Offline
                driven
                last edited by

                cheers Tig, I may have gotten there eventually...

                this works on the mac as suggested...

                do I need to close the original on a PC for the new one to open with geometry and green background?

                it's driving nuts as every version I've tried runs on a mac, and each one has been faster that the last...

                # faster than collecting and deleting unwanted items...
                def with_selection
                	new_skp = File.expand_path("~/Desktop/john_test2.skp")
                 	sel = Sketchup.active_model.selection
                        group = Sketchup.active_model.active_entities.add_group( sel.to_a )
                        Sketchup.active_model.selection.add( group ) if sel.length > 0
                	ins = group.to_component
                	defn = ins.definition
                	# named only to check if it's been undone...
                	defn.name = "Explode Me Later"
                	defn.save_as(new_skp)
                	# revert original
                	3.times {Sketchup.undo}
                	Sketchup.open_file(new_skp) # original stays open time depends on the selection size...
                  # re-define for new skp...
                	Sketchup.active_model.rendering_options['BackgroundColor'] = 'green'
                end
                

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

                1 Reply Last reply Reply Quote 0
                • D Offline
                  driven
                  last edited by

                  @Garry, the template shouldn't matter...

                  I just can't figure out why you don't get the geometry...

                  This is just a tiny part of a working mac plugin that I'm now porting to PC...

                  on the mac it can grab 100 mixed items from a 1000 item file and cleanly add them to a new model...

                  one test file took 6 hrs to process and delete the 900 unwanted entities, where this take seconds...

                  john

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

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

                    On a PC an instance of SketchUp is opened for separate for each SKP.
                    On a MAC one instance of SketchUp opens all SKPs.
                    So on a PC, if you you use:
                    Sketchup.open_file("C:/users/tig/desktop/a.skp")
                    its opens that SKP file, BUT closes the current one !
                    But you could use:
                    UI.openURL("file:///#{full_path_to_skp}")
                    which, on a PC, will open the specified SKP in a new instance of SketchUp [and it'll probably work on a MAC, but then it'll be using the same SketchUp]...

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      driven
                      last edited by

                      @tig said:

                      ...But you could use:
                      UI.openURL("file:///#{full_path_to_skp}")
                      which, on a PC, will open the specified SKP in a new instance of SketchUp [and it'll probably work on a MAC, but then it'll be using the same SketchUp]...

                      it works exactly the same as open_file on a mac...

                      you can pass the new model to the next ruby method...

                      on a PC, I assume a new instance would need manual intervention to carry on to step 2 of any ruby script?

                      Are there ways around that?

                      I'm starting to see why 'component_edit_window' has so many observers...

                      john

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

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        driven
                        last edited by

                        @tig said:

                        ...
                        So on a PC, if you use:
                        Sketchup.open_file("C:/users/tig/desktop/a.skp")
                        its opens that SKP file, BUT closes the current one !
                        ...

                        on re-reading this and it may be all I need...

                        i.e. opens the new_skp [containing the selection] in the current ruby session...

                        Is that what happens?

                        keeping the original open isn't a requirement, in fact I'm wanting to preserve intact, and run my actual tool which is destructive on the copy/sub-set...

                        john

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

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

                          Yes, opening a second SKP in the same SketchUp preserves the current Ruby settings from the first SKP.

                          If you open up a second SketchUp, then the first SKP's Ruby set up is potentially in accessible.
                          Of course, in the first SKP you could write some 'defaults' out to SketchUp [i.e. into the PC Registry], and read those back in, while inside the second SKP, but you then need to load/run some code ?

                          TIG

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            driven
                            last edited by

                            cheers Tig,

                            the plugin runs my 'selector' tool after new_skp has been cleaned up...

                            the 'selector' can be scaled, rotated or moved before running the cuts...

                            any solids remain solids afterwards...

                            sixSectoins.gif

                            I need a PC version to attract more testers...

                            john

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

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

                            Advertisement