Moving a Line or Edge
-
I am trying to move an edge of a solid after I have push pulled it into shape and added an extra line, however the Transform! method does not seem to work:
h_pt1 = [xvalue, @Hx1, @Hy1] h_pt2 = [xvalue, @Hx2, @Hy2] h_pt3 = [xvalue, @Hx3, @Hy3] h_pt4 = [xvalue, @Hx4, @Hy4] h_pt5 = [xvalue, @Hx5, @Hy5] h_pt6 = [xvalue, @Hx6, @Hy6] h_pt7 = [xvalue, @Hx7, @Hy7] group3 = @truss_component2.entities.add_group entities3 = group3.entities group3.description = "Hip Rafter" group3.name = "Hip Rafter" new_face3 = entities3.add_face h_pt1, h_pt2, h_pt3, h_pt4, h_pt5, h_pt6, h_pt7 new_face3.pushpull plydepth midline = xvalue + @Ply*0.5 lp1 = [midline, @Hx5, @Hy5] lp2 = [midline, @Hx6, @Hy6] linebottom = entities3.add_line lp1, lp2 # Translates to vertex of fascia lb_trans = Geom::Transformation.new([0, -@Plyhalf, 0]) linebottom.transform! lb_trans -
An Edge is an entity and can not be transformed by .transform! use .transform_entities instead.
mod = Sketchup.active_model ent = mod.active_entities sel = mod.selection vue = mod.active_view h_pt1 = [xvalue, @Hx1, @Hy1] h_pt2 = [xvalue, @Hx2, @Hy2] h_pt3 = [xvalue, @Hx3, @Hy3] h_pt4 = [xvalue, @Hx4, @Hy4] h_pt5 = [xvalue, @Hx5, @Hy5] h_pt6 = [xvalue, @Hx6, @Hy6] h_pt7 = [xvalue, @Hx7, @Hy7] group3 = @truss_component2.entities.add_group entities3 = group3.entities group3.description = "Hip Rafter" group3.name = "Hip Rafter" new_face3 = entities3.add_face h_pt1, h_pt2, h_pt3, h_pt4, h_pt5, h_pt6, h_pt7 new_face3.pushpull plydepth midline = xvalue + @Ply*0.5 lp1 = [midline, @Hx5, @Hy5] lp2 = [midline, @Hx6, @Hy6] linebottom = entities3.add_line lp1, lp2 # Translates to vertex of fascia lb_trans = Geom;;Transformation.new([0, -@Plyhalf, 0]) #linebottom.transform! lb_trans entities3.transform_entities(lb_trans,linebottom) -
As Sam says, transformations only apply to containers like component-instances, groups and images.
A Point3d does not have a transformation, BUT you can usepoint.transform!(transformation)it relocate it.Basic entity objects - like vertices, edges and faces - have to be transformed using:
objects_parent_entities.transform_entities(a_transformation, [array_of_objects])
this works with any kind of transformation; or for a vector based 'translation':
objects_parent_entities.transform_by_vectors([array_of_objects], [array_of_vectors])
note that each object in the first array must have a matching vector in the second array...
Also if you are using the these to move say vertices, don't also include some edges or faces which use those vertices - otherwise the vector transformation will be done twice, with unexpected consequences...
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