Python rg.Brep.DuplicateFaces(brep)?


but what is it for faces in Python?


it does not work

what am I doing wrong?

Have a look at the Brep class documentation. Depending on what you’re trying to do, you might want to access the Brep.Faces and get an item (and duplicate its face), or maybe you want to extract a face from a brep.

1 Like

I suspect that rg.Brep.DuplicateFaces() does not even exist…

There is rg.BrepFace.DuplicateFace() instead.


This converts a brepface into a brep consisting of a single face, often used as a trimmed surface.

1 Like

I am sorry, but is there a way to get the faces in a list form?
I cannot remember how to type that line.

20190131 problem brepfaces (6.9 KB)

I think there is no such a function. Maybe this…

brepfaces=[face.DuplicateFace(False) for face in br.Faces]
1 Like

And to get the centerpoints of the faces (this one does not work).

facescenters=[face.AreaMassProperties.Centroid for face in brepfaces]

Sorry, I do not know yet when to place the objectname in front of the function or after the function between the ().
I assume when written, but looking at AreaMassProperties_Centroid I am not able to understand how to do it in Python.

That’s actually not an easy one. yes there are two types of functions.
“static method” is the key word. But I’m sure it’s difficult to understand.

I try to explain.
Let’s say we have a method “a” defined under class A. The Python editor shows it as A.a().
you have a myA of type A, created by


you can call function “a” by calling


Internally, this calls a function

def a(self,other parameters):
    #do something

and your “myA” is set to self. from within a() you can access to myA through self.

Now, static methods. under the class “A”, you can have a function that does not have access to self. It’s simply

def b():
    #do Something

this function, you need to call it via A.b(), not myA.b() because it doesn’t take a reference to an instance of A. (myA is an instance of A).
In C#, C++, etc., static methods and regular methods are different, but in Python, you can call non-static method as like it is a static method,

A.a(myA,...)   #equivalent to myA.a(...)
1 Like

Now I see you needed faces converted to breps because you needed center points…

If I remembered correctly, AreaMassProperties.Compute is a static method, but returns an instance of AreaMassProperties, and you are not allowed to create an instance of AreaMassProperties via AreaMassProperties(), agh.


I vote to an option to simply do a for loop for what you want to do. But if you stick to [… for … in …] syntax, this may work

brepfaces=[face.DuplicateFace(False) for face in br.Faces]
facescenters=[rg.AreaMassProperties.Compute(brepface).Centroid for b brepface in brepfaces]
1 Like

Wooowww :open_mouth::flushed:, thank you for your explanation and your help.
I read it and now understand this part about ‘static methods’ better.

The way I understand it now is like:

"A" is something like a tree, but not a tree. "A" is more like an octopus with tentacles which hold different kinds of data which can be looked at by doing "A.a()." And functions are things to 'create' things 'with data.'

I confused ‘functions’ with ‘octopuses.’

So, in theory, I assume, with the functions it is also possible to create those ‘octopuses (data packages).’ It is not an assumption but seems logic of how this works.

Static methods are the things to access the data packages from the ‘octopus.’
Functions are other commands.
Everything explaining to me that the way it is written is different because of that.

Functions are things whereafter the object goes between the () and with static methods it is written to access what is in the object. Sorry, maybe I make it even more confusing. What I want to say with this is that you made it me very clear, thank you. :smile:

And thank you for your help and explanation in the second comment, you gave me a large jump. :smiley: Thank you!

1 Like

Okay, I don’t understand any bit of your explanation :rofl:, but I’m happy you had a big leap.

Another term perhaps shed a light on you is “constructor”.

You have a class “A” and you want to get an instance of class “A”.
class “A” usually has a special function which has exactly same name as “A” and returns an instance of A. This function, A.A() is called a constructor. I know it’s confusing, but A.A() returns an instance of A, agh. First A is the name of class. The second A is the name of function, aka constructor. Other functions can return either values(numbers, texts) or class instances (objects).

And this A.A(), in Python, you can call it by simply calling A().
so, if you call


“a” will be a new instance of class A. A bit confusing is that A() itself is not a class, but it’s a constructor of class A. Just, there is a convention that a constructor of a class always has the same name as it’s class name.

I guess this is the reason you were confused “functions” with “octopusses”.

1 Like

Oh wow, that is more easy than my explanation: not :octopus:'s, but ‘classes.’
:dizzy_face::grin: constructors, ah-ha :thinking::sunglasses:

1 Like