Comparing the found vertices in the section result

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

Comparing the found vertices in the section result

Post by stefankorisnik3 »

I have plane (maybe you get it with my previous posts :) ).
Have solid object c1Shape that have a shape wire and doing the section function on the shape.
As result i get new object newShape of type Shape.
Now when introspect the new Shape object for the intersected vertices i would like to know exactly where it is located in the start solid object c1Shape.
Currently i'm looping like the code following and getting only "YES POINT ARE THEY". Is there better way for doing this?

UPDATE: Found that the result of intersected vertices doesn't need to be in the c1Shape.Wires[0].Vertexes.

Code: Select all

newShape = c1Shape.section(plane.toShape())
if len(newShape.Vertexes) != 0:
            for v1 in newShape.Vertexes:
                for v2 in c1Shape.Wires[0].Vertexes:
                    if v1.isPartner(v2):
                        print("YES PARTNER ARE THEY")
                    if v1.isSame(v2):
                        print("YES SAME ARE THEY")
                    if v1.isEqual(v2):
                        print("YES EQUAl ARE THEY")
                    if v1.Point.isEqual(v2.Point, 1):
                        print("YES POINT ARE THEY")

                    chk1 = (round(v1.Point[0], 3) == round(v2.Point[0], 3))
                    chk2 = (round(v1.Point[1], 3) == round(v2.Point[1], 3))
                    chk3 = (round(v1.Point[2], 3) == round(v2.Point[2], 3))
                    
                    if chk1 and chk2 and chk3:
                        print("YES ROUND ARE THEY")

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: English/United Kingdom (en_GB)
Installed mods: 
  * CurvedShapes 1.0.3
  * Curves 0.5.2
Post Reply