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
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
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
RE: How to collect 3D point using VB
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