Why is a box deleted / Why is a box not a manifold?
-
Hi all,
Embarrassing simple questions (I think):
- The code underneath gives the message "bbx1 deleted!"
What is happening and how do I prevent it from being deleted? - The code underneath gives alse the message "bbx2 is not a manifold"
What is happening and how do I make it a manifold?
( I want to learn about boolean solid operations like union etc,... )
With kind regards,
Frank Brugman
bbxmax = Geom;;Point3d.new bbxmin = Geom;;Point3d.new bbxmin.x = 1000.mm bbxmin.y = 0.mm bbxmin.z = 0.mm bbxmax.x = 2000.mm bbxmax.y = 1000.mm bbxmax.z = 1000.mm boxpts = [] boxpts[0] = [bbxmin.x, bbxmin.y, bbxmin.z] boxpts[1] = [bbxmax.x, bbxmin.y, bbxmin.z] boxpts[2] = [bbxmax.x, bbxmax.y, bbxmin.z] boxpts[3] = [bbxmin.x, bbxmax.y, bbxmin.z] face1 = Sketchup.active_model.entities.add_face boxpts face1.reverse! face1.pushpull(bbxmax.z-bbxmin.z ) bbx1 = Sketchup.active_model.entities.add_group bbx1.entities.add_group face1.all_connected bbxmin.x = 2000.mm bbxmin.y = 0.mm bbxmin.z = 0.mm bbxmax.x = 3000.mm bbxmax.y = 1000.mm bbxmax.z = 1000.mm boxpts = [] boxpts[0] = [bbxmin.x, bbxmin.y, bbxmin.z] boxpts[1] = [bbxmax.x, bbxmin.y, bbxmin.z] boxpts[2] = [bbxmax.x, bbxmax.y, bbxmin.z] boxpts[3] = [bbxmin.x, bbxmax.y, bbxmin.z] face2 = Sketchup.active_model.entities.add_face boxpts face2.reverse! face2.pushpull(bbxmax.z-bbxmin.z ) bbx2 = Sketchup.active_model.entities.add_group bbx2.entities.add_group face2.all_connected if ( bbx1.deleted? ) UI.messagebox("bbx1 deleted!") end if ( not bbx2.manifold? ) UI.messagebox("bbx2 is not a manifold") end
- The code underneath gives the message "bbx1 deleted!"
-
Looking at it...
Sidenote: when using the Ruby API you create the group first then add the entities to the group. Inverse of what you do via the UI.
-
Another side note:
Instead of this:
bbxmin = Geom;;Point3d.new bbxmin.x = 1000.mm bbxmin.y = 0.mm bbxmin.z = 0.mm
it's much simpler to write:
bbxmin = Geom;;Point3d.new(1000.mm, 0.mm, 0.mm)
-
Right, so the deleted? thing happen because you make the face first, then try to move it into another group - a nested group event.
Rearranging so you create your groups first, then add the faces fixes that.
The manifold? test fails because bbx2 contains another group inside it. That group however is a manifold. Maybe you didn't intend to create two levels of nested groups?
bbxmax = Geom;;Point3d.new bbxmin = Geom;;Point3d.new bbxmin.x = 1000.mm bbxmin.y = 0.mm bbxmin.z = 0.mm bbxmax.x = 2000.mm bbxmax.y = 1000.mm bbxmax.z = 1000.mm boxpts = [] boxpts[0] = [bbxmin.x, bbxmin.y, bbxmin.z] boxpts[1] = [bbxmax.x, bbxmin.y, bbxmin.z] boxpts[2] = [bbxmax.x, bbxmax.y, bbxmin.z] boxpts[3] = [bbxmin.x, bbxmax.y, bbxmin.z] bbx1 = Sketchup.active_model.entities.add_group g1 = bbx1.entities.add_group face1 = g1.entities.add_face boxpts face1.reverse! face1.pushpull(bbxmax.z-bbxmin.z ) bbxmin.x = 2000.mm bbxmin.y = 0.mm bbxmin.z = 0.mm bbxmax.x = 3000.mm bbxmax.y = 1000.mm bbxmax.z = 1000.mm boxpts = [] boxpts[0] = [bbxmin.x, bbxmin.y, bbxmin.z] boxpts[1] = [bbxmax.x, bbxmin.y, bbxmin.z] boxpts[2] = [bbxmax.x, bbxmax.y, bbxmin.z] boxpts[3] = [bbxmin.x, bbxmax.y, bbxmin.z] bbx2 = Sketchup.active_model.entities.add_group g2 = bbx2.entities.add_group face2 = g2.entities.add_face boxpts face2.reverse! face2.pushpull(bbxmax.z-bbxmin.z ) if ( bbx1.deleted? ) UI.messagebox("bbx1 deleted!") end if ( not bbx2.manifold? ) UI.messagebox("bbx2 is not a manifold") end
-
Hi Thom,
Thank you for your quick respons.
I indeed did not want to create a two level nested group.
Is it easy for you to tell me how I got rid of one of the two levels?With kind regards, Frank
-
Hi Thom,
Thank you for your quick respons. It works!
With exploding the groups I got rid of the two levels.With kind regards,
Frank
Enjoy spring!
-
There is no need to explode - just don't create two groups.
Change this:
bbx1 = Sketchup.active_model.entities.add_group g1 = bbx1.entities.add_group face1 = g1.entities.add_face boxpts face1.reverse! face1.pushpull(bbxmax.z-bbxmin.z )
to
bbx1 = Sketchup.active_model.entities.add_group face1 = bbx1.entities.add_face boxpts face1.reverse! face1.pushpull(bbxmax.z-bbxmin.z )
If you read your code carefully you will see that you call add_group twice, once in the root entities element and once in the first group you created.
Advertisement