×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Create Points on output features

Create Points on output features

Create Points on output features

(OP)
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 

RE: Create Points on output features

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

RE: Create Points on output features

(OP)
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.

RE: Create Points on output features

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

RE: Create Points on output features

(OP)
Thanks for the reply. You are right.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources