sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    How to receive correct coordinates of all vertexes?

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 461 Views 2 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.
    • A Offline
      AlexMozg
      last edited by

      How to receive correct coordinates of all vertexes in selection, including all the nested groups and components.
      Multiplication of transformations far not always gives correct result, especially if for any nested group(component) of an axis do not coincide with an axis of group(component) in which it is enclosed.

      I was trying so:

      
      ...
      @lines = []
      extract_lines(group.entities, (Geom;;Transformation.new))
      ...
      def extract_lines(ents, tr)
      	ents.each do |e|
      		if e.typename == "Edge"
      				line = [e.vertices[0].position, e.vertices[1].position]
      				line[0] = tr * line[0]
      				line[1] = tr * line[1]
      				@lines << line
      		elsif e.typename == "Group"
      			extract_lines(e.entities, (e.transformation * tr))
      		elsif e.typename == "ComponentInstance"
      			extract_lines(e.definition.entities, (e.transformation * tr))
      		end
      	end
      end
      
      

      But here the relative positioning of groups concerning a model is not considered.
      There are ideas as it to make?

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

        Hi Alex,

        Your sample code looks fine for me. Could you post a simple model showing wrong coordination's readout?

        Tomasz

        Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

        1 Reply Last reply Reply Quote 0
        • A Offline
          AlexMozg
          last edited by

          Correctly it will be whew:

          
          ...
          @lines = []
          extract_lines(group.entities, group.transformation)#!!!
          ...
          def extract_lines(ents, tr)
             ents.each do |e|
                if e.typename == "Edge"
                      line = [e.vertices[0].position, e.vertices[1].position]
                      line[0] = tr * line[0]
                      line[1] = tr * line[1]
                      @lines << line
                elsif e.typename == "Group"
                   extract_lines(e.entities, (tr * e.transformation))##!!!
                elsif e.typename == "ComponentInstance"
                   extract_lines(e.definition.entities, (tr * e.transformation))#!!!
                end
             end
          end
          
          

          and it works!
          😍

          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