Trick to Make a One Surface Join Using CATIA Macro

If you’ve ever tried to create a Join surface using HybridShapeAssemble function AddNewJoin you may have noticed that it requires two elements as reference or input:

Function AddNewJoin(Element1 As Reference, Element2 As Reference) As HybridShapeAssemble

But what if you want to make a join from only one surface? Often times you just want to check the tangency or connectivity of a surface or using a Join at the very end of your spec tree is a good way to show what the very last piece of geometry is. This is a trick you can use in order to create a join based on only one surface.

Basically, you input the one surface twice, create the join geometry, then remove one of the inputs. See the CATIA macro code below:

Sub CATMain()

'---CATPart must be the active document

Dim partDocument1 As PartDocument

Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part

Set part1 = partDocument1.Part

Dim hybridShapeFactory1 As HybridShapeFactory

Set hybridShapeFactory1 = part1.HybridShapeFactory

Dim hybridBodies1 As HybridBodies

Set hybridBodies1 = part1.HybridBodies

Dim hybridBody1 As HybridBody

'get the first geometrical set

Set hybridBody1 = hybridBodies1.Item(1)

Dim MyHybridShapes As HybridShapes

Set MyHybridShapes = hybridBody1.HybridShapes


Dim parameters1 As Parameters

Set parameters1 = part1.Parameters

Dim hybridShapeSurfaceExplicit1 As HybridShapeSurfaceExplicit

Set hybridShapeSurfaceExplicit1 = parameters1.Item(1)

Dim reference1 As Reference

Set reference1 = part1.CreateReferenceFromObject(hybridShapeSurfaceExplicit1)

'instead of using two different reference surfaces, we use the same one twice

Dim hybridShapeAssemble1 As HybridShapeAssemble

Set hybridShapeAssemble1 = hybridShapeFactory1.AddNewJoin(reference1, reference1)

'--join settings, change as desired

hybridShapeAssemble1.SetConnex 0

hybridShapeAssemble1.SetManifold 0

hybridShapeAssemble1.SetSimplify 0

hybridShapeAssemble1.SetSuppressMode 0

hybridShapeAssemble1.SetDeviation 0.001

hybridShapeAssemble1.SetAngularToleranceMode 0

hybridShapeAssemble1.SetAngularTolerance 0.5

hybridShapeAssemble1.SetFederationPropagation 0

hybridBody1.AppendHybridShape hybridShapeAssemble1

part1.InWorkObject = hybridShapeAssemble1

hybridShapeAssemble1.RemoveElement 2

part1.Update

End Sub

 

2 Comments

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.