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

    Transform by vectors and Hash.

    Scheduled Pinned Locked Moved Developers' Forum
    12 Posts 5 Posters 303 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.
    • jolranJ Offline
      jolran
      last edited by

      Hi. Coming from this topic:

      http://sketchucation.com/forums/viewtopic.php?f=180&t=51263

      (BTW moderators, regarding that post. Since it was started regarding information about Group name = make_uniq. I would not mind deleting those last posts or perhaps move them here since discussion was headed towards solving a different unrelated problem?)

      Ok. to question.

      Wondering for best stategy using transform_by_vectors.

      I'm inside a for-loop adding groups to faces. The groups are all appended in a parentgroup.
      I have vertice transformations to apply to entities inside the groups.

      Recommendations says this should be performed in 1 big go, preferably after looping.

      Transform_by_vectors takes 2 arrays as arguments, ok. So I tried appending those while looping to 2 arrays verts and vecs.
      The problem is that if I don't loop the groups individually I get splats? πŸ˜•
      I.e this do not work. parentgroup.entities.transform_by_vectors( verts, vecs )
      (Remember parentgroup holds all the groups with contains the vertices.)

      So what is working is storing the groups, vertices and vectors in a Hash like so:
      Hash{group => [vertices, [vectors]}] . Note there can be many key, value pairs here.

      But I have to loop the groups again.

      
      for k,v in hash
         k.entities.transform_by_vectors( v[0], v[1] ) #
      end
      
      

      That works but I get very little performance gain compared to transforming inside the first big loop.

      I'll keep working on it, but if anyone has any tip I wouldent mind getting a push in the right direction. πŸ˜„
      I have a feeling that what I'm trying to do might not be practically possible the Ruby way.

      BTW. I have a counter inside the big loop. It starts counting fast and slows down and if many loops it stops counting and webdialog X(closebutton) becomes red. Signs of reccursion or just plain Sketchup freeze?

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

        hi may be of use... maybe not.
        whenI made a ruby to make the entire mac font library as 3d text in a row, it was painfully slow, but by breaking it into chunks solved that problem, dan helped me with the code, the original is in the same post
        http://sketchucation.com/forums/viewtopic.php?f=180&t=48761&start=30#p440763

        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
        • jolranJ Offline
          jolran
          last edited by

          Very interesting Driven.

          I have missed that topic completely during my searchs.

          It's bedtime early today, so I have a closer peak tomorrow.
          Thanks for the link.

          1 Reply Last reply Reply Quote 0
          • jolranJ Offline
            jolran
            last edited by

            Had a peek inside that topic and while it's very interesting reading I'm uncertain it will help me in this case?

            Refering to group make uniq! VS group name. It seems Group.name is a tad quicker.(horray!)
            BUT, creating many new groups is very costly. In fact it's nearly half of the calculationtime for my script at the moment. Adding entities are of course expensive, but the difference between using instances and new groups is enourmous.

            (A longshot: There is no way to do Matrice calculations that affect tapering in Sketchup ?
            I've gotten some shearing results when playing with the Matrix, but that's about it..)

            Biggest lag comes from transformation of vertices. Trying to bundle them do speed up things, but still far from satisfactory, and I doubt I'll ever get near any sufficient workable results..

            So problem A is since making groups uniq and transforming by vectors are all SU API methods I can not get any benefit from a C-extension I persume? (If I ever go that route..)

            Anyway I think I've made a big rookie misstake when preparing and gathering information for doing all in a big loop. But then again I don't if know slicing the code up will prevent from problem A? Confused right now πŸ˜•

            See if I can split up the code a little. Any suggestions would be appreciated.

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

              You can only transform in one Entities object at a time - you cannot combine transformations in multiple Entities objects.

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

              1 Reply Last reply Reply Quote 0
              • jolranJ Offline
                jolran
                last edited by

                Ah ok, you are refering to tapering, right ?

                I sent you PM.

                1 Reply Last reply Reply Quote 0
                • T Offline
                  Trogluddite
                  last edited by

                  @jolran said:

                  There is no way to do Matrice calculations that affect tapering in Sketchup ?

                  I don't know the API so well, but mathematically, the matrices would only be able to do what are known as "affine transformations", which have the property that lines which start out parallel with each other always remain parallel - so tapering would not be possible.

                  1 Reply Last reply Reply Quote 0
                  • jolranJ Offline
                    jolran
                    last edited by

                    @unknownuser said:

                    mathematically, the matrices would only be able to do what are known as "affine transformations"

                    That IS what I wondered. Bummer 😞

                    Whats the term for tapering? I've seen it being called "projective scaling". That is what I wanted to do to component instances anyway. Scaling one instance doesent affect the other and so on...

                    1 Reply Last reply Reply Quote 0
                    • Dan RathbunD Offline
                      Dan Rathbun
                      last edited by

                      @jolran said:

                      Whats the term for tapering? I've seen it being called "projective scaling". That is what I wanted to do to component instances anyway. Scaling one instance doesent affect the other and so on...

                      You CAN do this.. BUT each instance must be unique.

                      Imagine a "Box" component.

                      Insert two instances a few feet from one another.

                      If you edit one instance, you will affect the other because they both share the same definition, that "owns" the entities collection.

                      But select one of them, right-click and choose "Make unique" and it has it's own definition.
                      Now.. double-click it to enter it's edit-mode. Select the top face, and then choose the ScaleTool.
                      Hold down the CTRL key and click-drag one of the corner handles to taper the top face (about the center.)

                      πŸ’­

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • jolranJ Offline
                        jolran
                        last edited by

                        Yeah Dan thanks, sort of doing that in my code already..

                        But what i wished for was tapering one instance and it doesent affect the other and so on.

                        Now that apparently can't be done with current API, otherwise Fredoscale taper-mode probably wouldent exist.

                        Don't know if that sort of thing could be added to the API anyway since Sketchup is a surface modeler. Maybe need nurbs for this kind of behaviour ? πŸ˜•

                        Anyway getting OT on my own topic..

                        1 Reply Last reply Reply Quote 0
                        • Dan RathbunD Offline
                          Dan Rathbun
                          last edited by

                          @jolran said:

                          Don't know if that sort of thing could be added to the API anyway since Sketchup is a surface modeler. Maybe need nurbs for this kind of behaviour ? πŸ˜•

                          NO not now, because the vertice positions are part of the definition, and not part of the individual instance(s).

                          An interesting idea.

                          I'm not here much anymore.

                          1 Reply Last reply Reply Quote 0
                          • jolranJ Offline
                            jolran
                            last edited by

                            @unknownuser said:

                            NO not now, because the vertice positions are part of the definition, and not part of the individual instance(s).

                            Thanks for answering Dan.
                            It could be an useful addition to the API, IMO.

                            What confuses me is that we are moving the vertices when scaling the instance(s) using Sketchup normal scaling behavior. So why would it be different if doing a tapering ?

                            I know the calculations for tapering is much more complex, but...
                            Maybe there is need for some symmetry calculation I havent thought about.

                            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