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!

*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

GetCoordinates of a Point in Drawing View

GetCoordinates of a Point in Drawing View

GetCoordinates of a Point in Drawing View


I am using Catia VBA Editor for finding the coordinates of a point in drawing view.
For some reason "GetCoordinates" method of Point2d object doesn't return anything in VBA.
The same is working fine with C#.

Exact issue as mentioned in this thread: https://www.eng-tips.com/viewthread.cfm?qid=455223

Manually i tried using "Measure Item" in Catia and selected the point in drawing view which gives me the Coordinates of the point relative to the view.
How do i automate Measure Item" in Drawing Document.

Measurable.GetMeasurable(CATIAReference iMeasuredItem) needs CATIAReference as parameter.
How can i create CATIAReference for an object in drawing document?

Like in PartDoc "Partdocument.Part.CreateReferenceFromObject"
How do i get in DrawingDoc "Drawingdocument.?"

Prasanna M

RE: GetCoordinates of a Point in Drawing View

All methods work the same whatever language you use.

I believe you get "Function or interface resteicted" error which may be swallowed by uneducated use of "On Error" statements.

Post your code.

RE: GetCoordinates of a Point in Drawing View

You are correct. I overlooked the code.

CODE --> vb

Sub Main()
Dim catDrwDoc As DrawingDocument
Set catDrwDoc = CATIA.ActiveDocument

Dim catDrwSel As Selection
Dim catDrwSelLb As Object

Set catDrwSel = catDrwDoc.Selection
Set catDrwSelLb = catDrwSel

Dim objFilter(0) As Variant
objFilter(0) = "Point2D"

Dim strStatus As String
strStatus = catDrwSelLb.SelectElement2(objFilter, "Select point in drawing view", False)

Dim catDrwViewPoint As Point2D
Dim catDrwViewPointLB As Object
If strStatus = "Normal" Then
    Set catDrwViewPoint = catDrwSel.Item2(1).Value
    Set catDrwViewPointLB = catDrwViewPoint
End If

Dim arrCoords(2)
catDrwViewPointLB.GetCoordinates arrCoords

MsgBox "X Coord : " + CStr(arrCoords(0)) + Chr(10) + "Y Coord : " + CStr(arrCoords(1)) + Chr(10)

End Sub 

RE: GetCoordinates of a Point in Drawing View

Thank for posting the code.

Note to everyone how "interface marked as restricted" error was worked around by typing actual Selection object "as Object"

Dim catDrwSelLb As Object

RE: GetCoordinates of a Point in Drawing View

@Little Cthulhu,
Follow-up question of my original post.
Will there be a need of using CATIAReference object in drawing?
If yes, how do i actually create a CATIAReference in drawing document?

Just to know in case i come across a case where i need to use CATIAReference in drawing in future.

Prasanna M

RE: GetCoordinates of a Point in Drawing View

You can't use CATIAReference in a drawing.

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! Already a Member? Login


eBook - Functional Prototyping Using Metal 3D Printing
Functional prototypes are a key step in product development – they give engineers a chance to test new ideas and designs while also revealing how the product will stand up to real-world use. And when it comes to functional prototypes, 3D printing is rewriting the rules of what’s possible. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close