×
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

How to collect 3D point using VB

How to collect 3D point using VB

How to collect 3D point using VB

(OP)
Hi all

I have a CATPart with an Open.Body that has a several items, and I am trying to collect the items that are only points. Several points are renamed.  I tried to use GeometricElements class but it just return the sketch elements such as points, line, etc..  Can some one help me with this?
Thanks in advance

Sub CATMain ()

Dim Document1 as Document
Set Document1 = CATIA.ActiveDocument

Dim part1 as part
set part1 = Document1.Part

dim hybridbody1 as hybridbody
set hybridbody1 = part1.hybridbody

dim GeometricElement1 As GeometricElement
For i = 1 to hybridbody1.GeometricElements.Count
     SetGeometricElement1=
       hybridbody1.GeometricElements.item(i)
Next

End Sub

RE: How to collect 3D point using VB

Hi Camille,

We've created a few macros using point coordinate data retrieved from a selection of entities, which may contain some info you can use.  The type of element you are looking for is a "CATIAHybridShapePoint".  I've attached the relevant portion of one of the macros below:

        ' Retrieve the selected Points
        Dim PointSelection As AnyObject
        Dim SelectedItem As Integer        
        Dim PointCoordArray(2) As Long
        Dim PointLineOutput As String
        Dim icount as Integer
        Dim SelectionCount As Integer
        Dim NameChoice As Integer    
        
        NameChoice = MsgBox("Are Point Reference Names Required" & vbCrLf & "As Part Of Output File?", vbYesNo)

        SelectionCount = CurrentSelection.Count
        'Msgbox SelectionCount    
        For SelectedItem = 1 To SelectionCount    
            On Error Resume Next
            Set PointSelection = CurrentSelection.FindObject("CATIAHybridShapePoint")
            if (Err.Number = 0) Then
                PointSelection.GetCoordinates PointCoordArray
                For icount = 0 To 2
                    PointCoordArray(icount) = Round(PointCoordArray(icount)/25.4,6)
                    'Msgbox PointCoordArray(icount)
                Next
                            
                PointLineOutput = Join(PointCoordArray, "    ")
                If (NameChoice = vbYes) Then
                    TextStream.Write PointSelection.Name+"    "+PointLineOutput & vbCrLf
                Else
                    TextStream.Write PointLineOutput & vbCrLf
                End If
                
                Set PointLineOutput = Nothing
                Set PointSelection = Nothing
                icount = 0
            End If
        Next

If Beethoven had been killed in a plane crash at the age of 22, it would have changed the history of music...
and of aviation.

RE: How to collect 3D point using VB

Will this method overlook 'Intersect Points'?

RE: How to collect 3D point using VB

Hello I3ob,

Unfortunately you are correct - V5 seems to treat intersection (and projection) points differently from "normal" points.  While it recognises the intersection as being of type "point", we couldn't find a way to extract the coordinate data directly.

The only way round this seemed to be to select all points (selection.Search "CATGmoSearch.Point,all" - or some variation of this if not all points were required) and, where the point was defined as an intersection, inserting a "real" point using the intersection point as a reference element.  While it wasn't required for the task we were doing, I think this is also valid for projection elements.

If Beethoven had been killed in a plane crash at the age of 22, it would have changed the history of music...
and of aviation.

RE: How to collect 3D point using VB

I think that you will find, also, that in a large part, the Search function will work much faster than looping thru all of the elements.  

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