0

I have a problem. in my task, I have Pad and Line which intersect each other. I have 2 intersection points and I want to get coordinates, or something identification because I want to create a line between these points. After the first action, my line changed position and I have a new intersection and split. part updated and all these actions as well updated. I want to previous action stay in my product and go next. 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

 
End Sub
braX
  • 11,506
  • 5
  • 20
  • 33
Salome
  • 1
  • 2
  • 1
    Make the line between your two points (HybridShapeLinePtPt), then isolate it (make a datum line --> HybridShapeLineExplicit). Now update your points and the previous datum line will remain. Repeat for each position. – C R Johnson Apr 13 '23 at 12:59
  • Thank you for the reply, I've tried even this but, my intersection points are undefined, only the first point can make some manipulation, how can I write correctly, to find the second intersection point and make hybridshapelineptpt between them? – Salome Apr 14 '23 at 06:33
  • Can you add an image of your geometry to the question? Perhaps, as with a line intersecting a closed sketch, there may be two (or more), solutions. The intersection in such a case is not a point but a multi-domain shape. For this you will have to either go through the sub elements (don't do this) or apply near or far operations (easier) to extract the sub-element you want. Do this interactively so you see what it should end up looking like. – C R Johnson Apr 14 '23 at 15:11
  • https://drive.google.com/file/d/1SETnMv32o9ykkdZuadAhoBSI0gveRVqu/view?usp=sharing I uploaded this screenshot in DRIVE. Could you take a look? – Salome Apr 19 '23 at 05:43
  • 1
    It is just what I guessed. The intersection of the line with the box has 2 solutions. So you get both in one intersection. Create points on each end of your line and then make near features from the intersect using each of these points as references. Now you will have both intersections as separate points and can proceed. – C R Johnson Apr 20 '23 at 13:09

0 Answers0