Catia VBA Intersection Loop
Catia VBA Intersection Loop
(OP)
Hi, I want to create a series of intersections that have as input references the result of 2 iterations.
More concrete i have 2 geometrical sets ("Geometrical set A", "Geometrical set B"), with a series of n elements. In both sets the number of elements are the same. What i want to do is select the first geometrical set and then the second, and after that i want the macro to make intersections between elements in this way: first element from "Geometrical set A" with the first from the "Geometrical set B", second element from "Geometrical set A" with the second from the "Geometrical set B", and so on, until the end of the selection.
Thank you for future help! :)
More concrete i have 2 geometrical sets ("Geometrical set A", "Geometrical set B"), with a series of n elements. In both sets the number of elements are the same. What i want to do is select the first geometrical set and then the second, and after that i want the macro to make intersections between elements in this way: first element from "Geometrical set A" with the first from the "Geometrical set B", second element from "Geometrical set A" with the second from the "Geometrical set B", and so on, until the end of the selection.
Thank you for future help! :)





RE: Catia VBA Intersection Loop
regards,
LWolf
RE: Catia VBA Intersection Loop
it's not difficult, so even if you're a beginner, don't be afraid.
indocti discant et ament meminisse periti
RE: Catia VBA Intersection Loop
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Catia VBA Intersection Loop
_____________
Private Sub CommandButton5_Click()
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies
Dim hybridBody2 As HybridBody
Set hybridBody2 = hybridBodies1.Add()
hybridBody2.Name = "Intersections internal EDGES"
Dim hybridShapeBoundary1 As HybridShapeBoundary
Dim InputObjectType(0)
Dim SearchSelection As Selection
Dim reference As reference
Dim hybridShapeFactory1 As HybridShapeFactory
Set hybridShapeFactory1 = part1.HybridShapeFactory
Dim s As Integer
Dim q As Integer
Dim BoundarySelection1 As Selection
Set BoundarySelection1 = partDocument1.Selection
BoundarySelection1.Search "Name=Complete Boundary from Design Explode,all"
Set hybridBody1 = BoundarySelection1.Item2(1).Value
BoundarySelection1.Search "CATGmoSearch.GSMBoundary,sel"
Dim reference10 As reference
For s = 1 To BoundarySelection1.Count
Set reference10 = part1.CreateReferenceFromObject(BoundarySelection1.Item2(s).Value)
Dim BoundarySelection2 As Selection
Set BoundarySelection2 = partDocument1.Selection
BoundarySelection2.Search "Name=Complete Boundary on Join,all"
Set hybridBody1 = BoundarySelection2.Item2(1).Value
Dim reference11 As reference
BoundarySelection2.Search "CATGmoSearch.GSMBoundary,sel"
For q = 1 To BoundarySelection2.Count
Set reference11 = part1.CreateReferenceFromObject(BoundarySelection2.Item2(q).Value)
Dim hybridShapeIntersection1 As HybridShapeIntersection
Set hybridShapeIntersection1 = hybridShapeFactory1.AddNewIntersection(reference10, reference11)
hybridShapeIntersection1.PointType = 0
hybridBody2.AppendHybridShape hybridShapeIntersection1
part1.InWorkObject = hybridShapeIntersection1
part1.Update
Next
Next
End Sub
________
At this moment it make intersection with first element from first loop and every element from second loop. what is strange is that at the end of iteration it creates 2 aditional intersects that have update problem.
Catia that i use: Catia V5 R23
Thanks!
RE: Catia VBA Intersection Loop
CODE --> VBA
indocti discant et ament meminisse periti
RE: Catia VBA Intersection Loop
This was the a thing that i did not knew.
I've tested your suggestion and it works flawless.
Lower you can find the final structure of the loop.
Thank you all for replying!
_____________________________
Dim s As Integer
Dim BoundarySelection1 As Selection
Set BoundarySelection1 = partDocument1.Selection
BoundarySelection1.Search "Name=Complete Boundary from Design Explode,all"
Set hybridBody1 = BoundarySelection1.Item2(1).Value
BoundarySelection1.Search "CATGmoSearch.GSMBoundary,sel"
For s = 1 To BoundarySelection1.Count
Dim BoundarySelection3 As Selection
Set BoundarySelection3 = partDocument1.Selection
BoundarySelection3.Search "Name=Complete Boundary from Design Explode,all"
Set hybridBody1 = BoundarySelection3.Item2(1).Value
BoundarySelection3.Search "CATGmoSearch.GSMBoundary,sel"
Dim reference10 As reference
Set reference10 = part1.CreateReferenceFromObject(BoundarySelection1.Item2(s).Value)
Dim BoundarySelection2 As Selection
Set BoundarySelection2 = partDocument1.Selection
BoundarySelection2.Search "Name=Complete Boundary on Join,all"
Set hybridBody1 = BoundarySelection2.Item2(1).Value
BoundarySelection2.Search "CATGmoSearch.GSMBoundary,sel"
Dim reference11 As reference
Set reference11 = part1.CreateReferenceFromObject(BoundarySelection2.Item2(s).Value)
Dim hybridShapeIntersection1 As HybridShapeIntersection
Set hybridShapeIntersection1 = hybridShapeFactory1.AddNewIntersection(reference10, reference11)
hybridShapeIntersection1.PointType = 0
hybridBody2.AppendHybridShape hybridShapeIntersection1
part1.InWorkObject = hybridShapeIntersection1
Next