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

    Taking a model to particular coordinates

    Scheduled Pinned Locked Moved Developers' Forum
    44 Posts 5 Posters 1.6k 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.
    • B Offline
      borg.stef
      last edited by

      it shows this message : The extension 3ds is not allowed.

      😞

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

        Don't worry about the example 3ds [but you could 'zip' that type of file]... I've found the problem. 3ds files import but expect you to pick an insertion point - some file type imports don't... I'm thinking how to circumvent this...

        TIG

        1 Reply Last reply Reply Quote 0
        • B Offline
          borg.stef
          last edited by

          Thanks for your time...you know I'm new to ruby I don't know these details...just built programs from what i found on the net..thanks!

          1 Reply Last reply Reply Quote 0
          • B Offline
            borg.stef
            last edited by

            i can't seem to make this thing work 😒

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

              No problem... "God loves a trier..."
              Here's a version that does work !
              I've never had to do this myself and I have written hundreds of scripts - so we all have things to learn πŸ˜’
              It now imports the 3ds file and places one instance at random, then adds one at the origin [0,0,0].
              It deletes the original one instances[0] and leaves the next one and then moves it by x/y values you have set at the start...

                  model = Sketchup.active_model
                  x=0 ### set x and y as needed...
                  y=10.m
                  defs=model.definitions.to_a
                  machine = "C;\\Temp\\trial.3ds"
                  model.import(machine,true)
                  defa=model.definitions.to_a - defs ### what you just added
                  defn=defa[0]
                  defn.instances[0].erase!
                  tr=Geom;;Transformation.new(ORIGIN)
                  obj=model.active_entities.add_instance(defn, tr)
                  pt=Geom;;Vector3d.new(x, y, 0)
                  tr=Geom;;Transformation.translation(pt)
                  obj.transform!(tr)    
              
              

              We all learn! πŸ˜„

              TIG

              1 Reply Last reply Reply Quote 0
              • B Offline
                borg.stef
                last edited by

                wow this actually worked....only that z is high up not 0..

                1 Reply Last reply Reply Quote 0
                • Rich O BrienR Offline
                  Rich O Brien Moderator
                  last edited by

                  Is this a 3ds importer that doesn't need you to place the model after importing? Or what is it?

                  Download the free D'oh Book for SketchUp πŸ“–

                  1 Reply Last reply Reply Quote 0
                  • B Offline
                    borg.stef
                    last edited by

                    rich, it imports a model and instantly takes it to particular coordinates dictated by you!

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

                      The code as it stands adds a component-instance based on the 3ds file at the origin [0,0,0]... after all of the kerfuffle.
                      It then moves it by the defined x & y values, the z isn't changed at all.
                      IF the original object is not z=0, then it simply stays where it is in the 3ds file ???
                      There are ways to move all of the definitions geometry to z=0 BUT that's not the original request ?
                      Please check the 3ds's geometry and the SKP's for similarities if x=0 & y=0...

                      TIG

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

                        @unknownuser said:

                        Is this a 3ds importer that doesn't need you to place the model after importing? Or what is it?

                        This 3ds importer [built-in] DOES require you to place it BUT my cludged work-around does work... just about πŸ˜’

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • Rich O BrienR Offline
                          Rich O Brien Moderator
                          last edited by

                          Can it place the 3ds file by lowest point of bounding box centre at 0,0,0? I'm not at pc to check this out?

                          Download the free D'oh Book for SketchUp πŸ“–

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

                            @unknownuser said:

                            Can it place the 3ds file by lowest point of bounding box centre at 0,0,0? I'm not at pc to check this out?

                            Yes it could... BUT currently it simply moves it in x/y...
                            If I'm asked the right questions I might give the right answers... πŸ˜‰

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • B Offline
                              borg.stef
                              last edited by

                              How can the model alwayx go to z = 0?

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

                                First off... do the code as before, but leave x=0 and y=0.
                                What is the z ?
                                If that's known then add the -z in Vector3d.new(x, y, -z)
                                It should fix it.
                                BUT IF it's not easily known then perhaps use z=obj.bounds.min.z
                                and then re-transform! the obj using a new vector of (0,0,-z)...........

                                TIG

                                1 Reply Last reply Reply Quote 0
                                • Rich O BrienR Offline
                                  Rich O Brien Moderator
                                  last edited by

                                  @unknownuser said:

                                  If I'm asked the right questions I might give the right answers

                                  Audible sigh.....

                                  Download the free D'oh Book for SketchUp πŸ“–

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

                                    @unknownuser said:

                                    @unknownuser said:

                                    If I'm asked the right questions I might give the right answers

                                    Audible sigh.....
                                    BUT we will sort this out [eventually... πŸ˜’ ]

                                    TIG

                                    1 Reply Last reply Reply Quote 0
                                    • GaieusG Offline
                                      Gaieus
                                      last edited by

                                      @tig said:

                                      @gaieus said:

                                      And you have all the powers to move any topic belonging there, TIG!
                                      πŸ˜„
                                      I know but hopefully, this is now 'dead' so moving it now seems a waste of time... πŸ˜’

                                      Ah yes, so the topic has grown to 3 pages ever since.
                                      πŸ˜‰
                                      Anyway, looking forward to the "doh" moment (not as if I understood any of the discussion here - maybe except for Rich's gibbering)
                                      πŸ˜’

                                      Gai...

                                      1 Reply Last reply Reply Quote 0
                                      • Rich O BrienR Offline
                                        Rich O Brien Moderator
                                        last edited by

                                        Aaah, look who's cheered up. Did you find your little unwelcome friend?

                                        Download the free D'oh Book for SketchUp πŸ“–

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

                                          @gaieus said:

                                          @tig said:

                                          @gaieus said:

                                          And you have all the powers to move any topic belonging there, TIG!
                                          πŸ˜„
                                          I know but hopefully, this is now 'dead' so moving it now seems a waste of time... πŸ˜’

                                          Ah yes, so the topic has grown to 3 pages ever since.
                                          πŸ˜‰
                                          Anyway, looking forward to the "doh" moment (not as if I understood any of the discussion here - maybe except for Rich's gibbering)
                                          πŸ˜’

                                          The announcement of the demise of the topic was a little premature [to paraphrase Mark Twain [again]]...
                                          There's also the PMing that you don't see πŸ˜’

                                          TIG

                                          1 Reply Last reply Reply Quote 0
                                          • B Offline
                                            borg.stef
                                            last edited by

                                            This programm is actually making me crazy. What I am doing is that Matlab gives me a list example like this in a text file.
                                            milling
                                            500 (x axis)
                                            400 (y axis)
                                            0 (rot)
                                            drilling
                                            600
                                            .....etc
                                            and then I use this text file in the program above. However it gives me an error: Failed import. strangely enough when I remove the first name and its coordinates and rotation and moves the second one in its place, it works. Do you think this is a problem about the matlab code or sketchup?

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

                                            Advertisement