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

    Set Vertex Position?

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 644 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.
    • A Offline
      alphanimal
      last edited by

      Hello!

      I was trying to manually set the Position of single Vertices.
      I was trying something like

      edge.start.position = Geom;;Point3d.new (10,20,30)
      

      but you cannot set the position on a vertex that way....

      any ideas?

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

        You've returned a point doing that. The end [or start] of an edge is returned as a vertex anyway. You need to 'transform' that vertex to move the the end/start of an edge...

        
        model=Sketchup.active_model
        ents=model.active_entities
        newendpoint=[12,34,56]  ### this is a new point
        end=edge.end   ### this is a vertex
        ents.transform_entities(newendpoint,end)  ### this moves the 'end' vertex
        
        

        this snippet will move the edge's start-vertex to newendpoint...

        TIG

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

          Thank you a lot!

          This works great...
          except two things πŸ˜„

          1. transforming with [12,34,56] will not set the position to these coordinates, but shift it by that vector. so if you want to set the position you will first have to calculate the offset and use this as the transformation

          2. if i'm shifting vertices inside a component things get weired... sketchup crashes all the time.

          What I actually want to do is round the coordinates of every Vertex in the whole model

          For a reason I dont know have all my edges been shifted (I often rotated the model in very small angles, this was nessecary to simplify modelling)
          So many edges lost their alignment on the axes and I cannot get them in the right place
          If I zoom in very close on corners I can see that the lines are slightly not on the right place. its just that I can see a small gap before I zoom into the Front clipping plane - so very small.

          My Ides war to round every Coordinate to an Integer value...

          I was never scripting sketchup before but I wanted to try this πŸ˜„

          here's my code:

          def execute_test
          	entities = Sketchup.active_model.entities
          	#Loop through all selected vertices
          	Sketchup.active_model.selection.each do |ent|
          		if(ent.kind_of? Sketchup;;Edge)
          			print ent.to_s+"\n"
          			#remember start and end vertex
          			es = ent.start.position
          			ee = ent.end.position
          			#transform each vertex
          			entities.transform_entities (Geom;;Point3d.new(es.x.round, es.y.round, es.z.round)-es), ent.start
          			entities.transform_entities (Geom;;Point3d.new(ee.x.round, ee.y.round, ee.z.round)-ee), ent.end
          
          		end
          	end
          end
          

          I substract the real vertex position from the rounded position to get the offset I need to align it

          I think I need some help πŸ˜• Sketchup crashes when I apply this inside a component with everything selected...
          some of the vertices are shifted far away, when I deselect them Sketchup crashes

          I attached the broken model.
          try setting edge color to "by axis". you'll notice that many edges are not aligned to the axes and theres nomthing you can do about it (i tried rotating the model, using the axis tool etc...

          thanks for every tip!!

          Daniel


          This is the model that is broken for some reason....

          1 Reply Last reply Reply Quote 0
          • fredo6F Offline
            fredo6
            last edited by

            I think you'd better use Transform by vector, since each vertex would have a different transformation. So you create a list of vectors for each vertex between the original point and the rounded points.

            Note that this may not work fine as Transforming elements in Sketchup follows the same rules as in the User Interface, allowing or not the transformation based on privileged direction.

            In my opinion, just rounding the coordinates of vertex will destroy the planarity of faces if you had some in your model.

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

              You are right, It destroys my faces... well it splits them into triangles but they stay planar... so I just have to delete the created lines manually. I can live with that

              But the bad thing is that rounding coordinates does not solve the problem I have...
              It seems to be a known bug! It happens with complex models when you often change the axes with the axis tool.

              I need some way to re-align edges to the axes (even their start and end-points are (almost) exactly on one axis, they are not recognised so)

              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