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!

CATIA EXPORT VALUE OF X,Y&Z values of Points

Status
Not open for further replies.

NaWin55

Mechanical
Mar 21, 2020
97
IN
Hello Every One
I have created this macro to export values of X,Y & Z co ordinate value of points
i can print the X,Y & Z value as message
But i want to print the value of x y & z co ordinate value of all the points to excel sheet
its only printing X value of the last point how, do i print x value of all points
i cant use GetCoordinates or selectElement2,3 methods becoz they wont work vba environment

here is the VBSCRIPT
Option Explicit

Sub PointMain()

Dim myDoc As Document
Set myDoc = CATIA.ActiveDocument

On Error Resume Next

Dim myPart As Part
Set myPart = CATIA.ActiveDocument.Part

Dim partDoc As PartDocument
Set partDoc = CATIA.ActiveDocument

Dim hybBds As HybridBodies
Set hybBds = myPart.HybridBodies

Dim bodies As bodies
Set bodies = myPart.bodies

Dim hybBd As HybridBody
Set hybBd = hybBds.Item(1)

Dim body As body
Set body = bodies.Item(1)

MsgBox hybBd.Name & vbNewLine & body.Name, vbOKOnly, "Message"

Dim hybShapefact As HybridShapeFactory
Set hybShapefact = myPart.HybridShapeFactory

Dim hybShape As HybridShapes
Set hybShape = hybBd.HybridShapes

Dim hybPoint As HybridShapePointCoord
Dim i As Integer
For i = 1 To hybShape.Count
Set hybPoint = hybShape.Item(i)
MsgBox hybPoint.X.Value
Next


Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
Dim xlbook As Workbook
Set xlbook = xlApp.Workbooks.Add
xlApp.Visible = True

Dim xlWorksSheet As Worksheet
Set xlWorksSheet = xlbook.Sheets.Item("Sheet1")

Dim j As Integer
For j = 1 To hybShape.Count
xlWorksSheet.Cells(j, 1).Value = hybPoint.X.Value
Next

End Sub

Here is the catpart files
 
 https://files.engineering.com/getfile.aspx?folder=d5afd712-110b-4cf9-85b8-a609f07f662b&file=Macro1.CATScript
Replies continue below

Recommended for you

try replacing

Code:
For j = 1 To hybShape.Count
xlWorksSheet.Cells(j, 1).Value = hybPoint.X.Value
Next

with
Code:
For j = 1 To hybShape.Count[b]
Set hybPoint = hybShape.Item(j)[/b]
xlWorksSheet.Cells(j, 1).Value = hybPoint.X.Value
Next

Eric N.
indocti discant et ament meminisse periti
 
@itsmyjob
Thank you so much it worked, i have been searching for this answer for a long time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top