Personal tools
You are here: Home Forum Use Re: get face ids based on a nomal vector

Re: get face ids based on a nomal vector

Up to Use

Re: get face ids based on a nomal vector

Posted by Ashkan Rafiee at June 15. 2020

Hi

I was wondering how can I get all faces that have a specific normal? Basically, in the attached image I want to get the faces that have normal OY (need to do this from Python script). I tried the followings:

Face_ids = geompy.SubShapeAllSortedCentres(StiffenedPlate, geompy.ShapeType["FACE"])
for fce in Face_ids:
    vnorm = geompy.GetNormal(fce)
    # fid = geompy.GetSubShapeID(StiffenedPlate, fce)

However, from here I cannot figure out how to get the ids of faces with normal in opposite direction of OY?

 

Attachments

Re: get face ids based on a nomal vector

Posted by Ashkan Rafiee at June 15. 2020

I managed to do it with

Face_ids = geompy.SubShapeAllSortedCentres(StiffenedPlate, geompy.ShapeType["FACE"])
for fce in Face_ids:
    norm = geompy.GetNormal(fce)
    vec = geompy.VectorCoordinates(norm)
    Mag = math.sqrt(vec[0] ** 2 + vec[1] ** 2 + vec[2] ** 2)
    theta = math.degrees(math.acos(geompy.DotProduct(norm, OY) / Mag))
    if abs(theta - 180.0) <= 1.0:
        print(geompy.GetSubShapeID(StiffenedPlate, fce))
        fid = geompy.GetSubShapeID(StiffenedPlate, fce)
        geompy.addToStudy(norm, "face_{}_norm".format(fid))

 

I am not so sure if this is the best way to do it though

Powered by Ploneboard
Document Actions