Moving a section plane using ruby

is it possible?

copilot says yes:
"# Sélectionner le plan de section
model = Sketchup.active_model
entities = model.active_entities
section_planes = entities.grep(Sketchup::SectionPlane)

if section_planes.any?
section_plane = section_planes.first

Définir une nouvelle transformation pour déplacer le plan

translation = Geom::Transformation.new([10, 0, 0]) # Déplace de 10 unités sur l’axe X
section_plane.transform!(translation)

puts “Le plan de section a été déplacé.”
else
puts “Aucun plan de section trouvé dans le modèle.”
end
"
but it is AI hallucination

sketchup documentation says transform! is only for groups and components

so is there another way?

I haven’t tried it, but maybe SectionPlane#set_plane is what you want.

1 Like

i tried: the example in sketchup documentation:

"model = Sketchup.active_model
entities = model.active_entities

Grab the first section plane from the model.

sp = entities.grep(Sketchup::SectionPlane).first
sp = sp.set_plane my_plane_array"

gives an error…

"“Wrong number of arguments for plane”

That sounds like you didn’t create plane array correctly. What did my_plane_array have in it? It should be an Array of one Geom::Point3d and one Geom::Vector3d, or an Array of four numbers that “give the coefficients of a plane equation”.

Edit: in case that vague API doc statement isn’t clear:

  • if you pass an Array of [Geom::Point3d, Geom::Vector3d] the point is any point on the plane, and the vector is the normal vector to the plane.
  • if you pass an Array of four numbers, they are the coefficients [a,b,c,d] of the 3d plane equation ax+by+cz = d
1 Like

Yes, the AIs often “invent” methods and functions that do not exist.

They also think that anything posted to a public forum is gospel truth, instead of checking official sources like API documentation.


Also, @glro please post code correctly in the forum:

i have tried this:

entities = model.active_entities

pt1 = Geom::Point3d.new
pt2 = Geom::Point3d.new(0,0,10)

vec = pt1 - pt2
my_plane_array = Array.new

my_plane_array.push pt1
my_plane_array.push vec

if entities.grep(Sketchup::SectionPlane).length >=1
	# Grab the first section plane from the model.
	sp = entities.grep(Sketchup::SectionPlane).first
	sp = sp.set_plane my_plane_array
	else
	UI.messagebox "no section plane in the model"
end

it works:
from this


to this

the section plane is moved to the origin

by changing pt1 coordinates, it would be possible to move the section plane; i would never have understood that alone, thank you

1 Like

I found another way to move a section plane, n this case along a points cloud.

create a scene with the points cloud, add a section plane on the other side of the points cloud, inactivate it and save the scene.

create a second scene, activate the section plane and save the scene.

make sure the animation parameters are set with a transition between scenes


also make sure that, in ‘scan essentials’ points cloud manager window , show a box of points around section plane, is on.

Now when you switch scenes, a slice of points is shown, moving from trom one side to the other

https://vimeo.com/1078904633?share=copy