×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Catia VBA Intersection Loop
2

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! :)

RE: Catia VBA Intersection Loop

How far have you gotten so far? What is not working?

regards,
LWolf

RE: Catia VBA Intersection Loop

please share your progress, we will help you get there.
it's not difficult, so even if you're a beginner, don't be afraid.

Eric N.
indocti discant et ament meminisse periti

RE: Catia VBA Intersection Loop

(OP)
Hello, at this moment my macro looks like this:
_____________

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

as you want to intersect groupA.item(1) with groupB.item(1)...groupA.item(n) with groupB.item(n), you only need one loop.

CODE --> VBA

For s = 1 To BoundarySelection1.Count

[...]
Set reference10 = part1.CreateReferenceFromObject(BoundarySelection1.Item2(s).Value)

[...]
Set reference11 = part1.CreateReferenceFromObject(BoundarySelection2.Item2(s).Value)

[...]

next 

Eric N.
indocti discant et ament meminisse periti

RE: Catia VBA Intersection Loop

(OP)
Thank you itsmyjob!thumbsup
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources