0

I'm using "AddNewHybridSplit" function between Pad and Line (picture below) and I want to find the split line (with green color on screen) start and end points to create a new line "AddNewLinePtPt". how can I do it? I tried intersection but this points is also undefined.

enter image description here

Can anyone help me?

Sub ArchiliIntCoords()
    ' Define the document and part
    Dim documents1 As Documents
    Set documents1 = CATIA.Documents
    Dim partDocument1 As PartDocument
    Set partDocument1 = documents1.Item("X0 Line.CATPart")
    Dim part1 As Part
    Set part1 = partDocument1.Part
    
    ' Define the bodies and sketches
    Dim bodies1 As Bodies
    Set bodies1 = part1.Bodies
    Dim body1 As Body
    Set body1 = bodies1.Item("X0-Line")
    Dim sketches1 As Sketches
    Set sketches1 = body1.Sketches
    Dim sketch1 As Sketch
    Set sketch1 = sketches1.Item("Sketch.1")
    
    ' Create a new geometrical set for the intersection
    Dim hybridBodies1 As HybridBodies
    Set hybridBodies1 = part1.HybridBodies
    Dim hybridBody1 As HybridBody
    Set hybridBody1 = hybridBodies1.Add()
  

' Create a new intersection object
    Dim hshf As HybridShapeFactory
    Set hshf = part1.HybridShapeFactory
    Dim pad1 As Sketch
    Set pad1 = body1.Sketches.Item(1)
    Dim ref11 As Reference
    Set ref11 = part1.CreateReferenceFromObject(pad1)

    Dim myObj2 As AnyObject
    Set myObj2 = part1.FindObjectByName("Epox")
    Set ref2 = part1.CreateReferenceFromObject(myObj2)
    Dim myIntersect As HybridShapeIntersection
    Set myIntersect = hshf.AddNewIntersection(ref11, ref2)


 ' Add the intersection object to the geometrical set
    hybridBody1.AppendHybridShape myIntersect
    part1.Update
   
    
  Dim myHybridBody As HybridBody
    Set myHybridBody = part1.HybridBodies.Item(1) 'geometrical setshi iwereba wertili

Dim hybridShapeFactory1 As HybridShapeFactory
Set hybridShapeFactory1 = part1.HybridShapeFactory
            Dim bodies11
            Set bodies11 = part1.Bodies
            Dim body11 As Body
            Set body11 = bodies1.Item(1) 'ak migebulia partpody
            Dim line11
            Set line11 = body1.Sketches.Item(1) 'curved igebs sketch 1-is lines romelzec unda daematos wertili
       
  
 Dim mysplit As HybridShapeSplit
 Set mysplit = hybridShapeFactory1.AddNewHybridSplit(ref11, ref2, -1)
 
 
  myHybridBody.AppendHybridShape mysplit
  part1.Update
  
Dim oSelection As Selection
Set oSelection = partDocument1.Selection
oSelection.Clear
oSelection.Add mysplit
oSelection.VisProperties.SetRealColor 0, 255, 0, 0 'mwvane pers nishnavs


part1.Update
End Sub
braX
  • 11,506
  • 5
  • 20
  • 33
Salome
  • 1
  • 2
  • Have you checked the solution, which was descripted in the comments of your last question? Use near/far operation to separate the points of the multi-domain shape. (first try it manual/interactive) – Shrotter Apr 19 '23 at 15:14
  • Didn't work for me. And is there another solution? – Salome Apr 20 '23 at 09:44
  • Using a split function makes the solution more complex. You have to decide/verify, if catia has chosen the right side. So I suggest to use a line point to point. The points can be created via extremum/near or the multi-domain feature (your intersect) – Shrotter Apr 20 '23 at 10:10
  • Only the first intersection points are known. because I have this problem creating newlineptpt. – Salome Apr 20 '23 at 11:27

1 Answers1

0

Here a example to create both extremum of a multi-domain feature (very basic code, without any error handling)

Sub CATMain()

Dim oPartDoc As Document
Dim oPart As Part
Dim oHyShapeFactory As Factory
Dim oDircection As HybridShapeDirection
Dim oHybridBody As HybridBody
Dim oRef As Reference
Dim oIntersection As HybridShape
Dim oExtremum As HybridShapeExtremum

Set oPartDoc = CATIA.ActiveDocument
Set oPart = oPartDoc.Part
Set oHyShapeFactory = oPart.HybridShapeFactory

Set oHybridBody = oPart.HybridBodies.Item(1)

Set oIntersection = oHybridBody.HybridShapes.Item("Intersect.1")
Set oRef = oPart.CreateReferenceFromObject(oIntersection)
Set oDircection = oHyShapeFactory.AddNewDirectionByCoord(0,0,1)

Set oExtremum = oHyShapeFactory.AddNewExtremum(oRef, oDircection, 1)

oHybridBody.AppendHybridShape oExtremum

Set oExtremum = oHyShapeFactory.AddNewExtremum(oRef, oDircection, 0)

oHybridBody.AppendHybridShape oExtremum

oPart.InWorkObject = oExtremum

oPart.Update 

End Sub
Shrotter
  • 350
  • 3
  • 9