Code: Select all
print(f'is planar? {obj.Shape.Faces[0].Surface.TypeId == "Part::GeomPlane"}')
Code: Select all
print(f'is planar? {obj.Shape.Faces[0].Surface.TypeId == "Part::GeomPlane"}')
Code: Select all
def commonFace(self, shape0, shape1):
print(f'Common Face : {len(shape0.Faces)} : {len(shape1.Faces)}')
zero = FreeCAD.Vector(0.0, 0.0, 0.0)
for i, face0 in enumerate(shape0.Faces):
for j, face1 in enumerate(shape1.Faces):
print('dir surface')
print(dir(face0.Surface))
print(face0.Surface.TypeId)
print(isinstance(face0.Surface, Part.Plane))
print(isinstance(face1.Surface, Part.Plane))
if isinstance(face0.Surface, Part.Plane) and \
isinstance(face1.Surface, Part.Plane):
print('Both Flat')
Code: Select all
20:24:39 dir surface
20:24:39 ['Content', 'Continuity', 'FirstUKnotIndex', 'FirstVKnotIndex', 'LastUKnotIndex', 'LastVKnotIndex', 'MaxDegree', 'MemSize', 'Module', 'NbUKnots', 'NbUPoles', 'NbVKnots', 'NbVPoles', 'Rotation', 'Tag', 'TypeId', 'UDegree', 'UKnotSequence', 'UPeriod', 'VDegree', 'VKnotSequence', 'VPeriod', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'approximate', 'bounds', 'buildFromNSections', 'buildFromPolesMultsKnots', 'clone', 'copy', 'curvature', 'curvatureDirections', 'deleteExtensionOfName', 'deleteExtensionOfType', 'dumpContent', 'exchangeUV', 'getAllDerivedFrom', 'getD0', 'getDN', 'getExtensionOfName', 'getExtensionOfType', 'getExtensions', 'getPole', 'getPoles', 'getPolesAndWeights', 'getResolution', 'getUKnot', 'getUKnots', 'getUMultiplicities', 'getUMultiplicity', 'getVKnot', 'getVKnots', 'getVMultiplicities', 'getVMultiplicity', 'getWeight', 'getWeights', 'hasExtensionOfName', 'hasExtensionOfType', 'increaseDegree', 'increaseUMultiplicity', 'increaseVMultiplicity', 'incrementUMultiplicity', 'incrementVMultiplicity', 'insertUKnot', 'insertUKnots', 'insertVKnot', 'insertVKnots', 'interpolate', 'intersect', 'intersectSS', 'isDerivedFrom', 'isPlanar', 'isUClosed', 'isUPeriodic', 'isURational', 'isUmbillic', 'isVClosed', 'isVPeriodic', 'isVRational', 'mirror', 'movePoint', 'normal', 'parameter', 'projectPoint', 'removeUKnot', 'removeVKnot', 'reparametrize', 'restoreContent', 'rotate', 'scale', 'segment', 'setExtension', 'setPole', 'setPoleCol', 'setPoleRow', 'setUKnot', 'setUKnots', 'setUNotPeriodic', 'setUOrigin', 'setUPeriodic', 'setVKnot', 'setVKnots', 'setVNotPeriodic', 'setVOrigin', 'setVPeriodic', 'setWeight', 'setWeightCol', 'setWeightRow', 'tangent', 'toBSpline', 'toShape', 'toShell', 'transform', 'translate', 'uIso', 'vIso', 'value']
20:24:39 Part::GeomBSplineSurface
20:24:39 False
20:24:39 False
Code: Select all
def commonFace(self, shape0, shape1):
print(f'Common Face : {len(shape0.Faces)} : {len(shape1.Faces)}')
zero = FreeCAD.Vector(0.0, 0.0, 0.0)
for i, face0 in enumerate(shape0.Faces):
for j, face1 in enumerate(shape1.Faces):
print('dir surface')
print(dir(face0.Surface))
print(face0.Surface.TypeId)
print(isinstance(face0.Surface, Part.Plane))
print(isinstance(face1.Surface, Part.Plane))
if isinstance(face0.Surface, Part.Plane) and \
isinstance(face1.Surface, Part.Plane):
print('Both Flat')
Code: Select all
20:24:39 dir surface
20:24:39 ['Content', 'Continuity', 'FirstUKnotIndex', 'FirstVKnotIndex', 'LastUKnotIndex', 'LastVKnotIndex', 'MaxDegree', 'MemSize', 'Module', 'NbUKnots', 'NbUPoles', 'NbVKnots', 'NbVPoles', 'Rotation', 'Tag', 'TypeId', 'UDegree', 'UKnotSequence', 'UPeriod', 'VDegree', 'VKnotSequence', 'VPeriod', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'approximate', 'bounds', 'buildFromNSections', 'buildFromPolesMultsKnots', 'clone', 'copy', 'curvature', 'curvatureDirections', 'deleteExtensionOfName', 'deleteExtensionOfType', 'dumpContent', 'exchangeUV', 'getAllDerivedFrom', 'getD0', 'getDN', 'getExtensionOfName', 'getExtensionOfType', 'getExtensions', 'getPole', 'getPoles', 'getPolesAndWeights', 'getResolution', 'getUKnot', 'getUKnots', 'getUMultiplicities', 'getUMultiplicity', 'getVKnot', 'getVKnots', 'getVMultiplicities', 'getVMultiplicity', 'getWeight', 'getWeights', 'hasExtensionOfName', 'hasExtensionOfType', 'increaseDegree', 'increaseUMultiplicity', 'increaseVMultiplicity', 'incrementUMultiplicity', 'incrementVMultiplicity', 'insertUKnot', 'insertUKnots', 'insertVKnot', 'insertVKnots', 'interpolate', 'intersect', 'intersectSS', 'isDerivedFrom', 'isPlanar', 'isUClosed', 'isUPeriodic', 'isURational', 'isUmbillic', 'isVClosed', 'isVPeriodic', 'isVRational', 'mirror', 'movePoint', 'normal', 'parameter', 'projectPoint', 'removeUKnot', 'removeVKnot', 'reparametrize', 'restoreContent', 'rotate', 'scale', 'segment', 'setExtension', 'setPole', 'setPoleCol', 'setPoleRow', 'setUKnot', 'setUKnots', 'setUNotPeriodic', 'setUOrigin', 'setUPeriodic', 'setVKnot', 'setVKnots', 'setVNotPeriodic', 'setVOrigin', 'setVPeriodic', 'setWeight', 'setWeightCol', 'setWeightRow', 'tangent', 'toBSpline', 'toShape', 'toShell', 'transform', 'translate', 'uIso', 'vIso', 'value']
20:24:39 Part::GeomBSplineSurface
20:24:39 False
20:24:39 False
Code: Select all
def createGeometry(self, fp):
# print('createGeometry')
if all((fp.x, fp.y, fp.z)):
currPlacement = fp.Placement
# if (hasattr(fp,'x') and hasattr(fp,'y') and hasattr(fp,'z')) :
mul = GDMLShared.getMult(fp)
GDMLShared.trace('mul : '+str(mul))
x = mul * fp.x
y = mul * fp.y
z = mul * fp.z
box = Part.makeBox(x, y, z)
base = FreeCAD.Vector(-x/2, -y/2, -z/2)
fp.Shape = translate(box, base)
fp.Placement = currPlacement
if hasattr(fp, 'scale'):
super().scale(fp)
Sorry don't like that solution at all, will carry on trying to find a solution,edwilliams16 wrote: ↑Mon Jun 27, 2022 9:10 pm Some operations turn flat faces into B-Spline Objects. It depends on the history of your objects...
The idea of intersecting thickened faces appears to work. It would take a little effort to code it. Draft|Downgrade to make faces. Then Part|3DOffset to thicken them and then Part|Boolean Common. The latter works fine on solids, but not on the original faces, for presumably numerical reasons. Another Draft|Downgrade could make the common surface.
The example is a Cube partially intersecting a cylinder.
Screen Shot 2022-06-27 at 10.56.30 AM.pngScreen Shot 2022-06-27 at 11.07.08 AM.png
Let us know what you find, that will work in general.keithsloan52 wrote: ↑Tue Jun 28, 2022 1:08 am
Sorry don't like that solution at all, will carry on trying to find a solution,
So how would one check if a B-Spline Surface is Flat?edwilliams16 wrote: ↑Mon Jun 27, 2022 9:10 pm Some operations turn flat faces into B-Spline Objects. It depends on the history of your objects...
@Chris_G is most likely to know.
If both Faces are Flat check for coplaner(?) same Planeedwilliams16 wrote: ↑Tue Jun 28, 2022 5:18 pm@Chris_G is most likely to know.
What's the plan if it isn't flat?
So, given a method powerful enough to match curved surfaces, surely it could handle flat ones?keithsloan52 wrote: ↑Tue Jun 28, 2022 5:38 pm
If both Faces are Flat check for coplaner(?) same Plane
If both Faces are Curved somehow check if they are both part of the same curved surface. i.e. the same or the smaller one would be part of the larger.