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!

Export point coordinate (Assembly Enviroment)

Status
Not open for further replies.

gm2gabriel

Aerospace
Jul 23, 2020
4
BR
Hello,

First of all, this is a great forum, it already helped me a lot in the past. So, I would like to ask for help in this specific subject:

I have a few Parts inside a Product and I would like to export to Excel XYZ coordinates of a few notable points. Those notable points are all inside the same .CATPart.

Looking in the forum, I have already found a macro (CATScript) to this, however it only works in the Part Design environment, i.e. when the .CATPart is open in a new window.

I have no programming skills in Catia... Is it possible to adapt this macro to work in the Assembly Design environment? Or even when a CATPart is active in the tree, but opened in a new window?

What I am really trying to do is put this macro inside another macro that will run in a .CATProduct, this Product have a Design Table and for each line of this design table I would like to export XYZ of a few points inside a .CATPart.

In the attached image are the two points I am trying to export XYZ coordinates. Note they are under a Part and I am in the Assembly Design environment.


The following CATScript macro only works with a .CATPart
------

Dim objGEXCELapp As Object
Dim objGEXCELwkBks As Object
Dim objGEXCELwkBk As Object
Dim objGEXCELwkShs As Object
Dim objGEXCELSh As Object
Dim FS, f, f1, fc, s
Dim coords(2) As Variant
Dim partDocument1

Sub CATMain()

CATIA.ActiveDocument.Selection.Search "CATGmoSearch.Point,all"

StartEXCEL

ExportPoint

End Sub

'******************************************************************************
Sub StartEXCEL()
'******************************************************************************
Err.Clear
On Error Resume Next
Set objGEXCELapp = GetObject(, "EXCEL.Application")

If Err.Number <> 0 Then
Err.Clear
Set objGEXCELapp = CreateObject("EXCEL.Application")
End If

objGEXCELapp.Application.Visible = True
Set objGEXCELwkBks = objGEXCELapp.Application.WorkBooks
Set objGEXCELwkBk = objGEXCELwkBks.Add
Set objGEXCELwkShs = objGEXCELwkBk.Worksheets(1)
Set objGEXCELSh = objGEXCELwkBk.Sheets(1)
objGEXCELSh.Cells(1, "A") = "Name"
objGEXCELSh.Cells(1, "B") = "X"
objGEXCELSh.Cells(1, "C") = "Y"
objGEXCELSh.Cells(1, "D") = "Z"

End Sub

'******************************************************************************
Sub ExportPoint()
'******************************************************************************
For i = 1 To CATIA.ActiveDocument.Selection.Count
Set Selection = CATIA.ActiveDocument.Selection
Set Element = Selection.Item(i)
Set Point = Element.Value

'Write PointData to Excel Sheet
Point.GetCoordinates (coords)

objGEXCELSh.Cells(i + 1, "A") = Point.Name
objGEXCELSh.Cells(i + 1, "B") = coords(0)
objGEXCELSh.Cells(i + 1, "C") = coords(1)
objGEXCELSh.Cells(i + 1, "D") = coords(2)

Next

End Sub

------
example_oe8mzu.png
 
Replies continue below

Recommended for you

however it only works in the Part Design environment, i.e. when the .CATPart is open in a new window.

Doesn't looks like it to me. What error do you get when you try to run the macro from a product?
 
1_bi5d6n.png
2_d7j7qg.png
3_bdo0uv.png


This is what I get when I try to run this macro on the .CATProduct in the Assembly environment.

Note that there is "2 elements selected" when I try to run the macro, but there are "6 elements selected" when I get the error.

As I said before, it runs ok when the .CATPart is open in a new window, but of course is this case I get XYZ in the part local ref axis, not in the assembly ref axis.

Error message (translating the portuguese text)

Execute the script "M2 pos macro.CATScript".
The scripting engine for CATScript has reported the following error:

Source: Error of execution time of Microsoft VBScript
Description: The object does not give support to the property or method: "Point.GetCoordinates'
Line: 54
Column: 0
 
I believe if you open "M2 model" part in a new window your original macro will fail.
Am I right?
 
If I open "M2 model" part in a new windows the macro listed here works, flawless. However, it will export the XYZ in the local system of coordinates (part level) and this data is of no use for me. I need the coordinates in the product system of coordinates.
 
I need the coordinates in the product system of coordinates

You should've wrote it from the very beginning.

Basically, there's no straightforward way to get those coordinates, you have to do a little bit of math.

Search the form for "global coordinates" and similar threads.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top