Xor Boolean Operation on Polygons

edited April 2013 in Ruby Scripting
Hi Matthias,

Right now I am trying to figure out how to use the Xor boolean operation for two polygons over the top of one another in scripting just like you have as an available function under the "Edit" --> "Layers" --> "Boolean Operations" window.

This is the code that I have made so far, and I can't figure out what is wrong with it after looking through your "Assistant" tool.

Here is the code:

include RBA

def self.my_method()
mw = RBA::Application::instance.main_window
layout = mw.create_layout(0).layout
layout_view = mw.current_view

my_cell = layout.add_cell("My_Cell")
cell = layout.cell(my_cell)
layer1 = layout.insert_layer(RBA::LayerInfo::new(1,0))
layer2 = layout.insert_layer(RBA::LayerInfo::new(31,1))
a = RBA::Point::new(5000,5000)
b = RBA::Point::new(-5000,5000)
c = RBA::Point::new(-5000,-5000)
d = RBA::Point::new(5000,-5000)
e = RBA::Point::new(2500,2500)
f = RBA::Point::new(-2500,2500)
g = RBA::Point::new(-2500,-2500)
h = RBA::Point::new(2500,-2500)

p1 = cell.shapes(layer1).insert(RBA::Polygon::new([a,b,c,d]))
p2 = cell.shapes(layer2).insert(RBA::Polygon::new([e,f,g,h]))


layout_view.select_cell(my_cell, 0)


Thank you for your time,


  • edited April 2013

    Hi Jared,

    there is no boolean operation on shapes right now (maybe there never will, because a shape does not necessarily create one shape in the boolean operations).

    The right object to use is the ShapeProcessor object. It can perform a boolean operation on two layers and store the results in another layer.

    You can use it like this:

    layer_out = layout.insert_layer(RBA::LayerInfo::new(10,0))
    sp = ShapeProcessor::new
    sp.boolean(layout, cell, layer1, layout, cell, layer2, cell.shapes(layer_out),
      EdgeProcessor::ModeXor, true, true, true)


Sign In or Register to comment.