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!

Create Points on output features

Status
Not open for further replies.

GeorPapi

New member
Jul 14, 2016
3
GR
Hi, I am new on working with catia macros. I have a modified airfoil in 2D sketch and I want to design equidistant points on the airfoil splines and then to export the coordinates to an excel spreadsheet. The first step can be done easily in the 2D sketcherwith with the command "Equidistant Points". However, the points that are created cannot be exported directly as 3D points. So I have exported all these points as output features and I want to write a macro that adds a 3D point on each of them. The problem is that I don't know which is the exact command to do this. I would appreciate any kind of help.

Code:
Sub CATMain()

Dim i As Integer
Dim Sel As Selection
Set Sel = CATIA.ActiveDocument.Selection
Sel.Search "CATSketchSearch.2DOutput,all"
Sel.Search "Topology.Vertex,sel"
    
For i = 1 To elements.Count

Set Element = Sel.Item(i).Add("point") '<- Here I don't know how to write the command for adding a point on each vertex

Next
End Sub
 
Replies continue below

Recommended for you

why would you need to create a point whan you already have the vertex... you could get XYZ from vertex the same way you get it from point

Eric N.
indocti discant et ament meminisse periti
 
Hi,
I have tried to do this in this way, but it didn't work.

1)Firstly, I created a separate geometrical set, copied all the output features of the 2D sketch in this and finally I isolated them. Then I used a code, that I have found in this forum, for exporting points, but I was getting an error message: "The subject does not support this property or method: 'point.GetCoordinates'"

Code:
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)
Dim point As Variant
Dim PartDocument1
Sub CATMain()
CATIA.ActiveDocument.Selection.Search "CATGmoSearch.Point,all"
StartEXCEL
ExportPoint
'objGEXCELSh.Application.ActiveWorkbook.SaveAs (ExcelFolder & Left(CATIA.ActiveDocument.Name,Len(CATIA.ActiveDocument.Name)-8) & ".xls")
'objGEXCELSh.Application.ActiveWorkbook.Close
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()
'******************************************************************************
Dim x As Integer
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

2) Then I made some changes on the above code to get the coordinates from the output features in the 2D sketch. When I run this, I get an error "The subject does not support this property or method: 'reference1.GetCoordinates'"

Code:
'******************************************************************************


Sub ExportPoint()

Dim i As Integer
Dim Sel As Selection
Set Sel = CATIA.ActiveDocument.Selection
Sel.Search "CATSketchSearch.2DOutput,all"
Sel.Search "Topology.Vertex,sel"

Dim mycoord(2)

Y = sel.Count

For i = 1 To Y
Set reference1 = Sel.Item(i).Value
reference1.GetCoordinates (mycoord)
'Write PointData to Excel Sheet
reference1.GetCoordinates (coords)
objGEXCELSh.Cells(i + 1, "A") = reference1.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

That is why I thought that it was not possible to take the coordinates directly and I decided to write a macro that creates 3D points on the output features. Is there another way to do this?
Thanks in advance.

 
you using .Getcoordinates on the point object when it should be used in the Measurable object defined with the point as reference. please read again documentation or XYZ point extract sample from FAQ

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top