×
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

Problem Intersection with Solid VBA CATIA

Problem Intersection with Solid VBA CATIA

Problem Intersection with Solid VBA CATIA

(OP)
Hi all,

Two months ago I began to use CATIA, so it was already time to get into a forum :).
I've been struggling with a vba code that creates intersections between lines and solids: the .part file I am working with contains a geometrical set with lines and several bodies that form a single structure. Each body contains a single solid element. All lines begin on a common point located in space (outside the structure) and end on a solid surface point (there are about 1000 points spreaded over the surfaces of the solid elements).

What I would like to know is if a line intersects with the structure (all bodies) at some point, just wether the line intersects or not. I tried to create those intersections but unfortunately I am always getting problems with the "part.Update" and intersections are not created properly. Even if they are not created properly, I can check if the line intersects or not as I am getting an error. But the problem is that all end line points ending in one of the solid surfaces will always intersect (the solution will be the very end point located on the surface of the solid). I do not want to consider that type of points as intersections, just the intersections created when the lines passes through the solid, so in order to discriminate those, I was comparing the coordinates of the intersection point with the ending line point and check if they were the same, thing that I can no longer apply as intersections are not well created.

Having Bodies splitted by pads, holes.. gives me no problems when creating intersections. However, having a "solid" element makes my code get errors when creating them.

Hope you can help me! Thanks!

CODE -->

Function Create_Intersection(objPart, part, parts, partcount1, j)

Dim hybridShapeFactory1 As HybridShapeFactory
Set hybridShapeFactory1 = part.HybridShapeFactory

Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part.HybridBodies

Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item(partcount1)

Set objHShape = objPart.HybridBodies.Item(partcount1).HybridShapes.Item(j)

Dim reference1 As Reference
Set reference1 = objPart.CreateReferenceFromObject(objHShape)

Dim bodies1 As Bodies
Set bodies1 = part.Bodies

For l = 2 To part.Bodies.Count

    Dim body1 As Body
    Set body1 = bodies1.Item(l)
    
    Dim shapes1 As Shapes
    Set shapes1 = body1.Shapes
    
    Dim solid1 As Solid
    Set solid1 = shapes1.Item(1)

    Dim reference2 As Reference
    Set reference2 = part.CreateReferenceFromObject(solid1)
    
    Dim hybridShapeIntersection1 As HybridShapeIntersection
    Set hybridShapeIntersection1 = hybridShapeFactory1.AddNewIntersection(reference1, reference2)
    
    hybridShapeIntersection1.PointType = 0
    
    hybridBody1.AppendHybridShape hybridShapeIntersection1
    
    part.InWorkObject = hybridShapeIntersection1
    
    part.Update

Next

Create_Intersection = True

End Function 

RE: Problem Intersection with Solid VBA CATIA

(OP)
I solved the problem by extracting the bodies and joining the resulting extraction.

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