Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

exporting point coordinates relative to assembly axis.

Status
Not open for further replies.

pravs

Mechanical
Apr 12, 2018
34
US
Hi,(
I am having a part with multiple instances and need to export coordinates of points created on one part (reflecting on the other instances as well)relative to assembly axis as shown.Currently I am able to export only one set of coordinates .
Capture_td3i8y.png


the code is used is
Sub CATMain()
Set objexcel = CreateObject("Excel.Application")

objexcel.Visible = True

Set objWorkbook = objexcel.workbooks.Add()

Set objsheet1 = objWorkbook.Sheets.Item(1)

objsheet1.Name = "Points_Coordinates"

Dim coords(8) As Variant

Set Selection = CATIA.ActiveDocument.Selection
'Selection.Search "( CATPrtSearch.Point),all"
Selection.Search "NameInGraph=*Point*,all"

For i = 1 To Selection.Count

Set Element = Selection.Item(i)

Set ptt = Element.Value

ptt.Getcoordinates(coords)

objsheet1.cells(i + 1, 1).Value = ptt.Name

objsheet1.cells(i + 1, 2).Value = coords(0)

objsheet1.cells(i + 1, 3).Value = coords(1)

objsheet1.cells(i + 1, 4).Value = coords(2)
objsheet1.cells(i + 1, 5).Value = Element.Name



'this is for non-isolated Points
Set parentObject = ptt.Parent
Do
If TypeName(parentObject) = "HybridBody" Or TypeName(parentObject) = "Body" Then
objsheet1.cells(i + 1, 5).Value = parentObject.Name
Exit Do
Else
Set parentObject = parentObject.Parent
End If
'safe check
If TypeName(parentObject) = "Part" Then
Exit Do 'you've went to far up and reached the Part itself.
End If
Loop

'this is for isolated points
If objsheet1.cells(i + 1, 5).Value = "" Then
bFound = False
Set oPart = CATIA.ActiveDocument.Part
'temporarily rename the point so the proper point is retrieved.
tmpPointName = "tmpPoint." & i
Point.Name = tmpPointName
For ix = 1 To oPart.HybridBodies.Count
Set oMyHBody = oPart.HybridBodies.Item(ix)
For jx = 1 To oMyHBody.HybridShapes.Count
Set oHShape = oMyHBody.HybridShapes.Item(jx)
If oHShape.Name = tmpPointName Then
'this is my Point. get the parent's name
objsheet1.cells(i + 1, 5).Value = oMyHBody.Name
bFound = True
Exit For
End If
Next
If bFound Then Exit For
Next
Point.Name = objsheet1.cells(i + 1, 1).Value
End If
Next

.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top