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!

How to get Coordinates of a point in a drawing View. 1

Status
Not open for further replies.

sriram99

Aerospace
Dec 10, 2012
35
IN
Hi Everyone,

I have a number of point in a view for which in need get (x,y,z) coordinates and the add a text with leader need to add the coordinates and some text.
I'm trying automate it. I could able to select the required points but not able to get the coordinates.
Help is much appreciated.

Sub CATMain()

Dim i As Integer
Dim coord(2)

Dim dwgDoc As DrawingDocument
Set dwgDoc = CATIA.ActiveDocument

Dim dwgViews As DrawingViews
Set dwgViews = CATIA.ActiveDocument.Sheets.ActiveSheet.Views

Dim dwgView As DrawingView
Set dwgView = dwgViews.ActiveView

Dim Point1 As Point2D

Dim pointSel As Selection
Set pointSel = dwgDoc.Selection

pointSel.Search "Name='GeneratedPoint Point',sel"

MsgBox pointSel.Count

For i = 1 To pointSel.Count

Set Point1 = pointSel.Item(i)
Point1.GetCoordinates (coord)
MsgBox "(" & coord(0) & ", " & coord(1) & " ," & coord(2) & ")"

Next

pointSel.Clear

End Sub



Thnaks,
Sriram
 
Replies continue below

Recommended for you

Hi,
I think a problem is in a line:

Code:
Set Point1 = pointSel.Item(i)

which should be changed to:

Code:
Set Point1 = pointSel.Item(i).Value

If you are iterating over a selection, you are dealing with SelectedElement object. To get a "real" selected object from SelectedElement, you have to use its Value property.


Tesak
- Play Tetris in CATIA V5 drawing
 
why not use the Coordinate Dimension Table that's already in CATIA?
 
Hi Jackk,

I don't want to list out all the coordinated in a table rather my requirement is to show the coordinates at that specific point.
After getting the coordinates of each point,for each coordinate value I need to concatenate some text.

So I can't use Coordinate Dimension.



Thnaks,
Sriram
 
Hi Tesak,

Thank you for your Suggestion.

I tried it but it is not working.



Thnaks,
Sriram
 
Hi Tesak,

error is attached.

error_xqrgqh.jpg


Thnaks,
Sriram
 
It seems that variable Point1 is not a Point object. In order to find what object is behind Point1 variable please add this line into your code:


Code:
MsgBox TypeName(Point1)

and insert it behind the line:

Code:
Set Point1 = pointSel.Item(i).Value

Let me know what do you see in the message box.

Tesak
- Play Tetris in CATIA V5 drawing
 
Hi Tesak,

Sub CATMain()

Dim i As Integer
Dim coord(2)

Dim dwgDoc As DrawingDocument
Set dwgDoc = CATIA.ActiveDocument

Dim dwgViews As DrawingViews
Set dwgViews = CATIA.ActiveDocument.Sheets.ActiveSheet.Views

Dim dwgView As DrawingView
Set dwgView = dwgViews.ActiveView

Dim Point1 As Point2D

Dim pointSel As Selection
Set pointSel = dwgDoc.Selection

pointSel.Search "Name='GeneratedPoint',sel"

MsgBox pointSel.Count

For i = 1 To pointSel.Count

Set Point1 = pointSel.Item(i).Value
MsgBox TypeName(Point1)
Point1.GetCoordinates (coord)
MsgBox "(" & coord(0) & ", " & coord(1) & " ," & coord(2) & ")"

Next

pointSel.Clear

End Sub

error1_f7hyd2.jpg




Thnaks,
Sriram
 
I think it is a kind of bug in CATIA and it seems that you can not handle generated items of the view like lines, curves, points properly by VBA. If you try to approach them from inside VBA, you get a DrawingView object.

However, if you isolate the view & change your search query to look for points (not GeneratedPoint), your script should start to work properly.

Tesak
- Play Tetris in CATIA V5 drawing
 
Hi Tesak,

May be it is not possible using VBA but if I use CATIA.StartCommand ("Coordinate Dimension") after the search function it is generating (x,y,z) coordinate.
So, may be it can be possible with different programing language.

Thanks you very much for the support.

Thnaks,
Sriram
 
use the function to get the table, read the values from the table, make what you need, remove the table.

Eric N.
indocti discant et ament meminisse periti
 
reading info on isolated 2d point might not bring XYZ coord.

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

Part and Inventory Search

Sponsor

Back
Top