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

    Align component boundingbox to global axis

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 301 Views 3 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.
    • K Offline
      ktkoh
      last edited by

      I am rewriting my plugin [Comp2LayerSenes] that creates scenes for parts for making dimensioned drawings. It currently calls the makeorthoviews but I am writing my own drawing views section. A problem that is not currently addressed is how to display parts drawn at an angle to the global axis ( for example a corner brace ) Currently the part is copied to a new layer in its original orientation and then the other views are created by rotating copies of the part. See attached drawing [problem scene]. Currently the user would see it was not correct and delete all but 1 view, rotate that view to align with the global axis, then recreate the views with one of the plugin's features. See attached drawing [corrected scene].

      What I would like the program to do would be inspect the boundingbox corners and if they are not aligned with the global axis to transform the part into the aligned position before creating the additional views.

      Having read what I could find here with the search function I have not found much help.

      Any suggestions?

      Keith


      Test Angle Comp2SceneExample.skp

      1 Reply Last reply Reply Quote 0
      • M Offline
        mptak
        last edited by

        I will piggyback on this post to ask a related question both of which will be solved with linear algebra I am sure. How can you take a group's transformation and determine which way it is pointing (the components of its internal positive x) and its up (the components of its internal z)? I think this is just a middle step to the above problem where one calclulates the "basis vectors" of the bounding box by taking differences of coordinates of the corners and then normalizes them.

        Probably bad form here to answer my own subquery but what the hey. The following code snippet demonstrates that for a particular component instance of an unscaled component or group, the basis vectors (component x, component y and component z) are just the [0-2], [4-6], and [8-10] positions of the component transformation. In my own particular case I am trying to add lift, drag and thrust values to objects in sketchyphysics based on the attitude of the object.

        ` model = Sketchup.active_model
        entities = model.entities
        selection = model.selection
        #this assumes only one entity in the drawing
        #which would be a group or component
        #the basis vectors for the component definition
        #are calculated into xvdc,yvec and zvec
        #and then drawn at the origin
        t=entities[0].transformation.to_a
        orig=[0,0,0]
        xvec=[]
        yvec=[]
        zvec=[]
        for i in 0..2 do
        xvec.push(t[i])
        yvec.push(t[i+4])
        zvec.push(t[i+8])

        end
        puts xvec
        puts yvec
        puts zvec
        entities.add_line(orig,xvec)
        entities.add_line(orig,yvec)
        entities.add_line(orig,zvec)`

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

          I AM CANCELING MY REQUEST FOR THIS HELP:

          After looking at posts on this subject I realize that the bounding box and selection box are 2 separate things and I am going to abort the attempt to rotate the component and align it with the global axis before making the drawing views. For most ww projects there are few parts for which the user will need to correct the drawing views and the plugin already has a feature that makes this easy so I am going to stick with that solution.

          Keith

          1 Reply Last reply Reply Quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            So just to verify, are either of you still asking any questions?, or did you both solve your own issues? 😄

            Chris

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

            1 Reply Last reply Reply Quote 0
            • M Offline
              mptak
              last edited by

              You are a good man Chris. ....as Rosanne Rosana Dana once so eloquently said.....never mind.

              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