Moving a compo-instance by z
-
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_transformationthanx
stan

-
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)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement