sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Moving a compo-instance by z

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 238 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.
    • artmusicstudioA Offline
      artmusicstudio
      last edited by

      hi,

      i have a component-instance somewhere in space and i want to copy it in vertical direction.

      how can i say to the transformation, that the movement is only Z and in the position of the original component?
      (the position comes from a mouse-selection, so is not pre-calculated, but given...)

      the transformation allows to input a 3d point [0,0,height_delta],
      but i cannot retrieve the x,y of the original component ....

      
      my_component = group.to_component
            defn = zf_component.definition
      	#defn.name = "name"
      						
      		for groupcopy in 1..my_amount
      						
      		edge = model.entities.add_line([0,0,0],[0,0,@height*groupcopy])
      		vector = edge.start.position.vector_to(edge.end.position)
      		distance = edge.length
      		vector.length = distance
      		toppoint_1 = [0,0,@height*groupcopy]
      		nullpoint = [0,0,0]
      	        toppoint_2 = vector[1]
      						
      	componentinstance =
      	entities.add_instance(defn, [ 0,0,0]) # ???? HOW TO DEFINE THE POSITION OF THE ORIGINAL COMPONENT-DEFINITION TO BECOME A COPY AT THE SAME POSITION ???
      				
      	new_transformation = Geom;;Transformation.new([ 0,0,@height*groupcopy])
       	componentinstance.move! new_transformation
      
      

      thanx
      stan


      Zwischenablage01.png

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

        You have a component definition [ defn].
        You have an instance of it [ inst1].
        That instance has a transformation [ tr1=inst1.transformation].
        That transformation has an origin [ org=tr1.origin] - i.e. its 'insertion point'.
        You make a new transformation based on that:
        tr2=Geom::Transformation.new([org.x, org.y, org.z+z_increment])
        Where the ' z_increment' is the amount by which you want to move the copy upwards - either in inches or a Length.
        You add the copy thus:
        inst2=inst1.add_instance(defn, tr2)

        TIG

        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